make user/realname/port possible to change in config file

This commit is contained in:
Ryan Hitchman 2010-01-17 13:20:11 -07:00
parent 2fd4375d78
commit 1bc0a3497a
3 changed files with 17 additions and 6 deletions

2
bot.py
View File

@ -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()

View File

@ -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

View File

@ -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: