Archive => Archived 5.0 boards => Request for scripts => Topic started by: st0ne-db on 04 October, 2005, 21:32:26
Title: RSS reader with Ptoka 3.3.21 and pxwsa.dll
Post by: st0ne-db on 04 October, 2005, 21:32:26
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
Title:
Post by: plop on 04 October, 2005, 22:38:06
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
Title:
Post by: st0ne-db on 05 October, 2005, 00:34:23
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.
","\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
function SaveFile(filename,code) local handle = openfile(filename,"w") write(handle,code) closefile(handle) end
Title:
Post by: bastya_elvtars on 05 October, 2005, 00:40:03
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.
Title:
Post by: st0ne-db on 05 October, 2005, 01:47:43
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;
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
** 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.
Title:
Post by: plop on 05 October, 2005, 14:24:43
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
Title:
Post by: Star on 05 October, 2005, 19:51:09
Have been waiting a long time for a bot like this in LUA5... Nice to se it posseble now.
//StarChild
Title:
Post by: st0ne-db on 06 October, 2005, 06:19:20
ok guys... i have pieced together this script... it seems to work just fine. If anyone can improve it, please feel free to.
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
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
Title:
Post by: Pothead on 06 October, 2005, 12:40:56
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. :)
Title:
Post by: kunal on 06 October, 2005, 15:59:32
i m getting this error in stone db's script [19:28] Syntax C:\ptokax0.3.3.21\scripts\RSSfeed.lua:727: `)' expected near `","'
Title:
Post by: st0ne-db on 06 October, 2005, 19:59:14
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.
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.
Title:
Post by: witch on 06 October, 2005, 20:29:53
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
Title:
Post by: Pothead on 06 October, 2005, 21:30:58
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.
Title:
Post by: st0ne-db on 09 October, 2005, 21:23:52