From 1bc0a3497a0aa23eb07f6c075117a3cc9a566ffd Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Sun, 17 Jan 2010 13:20:11 -0700 Subject: [PATCH] make user/realname/port possible to change in config file --- bot.py | 2 +- core/config.py | 16 +++++++++++++--- core/irc.py | 5 +++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 18ecc57..a56856e 100755 --- a/bot.py +++ b/bot.py @@ -32,7 +32,7 @@ try: print 'ERROR: more than one connection named "%s"' % name raise ValueError bot.conns[name] = irc(conf['server'], conf['nick'], - channels=conf['channels'], conf=conf) + port=conf.get('port', 6667), channels=conf['channels'], conf=conf) except Exception, e: print 'ERROR: malformed config file', Exception, e sys.exit() diff --git a/core/config.py b/core/config.py index 0fc8dee..12336bc 100644 --- a/core/config.py +++ b/core/config.py @@ -4,9 +4,19 @@ from util import yaml if not os.path.exists('config'): conf = {'connections': [ - {'local irc': {'nick': 'skybot', - 'server': 'localhost', - 'channels': ["#test"]}}]} + {'local irc': + {'nick': 'skybot', + #'user': 'skybot', + #'realname': 'Python bot - http://bitbucket.org/Scaevolus/skybot/', + 'server': 'localhost', + #'port': 6667, + 'channels': ["#test"], + #'nickserv_password', 'password', + #'nickserv_name': 'nickserv', + #'nickserv_command': 'IDENTIFY %s' + } + } + ]} yaml.dump(conf, open('config', 'w')) del conf diff --git a/core/irc.py b/core/irc.py index b86ff60..c8c050c 100644 --- a/core/irc.py +++ b/core/irc.py @@ -93,8 +93,9 @@ class irc(object): self.conn = crlf_tcp(self.server, self.port) thread.start_new_thread(self.conn.run, ()) self.set_nick(self.nick) - self.cmd("USER", ["skybot", "3", "*", - ":Python bot - http://bitbucket.org/Scaevolus/skybot/"]) + self.cmd("USER", + [conf.get('user', 'skybot'), "3", "*", ':' + conf.get('realname', + 'Python bot - http://bitbucket.org/Scaevolus/skybot/')]) def parse_loop(self): while True: