Add a decorator on user match
This commit is contained in:
parent
8178a602fd
commit
8f1553883f
|
@ -10,4 +10,9 @@ def fun(bot, msg, *args):
|
|||
|
||||
@api.command("limite")
|
||||
def history_limit(bot, msg, *args):
|
||||
bot.send(msg.to, f"limite historique : {bot.history._History__limit}")
|
||||
bot.send(msg.to, f"limite historique : {bot.history._History__limit}")
|
||||
|
||||
|
||||
@api.user("Shadow15510")
|
||||
def agree(bot, msg, *args):
|
||||
bot.send(msg.to, "Ouaip ! Complètement d'accord avec toi !")
|
|
@ -43,7 +43,22 @@ def channel(channel_name, desc=""):
|
|||
desc=desc,
|
||||
cmnd_type=0
|
||||
)
|
||||
return decorator
|
||||
|
||||
|
||||
def user(user_name, desc=""):
|
||||
def decorator(func_or_cmnd):
|
||||
if isinstance(func_or_cmnd, Command):
|
||||
func_or_cmnd.events.append(lambda m: m.author == user_name)
|
||||
return func_or_cmnd
|
||||
else:
|
||||
return Command(
|
||||
name=func_or_cmnd.__name__,
|
||||
func=func_or_cmnd,
|
||||
events=[lambda m: m.author == user_name],
|
||||
desc=desc,
|
||||
cmnd_type=0
|
||||
)
|
||||
return decorator
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue