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
|
print 'ERROR: more than one connection named "%s"' % name
|
||||||
raise ValueError
|
raise ValueError
|
||||||
bot.conns[name] = irc(conf['server'], conf['nick'],
|
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:
|
except Exception, e:
|
||||||
print 'ERROR: malformed config file', Exception, e
|
print 'ERROR: malformed config file', Exception, e
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -4,9 +4,19 @@ from util import yaml
|
||||||
|
|
||||||
if not os.path.exists('config'):
|
if not os.path.exists('config'):
|
||||||
conf = {'connections': [
|
conf = {'connections': [
|
||||||
{'local irc': {'nick': 'skybot',
|
{'local irc':
|
||||||
|
{'nick': 'skybot',
|
||||||
|
#'user': 'skybot',
|
||||||
|
#'realname': 'Python bot - http://bitbucket.org/Scaevolus/skybot/',
|
||||||
'server': 'localhost',
|
'server': 'localhost',
|
||||||
'channels': ["#test"]}}]}
|
#'port': 6667,
|
||||||
|
'channels': ["#test"],
|
||||||
|
#'nickserv_password', 'password',
|
||||||
|
#'nickserv_name': 'nickserv',
|
||||||
|
#'nickserv_command': 'IDENTIFY %s'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
||||||
yaml.dump(conf, open('config', 'w'))
|
yaml.dump(conf, open('config', 'w'))
|
||||||
del conf
|
del conf
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,9 @@ class irc(object):
|
||||||
self.conn = crlf_tcp(self.server, self.port)
|
self.conn = crlf_tcp(self.server, self.port)
|
||||||
thread.start_new_thread(self.conn.run, ())
|
thread.start_new_thread(self.conn.run, ())
|
||||||
self.set_nick(self.nick)
|
self.set_nick(self.nick)
|
||||||
self.cmd("USER", ["skybot", "3", "*",
|
self.cmd("USER",
|
||||||
":Python bot - http://bitbucket.org/Scaevolus/skybot/"])
|
[conf.get('user', 'skybot'), "3", "*", ':' + conf.get('realname',
|
||||||
|
'Python bot - http://bitbucket.org/Scaevolus/skybot/')])
|
||||||
|
|
||||||
def parse_loop(self):
|
def parse_loop(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue