RSS reader with Ptoka 3.3.21 and pxwsa.dll
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

RSS reader with Ptoka 3.3.21 and pxwsa.dll

Started by st0ne-db, 04 October, 2005, 21:32:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

st0ne-db

Im new to LUA and sockets in Ptokax. Is there a script avaible, or one that could be changed, to read a RSS feed through a socket and dump the info to a text file? The RSS feed I would like to read is:

http://www.console-news.org/rss/rss_xbox.rss

TIA

plop

QuoteOriginally posted by st0ne-db
Im new to LUA and sockets in Ptokax. Is there a script avaible, or one that could be changed, to read a RSS feed through a socket and dump the info to a text file? The RSS feed I would like to read is:

http://www.console-news.org/rss/rss_xbox.rss

TIA

i'm fighthing with 1, but can't get it 2 loop correctly.
would be great if some1 manages 2 compile a xml library for ptokax.
several versions can be found @ http://luaforge.net

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

st0ne-db

thanks, but that is a little beyond me at this point.
I have found this script.... looks like it might do what I want, but it seems that it is in LUA4. Any chance of someone helping me out and converting this one to LUA5. I think I may be able to edit some of the code to get it to format the data from the XML tags, if i can get the script to work. Any help would be much appreciated.


-- Web Reader 1.0
--
--by Mutor The Ugly
--
-- Grabs the code from a url and sends to:
--	-- Main chat
--	-- Private Message
--	-- Saves As Text
-- Grab just the text or full html code
--
-- Usage : +wread <[URL]http://www.webpath/docname.htm[/URL]>
--	ie.. +wread [URL]http://www.google.com/index.html[/URL]
--
--
--User Settings-------------------------------------------------------------------------------------
Bot = "[WebReader]"	--Name for bot
Command = "+wread"	--Script Command
gport = 80		--Port to connect to [80 is the default for web servers
PMResult = "no"		--Report results in PM
Save2File = "yes"	--Save to text file [will save text or full code if enabled
FullCode = "yes"	--Show/Save all html code or just text [html tags removed ...well mostly :P]
--End User Settings----------------------------------------------------------------------------------
--	
function GetNews(user, data)
FileName = filename
if Save2File ~= "yes" then filename = "[ DISABLED ]" end
local dsp
dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp = dsp.."\t >Fetching URL: "..ghost..gfile.."\r\n"
dsp = dsp.."\t >Saving To Filename: "..filename.."\r\n"
dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
user:SendData(Bot,dsp)
GETHTML = "GET "..gfile.." HTTP/1.1\r\nHost: "..ghost.."\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
	local socket, err = connect(ghost, gport)
	local code = ""
	if not err then
		socket:timeout(2)
		socket:send(GETHTML..strchar(13,10))
		local line = ""
		while not err do
			line, err = socket:receive("*a")
			code = code..line --.."\r\n"--
			x = gsub(code, "^(.+)%s*> > "," <<")
			x = gsub(x, ""," <<")
			x = gsub(x, "//","")
			x = gsub(x, ";}","")
			x = gsub(x, " "," ")
			x = gsub(x, ""","\"")
			x = gsub(x, "»","?")
			x = gsub(x, "&","&")
			x = gsub(x, "<","<")
			x = gsub(x, ">",">")
			x = gsub(x, "%%20"," ")
			x = gsub(x, "%s%s+","")
			x = gsub(x, "™","?")
			x = gsub(x, "©","?")
			x = gsub(x, "®","?")
			x = gsub(x, "•","?")
			x = gsub(x, "°","?")
			x = gsub(x, "·","?")
			x = gsub(x, "","\r\n")
			x = gsub(x, "","\r\n")
			x = gsub(x, "","\t")
			x = gsub(x, "

","\r\n") x = gsub(x, " ","\r\n") x = gsub(x, "<([^>]-)>","") end socket:close() end socket:close() if PMResult == "yes" then user:SendPM(FileName,x) if Save2File == "yes" then SaveFile(filename,x) end if FullCode == "yes" then user:SendData("AllCode: "..FileName,"\r\n\r\n"..code) if Save2File == "yes" then SaveFile("AllCode_"..filename,code) end end else user:SendData(FileName,x) if Save2File == "yes" then SaveFile(filename,x) end if FullCode == "yes" then user:SendData("AllCode: "..FileName,"\r\n\r\n"..code) if Save2File == "yes" then SaveFile("AllCode_"..filename,code) end end end GETHTML = "" ghostin = "" ghost = "" gfile = "" end function DataArrival(user, data) if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(Bot)) == "$To: "..Bot) then data = strsub(data,1,strlen(data)-1) s,e,cmd, ghostin, gfile = strfind(data, "%s+(%S+)%shttp%:%/%/(%S+%.[^%.%/]+%.%a+)(%/%S+)")-- if (cmd == Command) then ghost = ghostin ghost = gsub(ghost, "http://","") ghost = gsub(ghost, "HTTP://","") fixhost =  gsub(ghost, "%.", "-")   fixfile =  gsub(gfile, "/", "-") fixfile =  gsub(fixfile, ".html", ".txt") fixfile =  gsub(fixfile, ".htm", ".txt") fixfile =  gsub(fixfile, ".php", ".txt") fixfile =  gsub(fixfile, ".php?", ".txt") fixfile =  gsub(fixfile, ".cgi", ".txt") fixfile =  gsub(fixfile, ".asp", ".txt") fixfile =  gsub(fixfile, ".cfm", ".txt") filename = fixhost..fixfile GetNews(user, data) return 1 end end end function SaveFile(filename,code) local handle = openfile(filename,"w") write(handle,code) closefile(handle) end

bastya_elvtars

#3
Problem is that while HTML can have (mostly) known tags, XML can have any.

Also, tags aren't as important in HTML parsing as in XML.
Everything could have been anything else and it would have just as much meaning.

st0ne-db

Maybe I can explain what im trying to do a bit better.
I have a RSS feed, I would like to read the whole XML file and remove the parts i dont want.... and display it.
The RSS feed format is like this;



 
   
      Console-News
      [URL]http://www.console-news.org/[/URL]
      Console-News
   
       
       
         Sample Title
         Sample Description
         [URL]http://www.sampledomain.net[/URL]
       
       


So if im understanding the code for 'Web Reader 1.0' correctly the following code
would convert the XML tags from my feed into LUA string data.

while not err do
	line, err = socket:receive("*a")
	code = code..line --.."\r\n"--
  x = gsub(x, "","\t\t***************** \r\n")	
  x = gsub(x, "","\t\t***************** \r\n")		
	x = gsub(x, ""," ? Link: \r\n   ")
	x = gsub(x, "","\r\n")
	x = gsub(x, "","\r\n")
	x = gsub(x, "","\r\n\r\n")
	x = gsub(x, "","\t\t ** ")
	x = gsub(x, ""," ** \r\n")
	x = gsub(x, ""," ? ")
	x = gsub(x, "","\r\n")
end

And hopefully have an output similar to this....

  ****************
  ** Console News **
 ? Console News
   ****************

    ** Sample Title **
 ? Sample Description
 ? Link:
  [URL]http://www.sampledomain.net[/URL]

Would something like this even be possible with the Web Reader script?
I only would like to read this one RSS feed.

Thanks for all the help.

plop

on html you have a text with only have tags for layout/event features.
if you simply strip all of these the page becomes readable for humans.
the outcome stays text.
in a xml (rss)  they are key's, and there fore way more important.
what goes into the reader is a text file, but what has 2 come out is a table array mixture.
here's an example of what should come out of st0ne-db given rss feed.
tTable = {
	["channel"] = "Console-News"
	["link"] = [URL]http://www.console-news.org/,[/URL]
	["description"] = "Console-News - The one and only complete PS2, XBOX and GC-Release list.
	["item"] = {
		{
			["title"] = "Sniper_Elite_PAL_XBOXDVD-USA",
			["description"] = "Sniper_Elite_PAL_XBOXDVD-USA",
			["link"] = "http://www.console-news.org/index.php?_site=17&_subsite=2&vMode=nfo&system=2&nfo=5624",
		}

		{
			["title"] = "Darkwatch.PAL.MULTI5.XBOXDVD-WAR3X",
			["description"] = "Darkwatch.PAL.MULTI5.XBOXDVD-WAR3X",
			["link"] = "http://www.console-news.org/index.php?_site=17&_subsite=2&vMode=nfo&system=2&nfo=5623",
		}
	}
}
now check out the dcplusplus.xml, that would output a table.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Star

Have been waiting a long time for a bot like this in LUA5...
Nice to se it posseble now.

//StarChild

st0ne-db

#7
ok guys... i have pieced together this script... it seems to work just fine. If anyone can improve it, please feel free to.

--************************************************************************
--   CONSOLE-NEWS & NFOrce RSS FEED Bot     by: St0ne-db
--************************************************************************
--This script was pieced together using code from:
--
--Google.Bot.v.1.0.LUA5-ZD: ZD scripting team 
--Web Reader 1.0 : by Mutor The Ugly
--also thanks to bluebear & bastya_elvtars (http://ptxwiki.psycho-chihuahua.net/doku.php/scriptinghelp/pxwsa) 
--** I do not take credit for their work!! **
-- -St0ne-db
--
--
-- This script requires PxWSA.dll and PtokaX >= 3.3.21 
--
--  Commands:
-- !cnxbox            - [Console-News] Xbox Feed
-- !cnps2             - [Console-News] PS2 Feed
-- !cngc              - [Console-News] GameCube Feed
-- !cnall             - [Console-News] All Feeds
-- !nfall             - [NFOrce] All Feeds
-- !nfpcg-rip         - [NFOrce] PC Games-Rips Feed
-- !nfpcg-iso         - [NFOrce] PC Games-ISO Feed
-- !nfpcg-p           - [NFOrce] PC Games-Patches Feed
-- !nfpcg-dox         - [NFOrce] PC Games-Dox Feed
-- !nfpcg-addon       - [NFOrce] PC Games-Addons Feed
-- !nfpca-iso         - [NFOrce] PC Apps-ISO Feed
-- !nfdc              - [NFOrce] Dreamcast Feed
-- !nfps              - [NFOrce] Playstation Feed
-- !nfps2             - [NFOrce] PS2 Feed
-- !nfgba             - [NFOrce] GBA Feed
-- !nfxbox            - [NFOrce] Xbox Feed
-- !nfgc              - [NFOrce] Game Cube Feed
-- !nfdivx            - [NFOrce] DiVX Feed
-- !nfxvid            - [NFOrce] XViD Feed
-- !nfvcd             - [NFOrce] VCD Feed
-- !nfsvcd            - [NFOrce] SVCD Feed
-- !nfanime           - [NFOrce] Anime Feed
-- !nfxxx             - [NFOrce] XXX Feed
-- !nftv              - [NFOrce] TV-Rips Feed
-- !nfdvdr            - [NFOrce] DVD-R Feed

-- VARIABLES --
sBot = "Slo_B";   -- Bot Name
sPrefix = "!";    -- Command Prefix
--    END    --

libinit = loadlib("pxwsa.dll", "_libinit")
libinit()

CmdOpt = {
	["cnxbox"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["cnps2"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["cngc"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["cnall"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfall"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfpcg-rip"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfpcg-iso"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfpcg-p"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfpcg-dox"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfpcg-addon"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfpca-iso"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfdc"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},


	["nfps"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfps2"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},	
	
	["nfgba"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfxbox"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfgc"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfdivx"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfxvid"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfvcd"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfsvcd"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfanime"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

	["nfxxx"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nftv"] = { 
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["nfdvdr"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},
	
	["rsshelp"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

};

function Main()
	frmHub:RegBot(sBot);
end

function ChatArrival(user,data)
	data=string.sub(data,1,-2);
	local s,e,cmd = string.find(data,"^%b<>%s+(%S+)");
	local Prefix = string.sub(cmd,1,1);
	s,e,usr=string.find(data, "<(%S+)>")
	if (Prefix == sPrefix) then
		cmd = string.lower(string.sub(cmd,2,string.len(cmd)));
		if (Commands[cmd]) then
			return (Commands[cmd](user,data))
		end
	end	
end

Commands = {

--------------------------------------------------------------------------------
-- Console-News
--------------------------------------------------------------------------------
	["cnxbox"] = 
	function(user,data)
		if (Denial("cnxbox",user) == 1) then return 1 end
		--Variables:
    xhost="www.console-news.org"
    xfile="/rss/rss_xbox.rss"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,	

	["cnps2"] = 
	function(user,data)
		if (Denial("cnps2",user) == 1) then return 1 end
		--Variables:
    xhost="www.console-news.org"
    xfile="/rss/rss_ps2.rss"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,	
  
	["cngc"] = 
	function(user,data)
		if (Denial("cngc",user) == 1) then return 1 end
		--Variables:
    xhost="www.console-news.org"
    xfile="/rss/rss_gc.rss"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,	
  
	["cnall"] = 
	function(user,data)
		if (Denial("cnall",user) == 1) then return 1 end
		--Variables:
    xhost="www.console-news.org"
    xfile="/rss/rss_all.rss"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,	 

--------------------------------------------------------------------------------
-- NFOrce
--------------------------------------------------------------------------------

	["nfall"] = 
	function(user,data)
		if (Denial("nfall",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_all.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpcg-rip"] = 
	function(user,data)
		if (Denial("nfpcg-rip",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_1.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpcg-iso"] = 
	function(user,data)
		if (Denial("nfpcg-iso",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_2.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpcg-p"] = 
	function(user,data)
		if (Denial("nfpcg-p",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_4.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpcg-dox"] = 
	function(user,data)
		if (Denial("nfpcg-dox",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_5.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpcg-addon"] = 
	function(user,data)
		if (Denial("nfpcg-addon",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_3.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfpca-iso"] = 
	function(user,data)
		if (Denial("nfpca-iso",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_6.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfdc"] = 
	function(user,data)
		if (Denial("nfdc",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_7.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfps"] = 
	function(user,data)
		if (Denial("nfps",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_8.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfps2"] = 
	function(user,data)
		if (Denial("nfps2",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_9.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfgba"] = 
	function(user,data)
		if (Denial("nfgba",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_10.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfxbox"] = 
	function(user,data)
		if (Denial("nfxbox",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_11.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfgc"] = 
	function(user,data)
		if (Denial("nfgc",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_20.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfdivx"] = 
	function(user,data)
		if (Denial("nfdivx",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_12.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfxvid"] = 
	function(user,data)
		if (Denial("nfxvid",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_13.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfvcd"] = 
	function(user,data)
		if (Denial("nfvcd",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_14.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfsvcd"] = 
	function(user,data)
		if (Denial("nfsvcd",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_15.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfanime"] = 
	function(user,data)
		if (Denial("nfanime",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_16.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfxxx"] = 
	function(user,data)
		if (Denial("nfxxx",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_17.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nftv"] = 
	function(user,data)
		if (Denial("nftv",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_19.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["nfdvdr"] = 
	function(user,data)
		if (Denial("nfdvdr",user) == 1) then return 1 end
		--Variables:
    xhost="www.nforce.nl"
    xfile="/rss/rss_18.xml"
    xport=80
    xprot=0
    --END
    SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

	["rsshelp"] = 
	function(user,data)
		if (Denial("rsshelp",user) == 1) then return 1 end
    local rsshlp = "\t\t ** RSS Feed Bot Commands **    \r\n\r\n "
    rsshlp = rsshlp.."\t !cnxbox \t\t- [Console-News] Xbox Feed   \r\n "
    rsshlp = rsshlp.."\t !cnps2 \t\t- [Console-News] PS2 Feed   \r\n "
    rsshlp = rsshlp.."\t !cngc \t\t- [Console-News] GameCube Feed   \r\n "
    rsshlp = rsshlp.."\t !cnall \t\t- [Console-News] All Feeds   \r\n "
    rsshlp = rsshlp.."\t !nfall \t\t- [NFOrce] All Feeds   \r\n "
    rsshlp = rsshlp.."\t !nfpcg-rip \t- [NFOrce] PC Games-Rips Feed   \r\n "
    rsshlp = rsshlp.."\t !nfpcg-iso \t- [NFOrce] PC Games-ISO Feed   \r\n "
    rsshlp = rsshlp.."\t !nfpcg-p \t\t- [NFOrce] PC Games-Patches Feed   \r\n "
    rsshlp = rsshlp.."\t !nfpcg-dox \t- [NFOrce] PC Games-Dox Feed   \r\n "
    rsshlp = rsshlp.."\t !nfpcg-addon \t- [NFOrce] PC Games-Addons Feed   \r\n "
    rsshlp = rsshlp.."\t !nfpca-iso \t- [NFOrce] PC Apps-ISO Feed   \r\n "
    rsshlp = rsshlp.."\t !nfdc \t\t- [NFOrce] Dreamcast Feed   \r\n "
    rsshlp = rsshlp.."\t !nfps \t\t- [NFOrce] Playstation Feed   \r\n "
    rsshlp = rsshlp.."\t !nfps2 \t\t- [NFOrce] PS2 Feed   \r\n "
    rsshlp = rsshlp.."\t !nfgba \t\t- [NFOrce] GBA Feed   \r\n "
    rsshlp = rsshlp.."\t !nfxbox \t\t- [NFOrce] Xbox Feed   \r\n "
    rsshlp = rsshlp.."\t !nfgc \t\t- [NFOrce] Game Cube Feed   \r\n "
    rsshlp = rsshlp.."\t !nfdivx \t\t- [NFOrce] DiVX Feed   \r\n "
    rsshlp = rsshlp.."\t !nfxvid \t\t- [NFOrce] XViD Feed   \r\n "
    rsshlp = rsshlp.."\t !nfvcd \t\t- [NFOrce] VCD Feed   \r\n "
    rsshlp = rsshlp.."\t !nfsvcd \t\t- [NFOrce] SVCD Feed   \r\n "
    rsshlp = rsshlp.."\t !nfanime \t- [NFOrce] Anime Feed   \r\n "
    rsshlp = rsshlp.."\t !nfxxx \t\t- [NFOrce] XXX Feed   \r\n "
    rsshlp = rsshlp.."\t !nftv \t\t- [NFOrce] TV-Rips Feed   \r\n "
    rsshlp = rsshlp.."\t !nfdvdr \t\t- [NFOrce] DVD-R Feed   \r\n "   
    SendToNick(usr, "<"..sBot.."> \r\n"..rsshlp)                                                                              
    return 1;
	end,

};

function Denial(Table, user)
	if (CmdOpt[Table][user.iProfile] ~= 1) then
		SendToNick(usr, "<"..sBot.."> *** You are not allowed to use this command!");
		return 1;
	end
end

function OpenSck( xhost, xfile, xport, xprot )
    _,_,sock=WSA.NewSocket(xprot)
    WSA.BeginConnect(sock,xhost,xport)
end

function OnWsaConnected ( errorCode, errorStr, sock )
  if errorCode then
    SendToNick(usr, "<"..sBot.."> *** Connection Failed...  err:"..errorCode)
    WSA.Close(sock)
  else
    local CMD="GET "..xfile.." HTTP/1.1\r\nHost: "..xhost.."\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"..string.char(13,10)
    WSA.BeginSend(sock,CMD)
  end
end
 
function OnWsaSendComplete ( errorCode, errorStr, sock, bytesSent )
  if errorCode then
    SendToNick(usr, "<"..sBot.."> *** Connection Failed...  err:"..errorCode)
    WSA.Close(sock)
  else
    WSA.BeginReceive(sock)
  end
end

function OnWsaDataArrival(errorCode,errorStr,sock,sdata,bytesRead)
	if not errorCode or (errorCode==10040 and prot==0) then
		DataRecv=DataRecv..sdata
		return 1
	else
 		DataRecv=string.gsub(DataRecv, "",string.rep("*",65))
		DataRecv=string.gsub(DataRecv, "",string.rep("*",65).." \r\n")
		DataRecv=string.gsub(DataRecv, ""," ? ")
		DataRecv=string.gsub(DataRecv, "","\r\n")
		DataRecv=string.gsub(DataRecv, "(.-)","")
		DataRecv=string.gsub(DataRecv, ""," ? ")
		DataRecv=string.gsub(DataRecv, ""," \r\n")
		DataRecv=string.gsub(DataRecv, "(.-)","")
		DataRecv=string.gsub(DataRecv, "/a>","")
		DataRecv=string.gsub(DataRecv, "<","")
		DataRecv=string.gsub(DataRecv, "b>","")
		DataRecv=string.gsub(DataRecv, "/b>","")
		DataRecv=string.gsub(DataRecv, ">"," ")
		DataRecv=string.gsub(DataRecv, "br /","")
		DataRecv=string.gsub(DataRecv, "/ br","")
		DataRecv=string.gsub(DataRecv, "; released &(.-)Size:","")
		DataRecv=string.gsub(DataRecv, "Size:","\r\n\t\t\t ? Size: ")
  	DataRecv=string.gsub(DataRecv, ""","")
	  DataRecv=string.gsub(DataRecv, "a href=","\r\n\t\t\t ? ")
	  DataRecv=string.gsub(DataRecv, "Review","  - Review")
	  DataRecv=string.gsub(DataRecv, ""," ? Comments:\r\n")
	  DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "",string.rep("*",20).." Release Name "..string.rep("*",20))
		DataRecv=string.gsub(DataRecv, "","\r\n")
		DataRecv=string.gsub(DataRecv, ""," ? ")
		DataRecv=string.gsub(DataRecv, "","\r\n")
		DataRecv=string.gsub(DataRecv, ""," ? ")
		DataRecv=string.gsub(DataRecv, "","\r\n")
		DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "","")
		DataRecv=string.gsub(DataRecv, "","")
    SendToNick(usr, "\r\n "..DataRecv)
		DataRecv=""
		WSA.Close(sock)
		return 0
   end
