[Pybot-commits] CVS: pybot/scripts pybotopt.py,1.1.1.1,1.2 pybotsetup.py,1.1.1.1,1.2 pybot.py,1.1.1.
Brought to you by:
niemeyer
From: Gustavo N. <nie...@us...> - 2001-12-04 00:57:41
|
Update of /cvsroot/pybot/pybot/scripts In directory usw-pr-cvs1:/tmp/cvs-serv32496/scripts Modified Files: pybotopt.py pybotsetup.py Removed Files: pybot.py Log Message: - Implemented new startup system. - Converted tabs to spaces so people using other editors feel confortable as well (suggested by John Thingstad). Index: pybotopt.py =================================================================== RCS file: /cvsroot/pybot/pybot/scripts/pybotopt.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pybotopt.py 2001/11/02 17:20:37 1.1.1.1 --- pybotopt.py 2001/12/04 00:57:38 1.2 *************** *** 34,87 **** random.seed(time.time()) ! def random_answer(*pattern): ! ret = [] ! for tok in pattern: ! if type(tok) == type(()): ! recret = self._answer(tok) ! ret = ret + recret ! elif type(tok) == type([]): ! tmptok = tok[random.randint(0,len(tok)-1)] ! if type(tmptok) == type(""): ! ret.append(tmptok) ! elif tmptok != None: ! recret = self._answer(tmptok) ! ret.append(recret) ! elif tok != None: ! ret.append(tok) ! if ret: ! str = ret[0] ! for tok in ret[1:]: ! if tok[0] in [".","!","?"]: ! str = str+tok ! else: ! str = str+" "+tok ! else: ! str = "" ! return str if len(sys.argv)==3 and sys.argv[1] in ["show","print"]: ! if os.path.exists("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() ! if not option.has_key(sys.argv[2]): ! print random_answer(["It seems that", "Sorry, but", "Sir,"], "there's not such option.") ! else: ! print option[sys.argv[2]] ! else: ! print "There's no options file, sir!" elif len(sys.argv)>5 and sys.argv[1:3]==["set"] and sys.argv[4] == "to": ! if os.path.exists("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() ! else: ! option = {} ! option[sys.argv[3]] = eval(string.join(sys.argv[5:])) ! file = open("options", "w") ! option = cPickle.dump(option,file,1) ! file.close() ! print "Done, sir!" ! # vim:ts=4:sw=4 --- 34,87 ---- random.seed(time.time()) ! def random_answer(*pattern): ! ret = [] ! for tok in pattern: ! if type(tok) == type(()): ! recret = self._answer(tok) ! ret = ret + recret ! elif type(tok) == type([]): ! tmptok = tok[random.randint(0,len(tok)-1)] ! if type(tmptok) == type(""): ! ret.append(tmptok) ! elif tmptok != None: ! recret = self._answer(tmptok) ! ret.append(recret) ! elif tok != None: ! ret.append(tok) ! if ret: ! str = ret[0] ! for tok in ret[1:]: ! if tok[0] in [".","!","?"]: ! str = str+tok ! else: ! str = str+" "+tok ! else: ! str = "" ! return str if len(sys.argv)==3 and sys.argv[1] in ["show","print"]: ! if os.path.exists("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() ! if not option.has_key(sys.argv[2]): ! print random_answer(["It seems that", "Sorry, but", "Sir,"], "there's not such option.") ! else: ! print option[sys.argv[2]] ! else: ! print "There's no options file, sir!" elif len(sys.argv)>5 and sys.argv[1:3]==["set"] and sys.argv[4] == "to": ! if os.path.exists("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() ! else: ! option = {} ! option[sys.argv[3]] = eval(string.join(sys.argv[5:])) ! file = open("options", "w") ! option = cPickle.dump(option,file,1) ! file.close() ! print "Done, sir!" ! # vim:ts=4:sw=4:et Index: pybotsetup.py =================================================================== RCS file: /cvsroot/pybot/pybot/scripts/pybotsetup.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pybotsetup.py 2001/11/02 17:20:37 1.1.1.1 --- pybotsetup.py 2001/12/04 00:57:38 1.2 *************** *** 28,39 **** if os.path.isfile("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() else: ! option = {} try: ! print """ This program does the basic setup for pybot. It will allow you to set the first nick, username and server you want pybot to connect, --- 28,39 ---- if os.path.isfile("options"): ! file = open("options") ! option = cPickle.load(file) ! file.close() else: ! option = {} try: ! print """ This program does the basic setup for pybot. It will allow you to set the first nick, username and server you want pybot to connect, *************** *** 48,92 **** everything else. """ ! raw_input("Press [ENTER] to continue...") ! print """ Enter the nick you're going to use while talking to pybot.""" ! nick = raw_input("Your nick: ") ! print """Enter the username you're going to use while talking to pybot. Please, note that you may have a '~' added to your username, depending on your host's configuration. If you want to be sure what your username is, issue a '/whois %s' while connected to your irc server. You may also use a wildcard, like *username, if you're not sure at all."""%nick ! username = raw_input("Your username: ") ! print """ Enter the hostname you're going to use while talking to pybot. If you're not sure, you should also look at the output of the command '/whois %s' while connected to your irc server. A wildcard like *.my.host also work here, but be careful!"""%nick ! hostname = raw_input("Your host: ") ! print """ Enter the server name:port where pybot will connect to. This is just to start it out. You may add and/or remove servers later talking with him.""" ! server = raw_input("Server: ") ! print """ Enter the pybot nick you want to use in this server. That's important because you'll be able to tell him to join a channel and/or connect to a server by talking with him, so make sure you remember the nick.""" ! pybotnick = raw_input("Pybot's nick: ") ! print """ Enter the username pybot will use in this server.""" ! pybotusername = raw_input("Pybot's username: ") ! print """ Enter the real name pybot will use in this server.""" ! pybotrealname = raw_input("Pybot's real name: ") except EOFError: ! sys.exit("Interrupted!") option["Permission.gosh"] = [pybot.User(nick, username, hostname)] --- 48,92 ---- everything else. """ ! raw_input("Press [ENTER] to continue...") ! print """ Enter the nick you're going to use while talking to pybot.""" ! nick = raw_input("Your nick: ") ! print """Enter the username you're going to use while talking to pybot. Please, note that you may have a '~' added to your username, depending on your host's configuration. If you want to be sure what your username is, issue a '/whois %s' while connected to your irc server. You may also use a wildcard, like *username, if you're not sure at all."""%nick ! username = raw_input("Your username: ") ! print """ Enter the hostname you're going to use while talking to pybot. If you're not sure, you should also look at the output of the command '/whois %s' while connected to your irc server. A wildcard like *.my.host also work here, but be careful!"""%nick ! hostname = raw_input("Your host: ") ! print """ Enter the server name:port where pybot will connect to. This is just to start it out. You may add and/or remove servers later talking with him.""" ! server = raw_input("Server: ") ! print """ Enter the pybot nick you want to use in this server. That's important because you'll be able to tell him to join a channel and/or connect to a server by talking with him, so make sure you remember the nick.""" ! pybotnick = raw_input("Pybot's nick: ") ! print """ Enter the username pybot will use in this server.""" ! pybotusername = raw_input("Pybot's username: ") ! print """ Enter the real name pybot will use in this server.""" ! pybotrealname = raw_input("Pybot's real name: ") except EOFError: ! sys.exit("Interrupted!") option["Permission.gosh"] = [pybot.User(nick, username, hostname)] *************** *** 99,101 **** print "Options saved!" ! # vim:ts=4:sw=4 --- 99,101 ---- print "Options saved!" ! # vim:ts=4:sw=4:et --- pybot.py DELETED --- |