Browse Source

fixed a few bugs

master
jcao219 14 years ago
parent
commit
0775415115
  1. 6
      oyoyo/client.py
  2. 1
      oyoyo/parse.py
  3. 2
      wolfbot.py
  4. 12
      wolfgame.py

6
oyoyo/client.py

@ -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)

1
oyoyo/parse.py

@ -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:]]

2
wolfbot.py

@ -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

@ -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…
Cancel
Save