We don't need to explicitly pass "buffer" through on command events

This commit is contained in:
jesopo 2018-09-30 11:43:34 +01:00
parent 7ab8948101
commit 30641ce312
8 changed files with 10 additions and 12 deletions

View file

@ -90,8 +90,6 @@ class Module(ModuleManager.BaseModule):
if is_channel and hook.kwargs.get("private_only"):
return
buffer = target.buffer
module_name = ""
if hasattr(hook.function, "__self__"):
module_name = hook.function.__self__._name
@ -121,7 +119,7 @@ class Module(ModuleManager.BaseModule):
user = event["user"]
self.events.on("received.command").on(command
).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,
command=command.lower(), is_channel=is_channel,
tags=event["tags"])
@ -130,7 +128,7 @@ class Module(ModuleManager.BaseModule):
stderr.send()
target.last_stdout = stdout
target.last_stderr = stderr
buffer.skip_next()
target.buffer.skip_next()
event.eat()
@Utils.hook("received.message.channel", priority=EventManager.PRIORITY_LOW)

View file

@ -27,7 +27,7 @@ class Module(ModuleManager.BaseModule):
if event["args"]:
word = event["args"]
else:
word = event["buffer"].get(from_self=False)
word = event["target"].buffer.get(from_self=False)
page = self._get_definition(word)
if page:

View file

@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
"""
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:
page = Utils.get_url(URL_GOOGLESEARCH, get_params={
"q": phrase, "key": self.bot.config[
@ -36,7 +36,7 @@ class Module(ModuleManager.BaseModule):
"""
Get suggested phrases from Google
"""
phrase = event["args"] or event["buffer"].get()
phrase = event["args"] or event["target"].buffer.get()
if phrase:
page = Utils.get_url(URL_GOOGLESUGGEST, get_params={
"output": "json", "client": "hp", "q": phrase})

View file

@ -25,7 +25,7 @@ class Module(ModuleManager.BaseModule):
else:
query = event["args"]
else:
last_soundcloud = event["buffer"].find(REGEX_SOUNDCLOUD)
last_soundcloud = event["target"].buffer.find(REGEX_SOUNDCLOUD)
if last_soundcloud:
url = re.match(REGEX_SOUNDCLOUD,
last_soundcloud.message).string

View file

@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
if len(event["args"]) > 0:
url = event["args_split"][0]
else:
url = event["buffer"].find(REGEX_URL)
url = event["target"].buffer.find(REGEX_URL)
if url:
url = re.search(REGEX_URL, url.message).group(0)
if not url:

View file

@ -13,7 +13,7 @@ class Module(ModuleManager.BaseModule):
"""
phrase = event["args"]
if not phrase:
phrase = event["buffer"].get()
phrase = event["target"].buffer.get()
if phrase:
phrase = phrase.message
if not phrase:

View file

@ -32,7 +32,7 @@ class Module(ModuleManager.BaseModule):
if event["args"]:
target = event["args"]
else:
target = event["buffer"].find(REGEX_TWITTERURL)
target = event["target"].buffer.find(REGEX_TWITTERURL)
if target:
target = target.message
if target:

View file

@ -81,7 +81,7 @@ class Module(ModuleManager.BaseModule):
if event["args"]:
search = event["args"]
else:
last_youtube = event["buffer"].find(REGEX_YOUTUBE)
last_youtube = event["target"].buffer.find(REGEX_YOUTUBE)
if last_youtube:
video_id = re.search(REGEX_YOUTUBE, last_youtube.message).group(1)
if search or video_id: