Browse Source

now !help does not display aliases

master
jcao219 13 years ago
parent
commit
eb768c0fc2
  1. 5
      decorators.py
  2. 21
      oyoyo/client.py
  3. 27
      wolfgame.py

5
decorators.py

@ -37,6 +37,8 @@ def generate(fdict, **kwargs):
largs[0].notice(largs[1], "You are not an admin.") largs[0].notice(largs[1], "You are not an admin.")
return return
return f(*largs) return f(*largs)
alias = False
innerf.aliases = []
for x in s: for x in s:
if x not in fdict.keys(): if x not in fdict.keys():
fdict[x] = [] fdict[x] = []
@ -46,6 +48,9 @@ def generate(fdict, **kwargs):
fn.admin_only != admin_only): fn.admin_only != admin_only):
raise Exception("Command: "+x+" has non-matching protection levels!") raise Exception("Command: "+x+" has non-matching protection levels!")
fdict[x].append(innerf) fdict[x].append(innerf)
if alias:
innerf.aliases.append(x)
alias = True
innerf.owner_only = owner_only innerf.owner_only = owner_only
innerf.raw_nick = raw_nick innerf.raw_nick = raw_nick
innerf.admin_only = admin_only innerf.admin_only = admin_only

21
oyoyo/client.py

@ -105,7 +105,9 @@ class IRCClient(object):
self.connect_cb = None self.connect_cb = None
self.blocking = True self.blocking = True
self.lock = threading.RLock() self.lock = threading.RLock()
self.tokenbucket = TokenBucket(3, 1.73) self.tokenbucket = TokenBucket(3, 1.73)
self.last_messaged = ""
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
self.command_handler = cmd_handler self.command_handler = cmd_handler
@ -200,7 +202,7 @@ class IRCClient(object):
fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)] fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
except UnicodeDecodeError: except UnicodeDecodeError:
enc = "latin1" enc = "latin1"
fargs = fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)] fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
logging.debug("processCommand ({2}){0}({1})".format(command, logging.debug("processCommand ({2}){0}({1})".format(command,
fargs, prefix)) fargs, prefix))
@ -208,12 +210,12 @@ class IRCClient(object):
largs = list(args) largs = list(args)
if prefix is not None: if prefix is not None:
prefix = prefix.decode(enc) prefix = prefix.decode(enc)
for i,arg in enumerate(largs): # for i,arg in enumerate(largs):
if arg is not None: largs[i] = arg.decode(enc) # if arg is not None: largs[i] = arg.decode(enc)
if command in self.command_handler: if command in self.command_handler:
self.command_handler[command](self, prefix,*largs) self.command_handler[command](self, prefix,*fargs)
elif "" in self.command_handler: elif "" in self.command_handler:
self.command_handler[""](self, prefix, command, *largs) self.command_handler[""](self, prefix, command, *fargs)
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
raise e # ? raise e # ?
@ -226,9 +228,14 @@ class IRCClient(object):
raise SystemExit # lets exit raise SystemExit # lets exit
def msg(self, user, msg): def msg(self, user, msg):
for line in msg.split('\n'): for line in msg.split('\n'):
while not self.tokenbucket.consume(1): if user == self.last_messaged:
pass while not self.tokenbucket.consume(1):
pass
else: # ?
while not self.tokenbucket.consume(0.37):
pass
self.send("PRIVMSG", user, ":{0}".format(line)) self.send("PRIVMSG", user, ":{0}".format(line))
self.last_messaged = user
privmsg = msg # Same thing privmsg = msg # Same thing
def notice(self, user, msg): def notice(self, user, msg):
for line in msg.split('\n'): for line in msg.split('\n'):

27
wolfgame.py

@ -396,17 +396,17 @@ def fstart(cli, nick, chan, rest):
start(cli, nick, nick, rest) start(cli, nick, nick, rest)
# lol this was funny
@cmd("kpon") # @cmd("kpon")
def kpon(cli, nick, chan, rest): # def kpon(cli, nick, chan, rest):
"""(Same as !join)""" # """(Same as !join)"""
join(cli, nick, chan, rest) # join(cli, nick, chan, rest)
if "person" in var.ROLES.keys() and nick in var.ROLES["person"]: # if "person" in var.ROLES.keys() and nick in var.ROLES["person"]:
var.ROLES["person"].remove(nick) # var.ROLES["person"].remove(nick)
if "typo" in var.ROLES.keys(): # if "typo" in var.ROLES.keys():
var.ROLES["typo"].append(nick) # var.ROLES["typo"].append(nick)
else: # else:
var.ROLES["typo"] = [nick] # var.ROLES["typo"] = [nick]
@ -1942,12 +1942,13 @@ def get_help(cli, rnick, rest):
return return
# if command was not found, or if no command was given: # if command was not found, or if no command was given:
for name, fn in COMMANDS.items(): for name, fn in COMMANDS.items():
if name and not fn[0].admin_only and not fn[0].owner_only: if (name and not fn[0].admin_only and
not fn[0].owner_only and name not in fn[0].aliases):
fns.append("\u0002"+name+"\u0002") fns.append("\u0002"+name+"\u0002")
afns = [] afns = []
if cloak in botconfig.ADMINS or cloak in botconfig.OWNERS: if cloak in botconfig.ADMINS or cloak in botconfig.OWNERS:
for name, fn in COMMANDS.items(): for name, fn in COMMANDS.items():
if fn[0].admin_only: if fn[0].admin_only and name not in fn[0].aliases:
afns.append("\u0002"+name+"\u0002") afns.append("\u0002"+name+"\u0002")
cli.notice(nick, "Commands: "+", ".join(fns)) cli.notice(nick, "Commands: "+", ".join(fns))
if afns: if afns:

Loading…
Cancel
Save