We don't need to explicitly pass "buffer" through on command events
This commit is contained in:
parent
7ab8948101
commit
30641ce312
8 changed files with 10 additions and 12 deletions
|
@ -90,8 +90,6 @@ class Module(ModuleManager.BaseModule):
|
||||||
if is_channel and hook.kwargs.get("private_only"):
|
if is_channel and hook.kwargs.get("private_only"):
|
||||||
return
|
return
|
||||||
|
|
||||||
buffer = target.buffer
|
|
||||||
|
|
||||||
module_name = ""
|
module_name = ""
|
||||||
if hasattr(hook.function, "__self__"):
|
if hasattr(hook.function, "__self__"):
|
||||||
module_name = hook.function.__self__._name
|
module_name = hook.function.__self__._name
|
||||||
|
@ -121,7 +119,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
user = event["user"]
|
user = event["user"]
|
||||||
self.events.on("received.command").on(command
|
self.events.on("received.command").on(command
|
||||||
).call_limited(1, user=user, server=server,
|
).call_limited(1, user=user, server=server,
|
||||||
target=target, buffer=buffer, args=args,
|
target=target, args=args,
|
||||||
args_split=args_split, stdout=stdout, stderr=stderr,
|
args_split=args_split, stdout=stdout, stderr=stderr,
|
||||||
command=command.lower(), is_channel=is_channel,
|
command=command.lower(), is_channel=is_channel,
|
||||||
tags=event["tags"])
|
tags=event["tags"])
|
||||||
|
@ -130,7 +128,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
stderr.send()
|
stderr.send()
|
||||||
target.last_stdout = stdout
|
target.last_stdout = stdout
|
||||||
target.last_stderr = stderr
|
target.last_stderr = stderr
|
||||||
buffer.skip_next()
|
target.buffer.skip_next()
|
||||||
event.eat()
|
event.eat()
|
||||||
|
|
||||||
@Utils.hook("received.message.channel", priority=EventManager.PRIORITY_LOW)
|
@Utils.hook("received.message.channel", priority=EventManager.PRIORITY_LOW)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if event["args"]:
|
if event["args"]:
|
||||||
word = event["args"]
|
word = event["args"]
|
||||||
else:
|
else:
|
||||||
word = event["buffer"].get(from_self=False)
|
word = event["target"].buffer.get(from_self=False)
|
||||||
|
|
||||||
page = self._get_definition(word)
|
page = self._get_definition(word)
|
||||||
if page:
|
if page:
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
"""
|
"""
|
||||||
Get first Google result for a given search term
|
Get first Google result for a given search term
|
||||||
"""
|
"""
|
||||||
phrase = event["args"] or event["buffer"].get()
|
phrase = event["args"] or event["target"].buffer.get()
|
||||||
if phrase:
|
if phrase:
|
||||||
page = Utils.get_url(URL_GOOGLESEARCH, get_params={
|
page = Utils.get_url(URL_GOOGLESEARCH, get_params={
|
||||||
"q": phrase, "key": self.bot.config[
|
"q": phrase, "key": self.bot.config[
|
||||||
|
@ -36,7 +36,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
"""
|
"""
|
||||||
Get suggested phrases from Google
|
Get suggested phrases from Google
|
||||||
"""
|
"""
|
||||||
phrase = event["args"] or event["buffer"].get()
|
phrase = event["args"] or event["target"].buffer.get()
|
||||||
if phrase:
|
if phrase:
|
||||||
page = Utils.get_url(URL_GOOGLESUGGEST, get_params={
|
page = Utils.get_url(URL_GOOGLESUGGEST, get_params={
|
||||||
"output": "json", "client": "hp", "q": phrase})
|
"output": "json", "client": "hp", "q": phrase})
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
else:
|
else:
|
||||||
query = event["args"]
|
query = event["args"]
|
||||||
else:
|
else:
|
||||||
last_soundcloud = event["buffer"].find(REGEX_SOUNDCLOUD)
|
last_soundcloud = event["target"].buffer.find(REGEX_SOUNDCLOUD)
|
||||||
if last_soundcloud:
|
if last_soundcloud:
|
||||||
url = re.match(REGEX_SOUNDCLOUD,
|
url = re.match(REGEX_SOUNDCLOUD,
|
||||||
last_soundcloud.message).string
|
last_soundcloud.message).string
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if len(event["args"]) > 0:
|
if len(event["args"]) > 0:
|
||||||
url = event["args_split"][0]
|
url = event["args_split"][0]
|
||||||
else:
|
else:
|
||||||
url = event["buffer"].find(REGEX_URL)
|
url = event["target"].buffer.find(REGEX_URL)
|
||||||
if url:
|
if url:
|
||||||
url = re.search(REGEX_URL, url.message).group(0)
|
url = re.search(REGEX_URL, url.message).group(0)
|
||||||
if not url:
|
if not url:
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
"""
|
"""
|
||||||
phrase = event["args"]
|
phrase = event["args"]
|
||||||
if not phrase:
|
if not phrase:
|
||||||
phrase = event["buffer"].get()
|
phrase = event["target"].buffer.get()
|
||||||
if phrase:
|
if phrase:
|
||||||
phrase = phrase.message
|
phrase = phrase.message
|
||||||
if not phrase:
|
if not phrase:
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if event["args"]:
|
if event["args"]:
|
||||||
target = event["args"]
|
target = event["args"]
|
||||||
else:
|
else:
|
||||||
target = event["buffer"].find(REGEX_TWITTERURL)
|
target = event["target"].buffer.find(REGEX_TWITTERURL)
|
||||||
if target:
|
if target:
|
||||||
target = target.message
|
target = target.message
|
||||||
if target:
|
if target:
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if event["args"]:
|
if event["args"]:
|
||||||
search = event["args"]
|
search = event["args"]
|
||||||
else:
|
else:
|
||||||
last_youtube = event["buffer"].find(REGEX_YOUTUBE)
|
last_youtube = event["target"].buffer.find(REGEX_YOUTUBE)
|
||||||
if last_youtube:
|
if last_youtube:
|
||||||
video_id = re.search(REGEX_YOUTUBE, last_youtube.message).group(1)
|
video_id = re.search(REGEX_YOUTUBE, last_youtube.message).group(1)
|
||||||
if search or video_id:
|
if search or video_id:
|
||||||
|
|
Loading…
Reference in a new issue