packages/ircbot: a bit of refactoring
This commit is contained in:
parent
9c8abab1e3
commit
5e787f49ce
1 changed files with 10 additions and 12 deletions
|
@ -1,23 +1,21 @@
|
||||||
import justirc
|
import justirc
|
||||||
|
|
||||||
NICK = 'smith'
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
config = dict(nick='smith', debug=False)
|
||||||
|
run_bot(config)
|
||||||
|
|
||||||
|
def run_bot(c):
|
||||||
bot = justirc.IRCConnection()
|
bot = justirc.IRCConnection()
|
||||||
|
|
||||||
|
if c['debug']:
|
||||||
@bot.on('packet')
|
@bot.on('packet')
|
||||||
def new_packet(e):
|
def new_packet(e):
|
||||||
print(e.packet)
|
print(e.packet)
|
||||||
|
|
||||||
@bot.on('connected')
|
|
||||||
def reload_plugins(e):
|
|
||||||
print('bot has connected')
|
|
||||||
|
|
||||||
@bot.on('connect')
|
@bot.on('connect')
|
||||||
def connect(e):
|
def connect(e):
|
||||||
bot.send_line(f'NICK {NICK}')
|
bot.send_line(f'NICK {c["nick"]}')
|
||||||
bot.send_line(f'USER {NICK} 8 * {NICK}')
|
bot.send_line(f'USER {c["nick"]} 8 * {c["nick"]}')
|
||||||
bot.emit('connected')
|
|
||||||
|
|
||||||
@bot.on('welcome')
|
@bot.on('welcome')
|
||||||
def welcome(e):
|
def welcome(e):
|
||||||
|
|
Loading…
Reference in a new issue