end

DataRecv=""
xData=""
xhost=""
xfile=""
xprot=""
xport=""

function OnExit()
end

Thanks go out to everyone on this forum who helped out.   :)

Skippy84

#8
@stone-db thx its a great work:))





i translated the script into german

RSS feed Bot  :]

Pothead

Just a little suggestion for how it runs.  :)
Instead of having all the tables at the top, for what profile can access which command, allow all registered users access, and one master switch for unregistered users.
Then for each type of feed have an enable / disable option.
Combine this with a timer function which will download and save all the Enabled feeds to a text file, every XX hours.
Then upon using the commands (of enabled feeds) the contents of the relavent text file are outputted. :)

kunal

i m getting this error in stone db's script
[19:28] Syntax C:\ptokax0.3.3.21\scripts\RSSfeed.lua:727: `)' expected near `","'

st0ne-db

#11
QuoteOriginally posted by kunal
i m getting this error in stone db's script
[19:28] Syntax C:\ptokax0.3.3.21\scripts\RSSfeed.lua:727: `)' expected near `","'

sorry, seems that when i posted the code it changed that line... i edited the post, should be fine now.

line 727 should read:
 	DataRecv=string.gsub(DataRecv, "& quot;","")

it seems that the "& quot;" was removed from the post.
****** note please remove the space between '& q' in the above line... the board changes the code to a "

