Browse Source

now !help does not display aliases

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

21
oyoyo/client.py

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

27
wolfgame.py

@ -396,17 +396,17 @@ def fstart(cli, nick, chan, rest): @@ -396,17 +396,17 @@ def fstart(cli, nick, chan, rest):
start(cli, nick, nick, rest)
@cmd("kpon")
def kpon(cli, nick, chan, rest):
"""(Same as !join)"""
join(cli, nick, chan, rest)
if "person" in var.ROLES.keys() and nick in var.ROLES["person"]:
var.ROLES["person"].remove(nick)
if "typo" in var.ROLES.keys():
var.ROLES["typo"].append(nick)
else:
var.ROLES["typo"] = [nick]
# lol this was funny
# @cmd("kpon")
# def kpon(cli, nick, chan, rest):
# """(Same as !join)"""
# join(cli, nick, chan, rest)
# if "person" in var.ROLES.keys() and nick in var.ROLES["person"]:
# var.ROLES["person"].remove(nick)
# if "typo" in var.ROLES.keys():
# var.ROLES["typo"].append(nick)
# else:
# var.ROLES["typo"] = [nick]
@ -1942,12 +1942,13 @@ def get_help(cli, rnick, rest): @@ -1942,12 +1942,13 @@ def get_help(cli, rnick, rest):
return
# if command was not found, or if no command was given:
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")
afns = []
if cloak in botconfig.ADMINS or cloak in botconfig.OWNERS:
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")
cli.notice(nick, "Commands: "+", ".join(fns))
if afns:

Loading…
Cancel
Save