aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/channel_op.py14
-rw-r--r--modules/commands.py13
-rw-r--r--modules/google.py3
-rw-r--r--modules/lastfm.py4
-rw-r--r--modules/quotes.py12
-rw-r--r--modules/random_number.py3
-rw-r--r--modules/soundcloud.py3
-rw-r--r--modules/title.py3
-rw-r--r--modules/trakt.py3
-rw-r--r--modules/translate.py3
-rw-r--r--modules/tweets.py3
-rw-r--r--modules/urbandictionary.py3
-rw-r--r--modules/wikipedia.py3
-rw-r--r--modules/wolframalpha.py3
-rw-r--r--modules/youtube.py3
15 files changed, 55 insertions, 21 deletions
diff --git a/modules/channel_op.py b/modules/channel_op.py
index b9d8a715..a7070ba1 100644
--- a/modules/channel_op.py
+++ b/modules/channel_op.py
@@ -33,7 +33,8 @@ class Module(ModuleManager.BaseModule):
else:
raise UserNotFoundException("That user is not in this channel")
- @utils.hook("received.command.kick|k", channel_only=True, min_args=1)
+ @utils.hook("received.command.k", alias_of="kick")
+ @utils.hook("received.command.kick", channel_only=True, min_args=1)
def kick(self, event):
"""
:help: Kick a user from the current channel
@@ -103,7 +104,9 @@ class Module(ModuleManager.BaseModule):
self.bot.timers.add_persistent("unban", timeout,
server_id=event["server"].id,
channel_name=event["target"].name, hostmask=hostmask)
- @utils.hook("received.command.tempban|tb", channel_only=True, min_args=2)
+
+ @utils.hook("received.command.tb", alias_of="tempban")
+ @utils.hook("received.command.tempban", channel_only=True, min_args=2)
def temp_ban(self, event):
"""
:help: Temporarily ban someone from the current channel
@@ -115,7 +118,9 @@ class Module(ModuleManager.BaseModule):
self._temp_ban(event, True)
except InvalidTimeoutException as e:
event["stderr"].write(str(e))
- @utils.hook("received.command.tempkickban|tkb", channel_only=True,
+
+ @utils.hook("received.command.tkb", alias_of="tempkickban")
+ @utils.hook("received.command.tempkickban", channel_only=True,
min_args=2)
def temp_kick_ban(self, event):
"""
@@ -144,7 +149,8 @@ class Module(ModuleManager.BaseModule):
self._ban(event["server"], event["target"], False,
event["args_split"][0])
- @utils.hook("received.command.kickban|kb", channel_only=True, min_args=1)
+ @utils.hook("received.command.kb", alias_of="kickban")
+ @utils.hook("received.command.kickban", channel_only=True, min_args=1)
def kickban(self, event):
"""
:help: Kick and ban a user from the current channel
diff --git a/modules/commands.py b/modules/commands.py
index 8eb0b96b..0f22c2d8 100644
--- a/modules/commands.py
+++ b/modules/commands.py
@@ -112,6 +112,13 @@ class Module(ModuleManager.BaseModule):
return
hook = self.get_hook(command)
+ alias_of = self._get_alias_of(hook)
+ if alias_of:
+ if self.has_command(alias_of):
+ hook = self.get_hook(alias_of)
+ else:
+ raise ValueError("'%s' is an alias of unknown command '%s'"
+ % (command.lower(), alias_of.lower()))
is_channel = False
if "channel" in event:
@@ -197,6 +204,8 @@ class Module(ModuleManager.BaseModule):
return hook.get_kwarg("usage", None)
def _get_prefix(self, hook):
return hook.get_kwarg("prefix", None)
+ def _get_alias_of(self, hook):
+ return hook.get_kwarg("alias_of", None)
@utils.hook("received.command.help")
def help(self, event):
@@ -222,8 +231,10 @@ class Module(ModuleManager.BaseModule):
for child in self.events.on("received.command").get_children():
hooks = self.events.on("received.command").on(child).get_hooks()
- if hooks and self._get_help(hooks[0]):
+ if hooks and self._get_help(hooks[0]
+ ) and not self._get_alias_of(hooks[0]):
help_available.append(child)
+
help_available = sorted(help_available)
event["stdout"].write("Commands: %s" % ", ".join(help_available))
diff --git a/modules/google.py b/modules/google.py
index ebbc7461..076ba752 100644
--- a/modules/google.py
+++ b/modules/google.py
@@ -8,7 +8,8 @@ URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1"
URL_GOOGLESUGGEST = "http://google.com/complete/search"
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.google|g")
+ @utils.hook("received.command.g", alias_of="google")
+ @utils.hook("received.command.google")
def google(self, event):
"""
:help: Get first Google result for a given search term
diff --git a/modules/lastfm.py b/modules/lastfm.py
index 31cf1cfd..e67c6af1 100644
--- a/modules/lastfm.py
+++ b/modules/lastfm.py
@@ -9,7 +9,9 @@ URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
class Module(ModuleManager.BaseModule):
_name = "last.fm"
- @utils.hook("received.command.np|listening|nowplaying")
+ @utils.hook("received.command.np", alias_of="nowplaying")
+ @utils.hook("received.command.listening", alias_of="nowplaying")
+ @utils.hook("received.command.nowplaying")
def np(self, event):
"""
:help: Get the last listened to track from a user
diff --git a/modules/quotes.py b/modules/quotes.py
index 8ee1f561..ab3e4d18 100644
--- a/modules/quotes.py
+++ b/modules/quotes.py
@@ -7,7 +7,8 @@ class Module(ModuleManager.BaseModule):
return [part.strip() for part in s.split("=", 1)]
return None, None
- @utils.hook("received.command.quoteadd|qadd", min_args=1)
+ @utils.hook("received.command.qadd", alias_of="quoteadd")
+ @utils.hook("received.command.quoteadd", min_args=1)
def quote_add(self, event):
"""
:help: Add a quote to a category
@@ -23,7 +24,8 @@ class Module(ModuleManager.BaseModule):
else:
event["stderr"].write("Please provide a category AND quote")
- @utils.hook("received.command.quoteget|qget", min_args=1)
+ @utils.hook("received.command.qget", alias_of="quoteget")
+ @utils.hook("received.command.quoteget", min_args=1)
def quote_get(self, event):
"""
:help: Get a quote from a ccategory
@@ -46,7 +48,8 @@ class Module(ModuleManager.BaseModule):
event["stderr"].write("Please provide a category and a "
"part of a quote to find")
- @utils.hook("received.command.quotedel|qdel", min_args=1)
+ @utils.hook("received.command.qdel", alias_of="quotedel")
+ @utils.hook("received.command.quotedel", min_args=1)
def quote_del(self, event):
"""
:help: Delete a quote from a category
@@ -71,7 +74,8 @@ class Module(ModuleManager.BaseModule):
event["stderr"].write("Please provide a category and a quote "
"to remove")
- @utils.hook("received.command.quote|q", min_args=1)
+ @utils.hook("received.command.q", alias_of="quote")
+ @utils.hook("received.command.quote", min_args=1)
def quote(self, event):
"""
:help: Get a random quote from a category
diff --git a/modules/random_number.py b/modules/random_number.py
index eb0662ed..797b2fb4 100644
--- a/modules/random_number.py
+++ b/modules/random_number.py
@@ -4,7 +4,8 @@ from src import ModuleManager, utils
class Module(ModuleManager.BaseModule):
_name = "Random"
- @utils.hook("received.command.random|rand")
+ @utils.hook("received.command.rand", alias_of="random")
+ @utils.hook("received.command.random")
def random(self, event):
"""
:help: Get a random number
diff --git a/modules/soundcloud.py b/modules/soundcloud.py
index 3737d223..fd7300c3 100644
--- a/modules/soundcloud.py
+++ b/modules/soundcloud.py
@@ -10,7 +10,8 @@ REGEX_SOUNDCLOUD = "https?://soundcloud.com/([^/]+)/([^/]+)"
class Module(ModuleManager.BaseModule):
_name = "SoundCloud"
- @utils.hook("received.command.soundcloud|sc")
+ @utils.hook("received.command.sc", alias_of="soundcloud")
+ @utils.hook("received.command.soundcloud")
def soundcloud(self, event):
"""
:help: Search SoundCloud
diff --git a/modules/title.py b/modules/title.py
index 34b539d1..098d28e3 100644
--- a/modules/title.py
+++ b/modules/title.py
@@ -4,7 +4,8 @@ from src import ModuleManager, utils
REGEX_URL = re.compile("https?://\S+", re.I)
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.title|t", usage="[URL]")
+ @utils.hook("received.command.t", alias_of="title")
+ @utils.hook("received.command.title", usage="[URL]")
def title(self, event):
"""
:help: Get the title of a URL
diff --git a/modules/trakt.py b/modules/trakt.py
index 4d125c54..8adc3cc4 100644
--- a/modules/trakt.py
+++ b/modules/trakt.py
@@ -7,7 +7,8 @@ URL_TRAKTSLUG = "https://trakt.tv/%s/%s"
@utils.export("set", {"setting": "trakt", "help": "Set username on trakt.tv"})
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.nowwatching|nw")
+ @utils.hook("received.command.nw", alias_of="nowwatching")
+ @utils.hook("received.command.nowwatching")
def now_watching(self, event):
"""
:help: Get what you or another user is now watching on trakt.tv
diff --git a/modules/translate.py b/modules/translate.py
index 8570ae76..3a8e5b91 100644
--- a/modules/translate.py
+++ b/modules/translate.py
@@ -6,7 +6,8 @@ URL_LANGUAGES = "https://cloud.google.com/translate/docs/languages"
REGEX_LANGUAGES = re.compile("(\w+)?:(\w+)? ")
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.translate|tr")
+ @utils.hook("received.command.tr", alias_of="translate")
+ @utils.hook("received.command.translate")
def translate(self, event):
"""
:help: Translate the provided phrase or the last line in thie current
diff --git a/modules/tweets.py b/modules/tweets.py
index 539506b9..b057dade 100644
--- a/modules/tweets.py
+++ b/modules/tweets.py
@@ -19,7 +19,8 @@ class Module(ModuleManager.BaseModule):
since, unit = utils.time_unit(seconds_since)
return "%s %s ago" % (since, unit)
- @utils.hook("received.command.tweet|tw")
+ @utils.hook("received.command.tw", alias_of="tweet")
+ @utils.hook("received.command.tweet")
def tweet(self, event):
"""
:help: Get/find a tweet
diff --git a/modules/urbandictionary.py b/modules/urbandictionary.py
index 2f86ff6b..314b492f 100644
--- a/modules/urbandictionary.py
+++ b/modules/urbandictionary.py
@@ -5,7 +5,8 @@ URL_URBANDICTIONARY = "http://api.urbandictionary.com/v0/define"
REGEX_DEFNUMBER = re.compile("-n(\d+) \S+")
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.urbandictionary|ud", min_args=1)
+ @utils.hook("received.command.ud", alias_of="urbandictionary")
+ @utils.hook("received.command.urbandictionary", min_args=1)
def ud(self, event):
"""
:help: Get the definition of a provided term from Urban Dictionary
diff --git a/modules/wikipedia.py b/modules/wikipedia.py
index e8a7486c..08b3210e 100644
--- a/modules/wikipedia.py
+++ b/modules/wikipedia.py
@@ -3,7 +3,8 @@ from src import ModuleManager, utils
URL_WIKIPEDIA = "https://en.wikipedia.org/w/api.php"
class Module(ModuleManager.BaseModule):
- @utils.hook("received.command.wiki|wi", min_args=1)
+ @utils.hook("received.command.wi", alias_of="wiki")
+ @utils.hook("received.command.wiki", min_args=1)
def wikipedia(self, event):
"""
:help: Get information from wikipedia
diff --git a/modules/wolframalpha.py b/modules/wolframalpha.py
index 153b51e8..7e25098a 100644
--- a/modules/wolframalpha.py
+++ b/modules/wolframalpha.py
@@ -7,7 +7,8 @@ URL_WA = "https://api.wolframalpha.com/v1/result"
class Module(ModuleManager.BaseModule):
_name = "Wolfram|Alpha"
- @utils.hook("received.command.wolframalpha|wa", min_args=1)
+ @utils.hook("received.command.wa", alias_of="wolframalpha")
+ @utils.hook("received.command.wolframalpha", min_args=1)
def wa(self, event):
"""
:help: Evauate a given string on Wolfram|Alpha
diff --git a/modules/youtube.py b/modules/youtube.py
index 0e976aec..4beb3bb7 100644
--- a/modules/youtube.py
+++ b/modules/youtube.py
@@ -71,7 +71,8 @@ class Module(ModuleManager.BaseModule):
video_id = search_page["items"][0]["id"]["videoId"]
return "https://youtu.be/%s" % video_id
- @utils.hook("received.command.yt|youtube")
+ @utils.hook("received.command.yt", alias_of="youtube")
+ @utils.hook("received.command.youtube")
def yt(self, event):
"""
:help: Find a video on youtube