if someone wouldnt mind hosting the org. script, please let me know.

witch

Hi very nice script, but i got this error:

[11:27] Syntax ...oka\![pz]0.3.3.21.nt.dbg01.10.05\![pz]0.3.3.21.nt.dbg\scripts\consol.lua:1453: `)' expected near `","'

thx in advice  :P




st0ne-db

ok, for everyone who is havin problems.... get a fresh copy of the orginal script here.    :)

http://us.f1.yahoofs.com/bc/43457645_13963/bc/LUA5+Scripts/Console-NFO+RSS+Feed+Bot.rar?bf38XRDBAvDLYiFR

witch

QuoteOriginally posted by st0ne-db
ok, for everyone who is havin problems.... get a fresh copy of the orginal script here.    :)

http://us.f1.yahoofs.com/bc/43457645_13963/bc/LUA5+Scripts/Console-NFO+RSS+Feed+Bot.rar?bf38XRDBAvDLYiFR
thx m8  :P



plop

QuoteOriginally posted by st0ne-db if someone wouldnt mind hosting the org. script, please let me know.

upload it 2 the script database, the url you know (or look in bastya's signature).

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Star

Can it be mod so it's easier to add other RSS feed pages and commands to that? Is some sort of settings?

Great job!
//StarChild

st0ne-db

QuoteOriginally posted by Star
Can it be mod so it's easier to add other RSS feed pages and commands to that? Is some sort of settings?

Great job!
//StarChild

here is how to add feeds... may take a little work...

the script uses a basic format:

CmdOpt = {}
["CMDNAME"] = {
		[0] = 1,
		[1] = 1,
		[2] = 0,
		[3] = 0,
		[-1] = 0,
	},

where CMDNAME = the trigger for the feed.

Commands = {}
["CMDNAME"] = 
	function(user,data)
		if (Denial("CMDNAME",user) == 1) then return 1 end
--Variables:
 xhost="www.console-news.org"
 xfile="/rss/rss_xbox.rss"
 xport=80
 xprot=0
--END
         SendToNick(usr, "<"..sBot.."> *** Request Sent..  Please Wait")
   	OpenSck( xhost, xfile, xport, xprot )                                                                                            
    return 1;
	end,

and the function for the CMDNAME

just copy the fucntions..... and edit the variables;
xhost: site host
xfile: file
xport: port
xprot: 0 for TCP, 1 for UDP

and finally...
this part can be tricky....
find this code in the function  OnWsaDataArrival()
DataRecv=string.gsub(DataRecv, "","\r\n")

here is where you can edit how the script handles the XML tags. I would recommend saving the RSS feed in question and opening it up in PSPad. If you need help on a certain feed, let me know.

st0ne-db


SMF spam blocked by CleanTalk