move !alias variables in to alias_variables.py, add RNICK (random nick)
This commit is contained in:
parent
11e2475d52
commit
fc83d4fe50
3 changed files with 15 additions and 2 deletions
12
modules/alias_variables.py
Normal file
12
modules/alias_variables.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import random
|
||||
from src import EventManager, ModuleManager, utils
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@utils.hook("get.command")
|
||||
@utils.kwarg("priority", EventManager.PRIORITY_HIGH)
|
||||
def get_command(self, event):
|
||||
event["kwargs"]["NICK"] = event["user"].nickname
|
||||
if event["is_channel"]:
|
||||
event["kwargs"]["CHAN"] = event["target"].name
|
||||
random_user = random.choice(list(event["target"].users))
|
||||
event["kwargs"]["RNICK"] = random_user.nickname
|
|
@ -47,7 +47,7 @@ class Module(ModuleManager.BaseModule):
|
|||
|
||||
event["command"].command = alias
|
||||
event["command"].args = self._arg_replace(alias_args, given_args,
|
||||
{"NICK": event["user"].nickname})
|
||||
event["kwargs"])
|
||||
|
||||
@utils.hook("received.command.alias",
|
||||
permission="alias")
|
||||
|
|
|
@ -78,7 +78,8 @@ class Module(ModuleManager.BaseModule):
|
|||
if not self.has_command(command):
|
||||
command_event = CommandEvent(command, args)
|
||||
self.events.on("get.command").call(command=command_event,
|
||||
server=server, target=target, is_channel=is_channel, user=user)
|
||||
server=server, target=target, is_channel=is_channel, user=user,
|
||||
kwargs={})
|
||||
|
||||
command = command_event.command
|
||||
args = command_event.args
|
||||
|
|
Loading…
Reference in a new issue