fixed a few bugs
This commit is contained in:
parent
2affdfa555
commit
a2591c0163
@ -185,13 +185,9 @@ class IRCClient:
|
|||||||
for line in msg.split('\n'):
|
for line in msg.split('\n'):
|
||||||
self.send("NOTICE", user, ":{0}".format(line))
|
self.send("NOTICE", user, ":{0}".format(line))
|
||||||
def quit(self, msg):
|
def quit(self, msg):
|
||||||
self.send("QUIT :" + msg)
|
self.send("QUIT :{0}".format(msg))
|
||||||
def identify(self, passwd, authuser="NickServ"):
|
def identify(self, passwd, authuser="NickServ"):
|
||||||
self.msg(authuser, "IDENTIFY {0}".format(passwd))
|
self.msg(authuser, "IDENTIFY {0}".format(passwd))
|
||||||
def user(self, uname, rname):
|
def user(self, uname, rname):
|
||||||
self.send("USER", uname, self.host, self.host,
|
self.send("USER", uname, self.host, self.host,
|
||||||
rname or uname)
|
rname or uname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ def parse_raw_irc_command(element):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn('unknown numeric event %s' % command)
|
logging.warn('unknown numeric event %s' % command)
|
||||||
command = command.lower()
|
command = command.lower()
|
||||||
|
if isinstance(command, bytes): command = command.decode("ascii")
|
||||||
|
|
||||||
if args[0].startswith(bytes(':', 'ascii')):
|
if args[0].startswith(bytes(':', 'ascii')):
|
||||||
args = [bytes(" ", "ascii").join(args)[1:]]
|
args = [bytes(" ", "ascii").join(args)[1:]]
|
||||||
|
@ -27,7 +27,7 @@ class WolfBotHandler(DefaultCommandHandler):
|
|||||||
largs = list(args)
|
largs = list(args)
|
||||||
for i,arg in enumerate(largs):
|
for i,arg in enumerate(largs):
|
||||||
if arg: largs[i] = arg.decode('ascii')
|
if arg: largs[i] = arg.decode('ascii')
|
||||||
wolfgame.HOOKS[cmd](*largs)
|
wolfgame.HOOKS[cmd](self.client, *largs)
|
||||||
else:
|
else:
|
||||||
logging.debug('unhandled command %s(%s)' % (cmd, args))
|
logging.debug('unhandled command %s(%s)' % (cmd, args))
|
||||||
|
|
||||||
|
12
wolfgame.py
12
wolfgame.py
@ -55,7 +55,7 @@ def pinger(cli, nick, chan, rest):
|
|||||||
TO_PING = []
|
TO_PING = []
|
||||||
|
|
||||||
@hook("whoreply")
|
@hook("whoreply")
|
||||||
def on_whoreply(server, dunno, chan, dunno1,
|
def on_whoreply(cli, server, dunno, chan, dunno1,
|
||||||
dunno2, dunno3, user, status, dunno4):
|
dunno2, dunno3, user, status, dunno4):
|
||||||
if not vars.PINGING: return
|
if not vars.PINGING: return
|
||||||
if user in (botconfig.NICK, nick): return # Don't ping self.
|
if user in (botconfig.NICK, nick): return # Don't ping self.
|
||||||
@ -139,6 +139,7 @@ def leave(cli, what, nick):
|
|||||||
if nick not in vars.list_players(): # not playing
|
if nick not in vars.list_players(): # not playing
|
||||||
return
|
return
|
||||||
msg = ""
|
msg = ""
|
||||||
|
died_in_game = False
|
||||||
if what in ("!quit", "!leave"):
|
if what in ("!quit", "!leave"):
|
||||||
msg = ("\u0002{0}\u0002 died of an unknown disease. "+
|
msg = ("\u0002{0}\u0002 died of an unknown disease. "+
|
||||||
"S/He was a \u0002{1}\u0002.")
|
"S/He was a \u0002{1}\u0002.")
|
||||||
@ -156,10 +157,11 @@ def leave(cli, what, nick):
|
|||||||
cli.msg(botconfig.CHANNEL, msg)
|
cli.msg(botconfig.CHANNEL, msg)
|
||||||
del_player(cli, nick, died_in_game)
|
del_player(cli, nick, died_in_game)
|
||||||
|
|
||||||
cmd("!leave")(lambda cli, nick, chan, *rest: leave(cli, "!leave", nick))
|
cmd("!leave")(lambda cli, nick, *rest: leave(cli, "!leave", nick))
|
||||||
cmd("!quit")(lambda cli, nick, chan, *rest: leave(cli, "!quit", nick))
|
cmd("!quit")(lambda cli, nick, *rest: leave(cli, "!quit", nick))
|
||||||
hook("part")(lambda cli, nick, chan, *rest: leave(cli, "part", nick))
|
hook("part")(lambda cli, nick, *rest: leave(cli, "part", nick))
|
||||||
hook("quit")(lambda cli, nick, chan, *rest: leave(cli, "quit", nick))
|
hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", nick))
|
||||||
|
hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", nick))
|
||||||
|
|
||||||
def transition_day(cli):
|
def transition_day(cli):
|
||||||
chan = botconfig.CHANNEL
|
chan = botconfig.CHANNEL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user