Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

RES: Rebot progressing nicely!

 [1/2] from: carlos::lorenz::net at: 29-Nov-2000 18:01


Hi Mat May I take a look at rebot? --Carlos Lorenz -----Mensagem original----- De: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]Em nome de Mat Bettinson Enviada em: Quarta-feira, 29 de Novembro de 2000 17:33 Para: Dan Rolander Assunto: [REBOL] Rebot progressing nicely! Hi folks, I've made absolutely fantastic progress with my Rebol IRC bot. It's fully functional now and it's been amazing people how easily I drop in new commands that actually DO cool stuff. Like ripping the top 3 BBCnews headlines :) I found a port combination of /no-wait and /lines made the code really easy to use, not having to worry about a buffer and ignoring the last line until it was completed later etc. Anyhow, the code is turning into something really quite spaghetti style. I thought making it modular would be best. IE /msg rebot <command> <args> Would go off and run rebot-<command>.r The question is, would this be relatively quick and how do I parse args to another rebot script? I'm amazed I've got this far given how little of the basics I understand :) I'm somewhat interested in these new Rebol books that are out now. I don't consider the official guide to be very conducive to learning the language at all, unfortunately. It's irritatingly vague on all the stuff that really matters (and you guys have born the grunt of my stupid questions as a result). How do the others rate, anyone seen them? -- Mat Bettinson - EuroGamer's Gaming Evangelist with a Goatee http://www.eurogamer.net | http://www.eurogamer-network.com

 [2/2] from: mat:eurogamer at: 30-Nov-2000 0:59


Heya Mailbank, M> Hi Mat M> May I take a look at rebot? Couple of requests for this, what I'll print here probably doesn't work because I've cut something vital out. However it'd be much easier to see what's going on after I cut the reams and reams of game server functions and other stuff out out. I also learned a great many things so I'm actually going to ditch this and re-write it in sort of proper Rebol with half as many temporary variables; < -- Cut -- > Rebol [] ircserver: "irc.server.com" ircport: 6667 channel: "#channel" nick: "Rebot" usern: "Rebot" hostn: "0wnerage.com" servern: "irc.server.com" realn: "Rebol Bot Alpha 1" bold: to-char 2 underline: to-char 31 SendCMD: func [ irccommand ][ insert irccon irccommand ] get-status: func [ SendChan: func [ whattosay ][ sendCMD rejoin ["PRIVMSG " channel " :" whattosay] ] PrivMSG: func [ whattosay ][ SendCMD rejoin ["PRIVMSG " currentnick " :" whattosay] ] Quitchannel: func [ quitmsg ][ SendCMD rejoin ["PART " channel " :" quitmsg ] ] HelpSubject: func [ hsubject ][ switch hsubject [ "search" [PrivMSG "Usage: Search <playername>"] "commands" [PrivMSG rejoin [Nick " commands: commands, search, bbcnews, translate, serverstatus, serverannounce"] ] ] ] ProcessPublic: func [ ][ channelwords: parse channeltext none if nick = pick channelwords 1 [ publiccommand: find/tail channeltext nick publickeyword: pick parse publiccommand none 1 switch publickeyword [ "quit" [ SendChan "Bah :(" Quitchannel "Nobody loves me..." wait irccon close irccon halt ] comment {loads of switches for public commands goes here} ] ] ] ProcessPrivate: func [ ][ Print "Processing private msg" privatewords: parse msgtext none command: pick privatewords 1 print command switch command [ "search" [ searchOGA ] "commands" [ HelpSubject "commands"] "cmds" [ HelpSubject "commands"] comment {loads of switches for private /msg commands go here} ] ] ReadIRC: func [ ][ ircout: copy irccon for i 1 lnircout 1 [ ln: pick ircout i lnwords: parse ln none keyword: pick lnwords 1 irccommand: pick lnwords 2 if keyword = "PING" [ pingstamp: pick lnwords 2 SendCMD rejoin ["PONG " pingstamp] ] parse ln [thru ":" copy currentnick to "!"] if irccommand = "PRIVMSG" [ if channel = pick lnwords 3 [ channeltext: find/tail ln " :" ProcessPublic ] if nick = pick lnwords 3 [ msgtext: find/tail ln " :" ProcessPrivate ] ] ] return ircout ] Comment { THIS IS THE MAIN LOOP } ircurl: make url! rejoin ["tcp://" ircserver ":" ircport] if error? try [irccon: open/lines/no-wait ircurl] [ print ["Error connecting to server" ircurl] halt ] sendCMD rejoin ["NICK " nick] wait irccon print readIRC sendCMD rejoin ["USER " usern " " hostn " " servern " " realn] sendCMD rejoin ["JOIN " channel] SendChan "Rebot is my name and 0wnerage is my game! /msg rebot commands" do forever [ print readirc wait irccon ] -- Mat Bettinson - EuroGamer's Gaming Evangelist with a Goatee http://www.eurogamer.net | http://www.eurogamer-network.com