make user/realname/port possible to change in config file
This commit is contained in:
parent
2fd4375d78
commit
1bc0a3497a
2
bot.py
2
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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue