From 077541511577dc5c868bd403eb8113a5a718c9f4 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Tue, 5 Jul 2011 03:39:43 -0500 Subject: [PATCH] fixed a few bugs --- oyoyo/client.py | 6 +----- oyoyo/parse.py | 1 + wolfbot.py | 2 +- wolfgame.py | 12 +++++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/oyoyo/client.py b/oyoyo/client.py index fef9a82..caec499 100644 --- a/oyoyo/client.py +++ b/oyoyo/client.py @@ -185,13 +185,9 @@ class IRCClient: for line in msg.split('\n'): self.send("NOTICE", user, ":{0}".format(line)) def quit(self, msg): - self.send("QUIT :" + msg) + self.send("QUIT :{0}".format(msg)) def identify(self, passwd, authuser="NickServ"): self.msg(authuser, "IDENTIFY {0}".format(passwd)) def user(self, uname, rname): self.send("USER", uname, self.host, self.host, rname or uname) - - - - diff --git a/oyoyo/parse.py b/oyoyo/parse.py index 6b0dea5..05f27d5 100644 --- a/oyoyo/parse.py +++ b/oyoyo/parse.py @@ -56,6 +56,7 @@ def parse_raw_irc_command(element): except KeyError: logging.warn('unknown numeric event %s' % command) command = command.lower() + if isinstance(command, bytes): command = command.decode("ascii") if args[0].startswith(bytes(':', 'ascii')): args = [bytes(" ", "ascii").join(args)[1:]] diff --git a/wolfbot.py b/wolfbot.py index 1db17d5..6df81f4 100644 --- a/wolfbot.py +++ b/wolfbot.py @@ -27,7 +27,7 @@ class WolfBotHandler(DefaultCommandHandler): largs = list(args) for i,arg in enumerate(largs): if arg: largs[i] = arg.decode('ascii') - wolfgame.HOOKS[cmd](*largs) + wolfgame.HOOKS[cmd](self.client, *largs) else: logging.debug('unhandled command %s(%s)' % (cmd, args)) diff --git a/wolfgame.py b/wolfgame.py index 75b872a..b8d9267 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -55,7 +55,7 @@ def pinger(cli, nick, chan, rest): TO_PING = [] @hook("whoreply") - def on_whoreply(server, dunno, chan, dunno1, + def on_whoreply(cli, server, dunno, chan, dunno1, dunno2, dunno3, user, status, dunno4): if not vars.PINGING: return 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 return msg = "" + died_in_game = False if what in ("!quit", "!leave"): msg = ("\u0002{0}\u0002 died of an unknown disease. "+ "S/He was a \u0002{1}\u0002.") @@ -156,10 +157,11 @@ def leave(cli, what, nick): cli.msg(botconfig.CHANNEL, msg) del_player(cli, nick, died_in_game) -cmd("!leave")(lambda cli, nick, chan, *rest: leave(cli, "!leave", nick)) -cmd("!quit")(lambda cli, nick, chan, *rest: leave(cli, "!quit", nick)) -hook("part")(lambda cli, nick, chan, *rest: leave(cli, "part", nick)) -hook("quit")(lambda cli, nick, chan, *rest: leave(cli, "quit", nick)) +cmd("!leave")(lambda cli, nick, *rest: leave(cli, "!leave", nick)) +cmd("!quit")(lambda cli, nick, *rest: leave(cli, "!quit", nick)) +hook("part")(lambda cli, nick, *rest: leave(cli, "part", 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): chan = botconfig.CHANNEL