From 10ef985a8a849a6bbfa8cbb63c2548e42ffb3957 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 30 Sep 2018 17:29:09 +0100 Subject: [PATCH] Switch to using docstring for usage, permission and require_mode --- modules/8ball.py | 5 ++- modules/admin.py | 25 ++++++----- modules/auto_mode.py | 28 ++++++------ modules/bitcoin.py | 5 ++- modules/books.py | 10 +++-- modules/channel_op.py | 87 +++++++++++++++++++++++--------------- modules/check_mode.py | 6 +-- modules/coins.py | 38 +++++++++-------- modules/commands.py | 41 +++++++++--------- modules/define.py | 7 +-- modules/dice.py | 5 ++- modules/dns.py | 5 ++- modules/ducks.py | 12 +++--- modules/eval.py | 5 ++- modules/geoip.py | 5 ++- modules/google.py | 5 ++- modules/hash.py | 5 ++- modules/haveibeenpwned.py | 8 ++-- modules/ids.py | 4 +- modules/imdb.py | 5 ++- modules/in.py | 5 ++- modules/isgd.py | 5 ++- modules/karma.py | 12 +++--- modules/lastfm.py | 5 ++- modules/modules.py | 40 ++++++++++-------- modules/nr.py | 22 ++++++---- modules/permissions.py | 38 +++++++++-------- modules/pong.py | 5 ++- modules/quotes.py | 23 +++++----- modules/random_number.py | 7 +-- modules/seen.py | 5 ++- modules/set.py | 38 ++++++++++------- modules/soundcloud.py | 3 +- modules/spotify.py | 3 +- modules/stats.py | 4 +- modules/strax.py | 4 +- modules/tfl.py | 31 ++++++++------ modules/thesaurus.py | 6 +-- modules/title.py | 3 +- modules/to.py | 7 +-- modules/todo.py | 15 ++++--- modules/trakt.py | 5 ++- modules/translate.py | 6 ++- modules/tweets.py | 5 ++- modules/upc.py | 5 ++- modules/urbandictionary.py | 6 +-- modules/weather.py | 3 +- modules/wikipedia.py | 3 +- modules/wolframalpha.py | 5 ++- modules/words.py | 17 +++++--- modules/youtube.py | 5 ++- src/EventManager.py | 7 +++ src/Utils.py | 32 ++++++++++++++ 53 files changed, 415 insertions(+), 276 deletions(-) diff --git a/modules/8ball.py b/modules/8ball.py index ebfb1b0c..60cdb261 100644 --- a/modules/8ball.py +++ b/modules/8ball.py @@ -29,10 +29,11 @@ CHOICES = [ ] class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.8ball", min_args=1, usage="") + @Utils.hook("received.command.8ball", min_args=1) def decide(selfs, event): """ - Ask the mystic 8ball a question! + :help: Ask the mystic 8ball a question! + :usage: """ event["stdout"].write("You shake the magic ball... it " "says " + Utils.bold(random.choice(CHOICES))) diff --git a/modules/admin.py b/modules/admin.py index 1742758e..ac82dbcb 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -1,27 +1,31 @@ from src import ModuleManager, Utils class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.changenickname", - permission="changenickname", min_args=1, usage="") + @Utils.hook("received.command.changenickname", min_args=1) def change_nickname(self, event): """ - Change my nickname + :help: Change my nickname + :usage: + :permission: changenickname """ nickname = event["args_split"][0] event["server"].send_nick(nickname) - @Utils.hook("received.command.raw", permission="raw", min_args=1, - usage="") + @Utils.hook("received.command.raw", min_args=1) def raw(self, event): """ - Send a line of raw IRC data + :help: Send a line of raw IRC data + :usage: + :permission: raw """ event["server"].send(event["args"]) - @Utils.hook("received.command.part", permission="part", usage="[#channel]") + @Utils.hook("received.command.part") def part(self, event): """ - Part from the current or given channel + :help: Part from the current or given channel + :usage: [channel] + :permission: part """ if event["args"]: target = event["args_split"][0] @@ -31,9 +35,10 @@ class Module(ModuleManager.BaseModule): event["stderr"].write("No channel provided") event["server"].send_part(target) - @Utils.hook("received.command.reconnect", permission="reconnect") + @Utils.hook("received.command.reconnect") def reconnect(self, event): """ - Reconnect to the current network + :help: Reconnect to the current network + :permission: reconnect """ event["server"].send_quit("Reconnecting") diff --git a/modules/auto_mode.py b/modules/auto_mode.py index d1851a58..ae233396 100644 --- a/modules/auto_mode.py +++ b/modules/auto_mode.py @@ -51,32 +51,36 @@ class Module(ModuleManager.BaseModule): event["stdout"].write("Removed automode %s from '%s'" % ( mode_name, target_user.nickname)) - @Utils.hook("received.command.addop", require_mode="o", min_args=1, - channel_only=True, usage="") + @Utils.hook("received.command.addop", min_args=1, channel_only=True) def add_op(self, event): """ - Add a user to the auto-mode list as an op + :help: Add a user to the auto-mode list as an op + :usage: + :require_mode: o """ self._add_mode(event, "o", "op") - @Utils.hook("received.command.removeop", require_mode="o", min_args=1, - channel_only=True, usage="") + @Utils.hook("received.command.removeop", min_args=1, channel_only=True) def remove_op(self, event): """ - Remove a user from the auto-mode list as an op + :help: Remove a user from the auto-mode list as an op + :usage: + :require_mode: o """ self._remove_mode(event, "o", "op") - @Utils.hook("received.command.addvoice", require_mode="o", min_args=1, - channel_only=True, usage="") + @Utils.hook("received.command.addvoice", min_args=1, channel_only=True) def add_voice(self, event): """ - Add a user to the auto-mode list as a voice + :help: Add a user to the auto-mode list as a voice + :usage: + :require_mode: o """ self._add_mode(event, "v", "voice") - @Utils.hook("received.command.removevoice", require_mode="o", min_args=1, - channel_only=True, usage="") + @Utils.hook("received.command.removevoice", min_args=1, channel_only=True) def remove_voice(self, event): """ - Remove a user from the auto-mode list as anvoice + :help: Remove a user from the auto-mode list as a voice + :usage: + :require_mode: o """ self._remove_mode(event, "v", "voice") diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 1c88c0bb..07678d68 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -3,10 +3,11 @@ from src import ModuleManager, Utils class Module(ModuleManager.BaseModule): _name = "BTC" - @Utils.hook("received.command.btc", usage="[currency]") + @Utils.hook("received.command.btc") def btc(self, event): """ - Get the exchange rate of bitcoins + :help: Get the exchange rate of bitcoins + :usage: [currency] """ currency = (event["args"] or "USD").upper() page = Utils.get_url("https://blockchain.info/ticker", diff --git a/modules/books.py b/modules/books.py index 7a0204a6..e3642198 100644 --- a/modules/books.py +++ b/modules/books.py @@ -36,10 +36,11 @@ class Module(ModuleManager.BaseModule): else: event["stderr"].write("Failed to load results") - @Utils.hook("received.command.isbn", min_args=1, usage="") + @Utils.hook("received.command.isbn", min_args=1) def isbn(self, event): """ - Get book information from a provided ISBN + :help: Get book information from a provided ISBN + :usage: """ isbn = event["args_split"][0] if len(isbn) == 10: @@ -47,9 +48,10 @@ class Module(ModuleManager.BaseModule): isbn = isbn.replace("-", "") self.get_book("isbn:%s" % isbn, event) - @Utils.hook("received.command.book", min_args=1, usage="") + @Utils.hook("received.command.book", min_args=1) def book(self, event): """ - Get book information from a provided title + :help: Get book information from a provided title + :usage: """ self.get_book(event["args"], event) diff --git a/modules/channel_op.py b/modules/channel_op.py index a93d1137..49d9682c 100644 --- a/modules/channel_op.py +++ b/modules/channel_op.py @@ -33,11 +33,12 @@ class Module(ModuleManager.BaseModule): else: raise UserNotFoundException("That user is not in this channel") - @Utils.hook("received.command.kick|k", channel_only=True, - require_mode="o", usage=" [reason]", min_args=1) + @Utils.hook("received.command.kick|k", channel_only=True, min_args=1) def kick(self, event): """ - Kick a user from the current channel + :help: Kick a user from the current channel + :usage: [reason] + :require_mode: o """ target = event["args_split"][0] reason = " ".join(event["args_split"][1:]) or None @@ -76,11 +77,12 @@ class Module(ModuleManager.BaseModule): event["target"].send_unban(target) return target - @Utils.hook("received.command.ban", channel_only=True, min_args=1, - require_mode="o", usage="") + @Utils.hook("received.command.ban", channel_only=True, min_args=1) def ban(self, event): """ - Ban a user/hostmask from the current channel + :help: Ban a user/hostmask from the current channel + :usage: + :require_mode: o """ self._ban(event["server"], event["target"], True, event["args_split"][0]) @@ -101,17 +103,26 @@ 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|tban|tb", channel_only=True, - min_args=2, require_mode="o", usage="") + @Utils.hook("received.command.tempban|tb", channel_only=True, min_args=2) def temp_ban(self, event): + """ + :help: Temporarily ban someone from the current channel + :usage: + :require_mode: o + """ try: self._temp_ban(event, True) except InvalidTimeoutException as e: event["stderr"].set_prefix("Tempban") event["stderr"].write(str(e)) - @Utils.hook("received.command.tempkickban|tkban|tkb", channel_only=True, - min_args=2, require_mode="o", usage="") + @Utils.hook("received.command.tempkickban|tkb", channel_only=True, + min_args=2) def temp_kick_ban(self, event): + """ + :help: Temporarily kick and ban someone from the current channel + :usage: + :require_mode: o + """ reason = " ".join(event["args_split"][2:]) or None event["stderr"].set_prefix("TKB") try: @@ -123,20 +134,22 @@ class Module(ModuleManager.BaseModule): except UserNotFoundException as e: event["stderr"].write(str(e)) - @Utils.hook("received.command.unban", channel_only=True, min_args=1, - require_mode="o", usage="") + @Utils.hook("received.command.unban", channel_only=True, min_args=1) def unban(self, event): """ - Unban a user/hostmask from the current channel + :help: Unban a user/hostmask from the current channel + :usage: + :require_mode: o """ self._ban(event["server"], event["target"], False, event["args_split"][0]) - @Utils.hook("received.command.kickban|kb", channel_only=True, - require_mode="o", usage=" [reason]", min_args=1) + @Utils.hook("received.command.kickban|kb", channel_only=True, min_args=1) def kickban(self, event): """ - Kick and ban a user from the current channel + :help: Kick and ban a user from the current channel + :usage: [reason] + :require_mode: o """ target = event["args_split"][0] reason = " ".join(event["args_split"][1:]) or None @@ -147,56 +160,62 @@ class Module(ModuleManager.BaseModule): event["stderr"].set_prefix("Kickban") event["stderr"].write(str(e)) - @Utils.hook("received.command.op", channel_only=True, - require_mode="o", usage="[nickname]") + @Utils.hook("received.command.op", channel_only=True) def op(self, event): """ - Op a user in the current channel + :help: Op a user in the current channel + :usage: [nickname] + :require_mode: o """ target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("+o", target) - @Utils.hook("received.command.deop", channel_only=True, - require_mode="o", usage="[nickname]") + @Utils.hook("received.command.deop", channel_only=True) def deop(self, event): """ - Remove op from a user in the current channel + :help: Remove op from a user in the current channel + :usage: [nickname] + :require_mode: o """ target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("-o", target) - @Utils.hook("received.command.voice", channel_only=True, - require_mode="o", usage="[nickname]") + @Utils.hook("received.command.voice", channel_only=True) def voice(self, event): """ - Voice a user in the current channel + :help: Voice a user in the current channel + :usage: [nickname] + :require_mode: o """ target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("+v", target) - @Utils.hook("received.command.devoice", channel_only=True, - require_mode="o", usage="[nickname]") + @Utils.hook("received.command.devoice", channel_only=True) def devoice(self, event): """ - Remove voice from a user in the current channel + :help: Remove voice from a user in the current channel + :usage: [nickname] + :require_mode: o """ target = event["user"].nickname if not event["args_split"] else event[ "args_split"][0] event["target"].send_mode("-v", target) - @Utils.hook("received.command.topic", min_args=1, require_mode="o", - channel_only=True, usage="") + @Utils.hook("received.command.topic", min_args=1, channel_only=True) def topic(self, event): """ - Set the topic in the current channel + :help: Set the topic in the current channel + :usage: + :require_mode: o """ event["target"].send_topic(event["args"]) - @Utils.hook("received.command.tappend", min_args=1, require_mode="o", - channel_only=True, usage="") + @Utils.hook("received.command.tappend", min_args=1, channel_only=True) def tappend(self, event): """ - Append to the topic in the current channel + :help: Append to the topic in the current channel + :usage: + :require_mode: o """ event["target"].send_topic(event["target"].topic + event["args"]) diff --git a/modules/check_mode.py b/modules/check_mode.py index 2d0298b6..953b04e9 100644 --- a/modules/check_mode.py +++ b/modules/check_mode.py @@ -1,11 +1,11 @@ + from src import ModuleManager, Utils class Module(ModuleManager.BaseModule): @Utils.hook("preprocess.command") def preprocess_command(self, event): - if event["is_channel"] and event["hook"].kwargs.get( - "require_mode"): - required_mode = event["hook"].kwargs.get("require_mode")[0] + require_mode = event["hook"].get_kwarg("require_mode") + if event["is_channel"] and require_mode: if not event["target"].mode_or_above(event["user"], required_mode): return "You do not have permission to do this" diff --git a/modules/coins.py b/modules/coins.py index 4e0f966e..a27755d3 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -39,7 +39,7 @@ class Module(object): @Utils.hook("received.command.coins") def coins(self, event): """ - Show how many coins you have + :help: Show how many coins you have """ if event["args_split"]: target = event["server"].get_user(event["args_split"][0]) @@ -49,11 +49,12 @@ class Module(object): event["stdout"].write("%s has %s coin%s" % (target.nickname, "{0:.2f}".format(coins), "" if coins == 1 else "s")) - @Utils.hook("received.command.resetcoins", permission="resetcoins", - min_args=1, usage="") + @Utils.hook("received.command.resetcoins", min_args=1) def reset_coins(self, event): """ - Reset a user's coins to 0 + :help: Reset a user's coins to 0 + :usage: + :permission: resetcoins """ target = event["server"].get_user(event["args_split"][0]) coins = decimal.Decimal(target.get_setting("coins", "0.0")) @@ -64,11 +65,12 @@ class Module(object): target.del_setting("coins") event["stdout"].write("Reset coins for %s" % target.nickname) - @Utils.hook("received.command.givecoins", min_args=1, - usage=" ", permission="givecoins") + @Utils.hook("received.command.givecoins", min_args=1) def give_coins(self, event): """ - Give coins to a user + :help: Give coins to a user + :usage: + :permission: givecoins """ target = event["server"].get_user(event["args_split"][0]) coins = event["args_split"][1] @@ -86,7 +88,7 @@ class Module(object): @Utils.hook("received.command.richest") def richest(self, event): """ - Show the top 10 richest users + :help: Show the top 10 richest users """ all_coins = event["server"].get_all_user_settings("coins", []) all_coins = list(filter(lambda coin: decimal.Decimal(coin[1]), @@ -107,7 +109,7 @@ class Module(object): @Utils.hook("received.command.redeemcoins") def redeem_coins(self, event): """ - Redeem your free coins + :help: Redeem your free coins """ user_coins = decimal.Decimal(event["user"].get_setting( "coins", "0.0")) @@ -132,11 +134,11 @@ class Module(object): event["stderr"].write( "You can only redeem coins when you have none") - @Utils.hook("received.command.flip", usage="heads|tails ", - min_args=2, authenticated=True) + @Utils.hook("received.command.flip", min_args=2, authenticated=True) def flip(self, event): """ - Bet on a coin flip + :help: Bet on a coin flip + :usage: heads|tails """ side_name = event["args_split"][0].lower() coin_bet = event["args_split"][1].lower() @@ -176,11 +178,11 @@ class Module(object): event["user"].nickname, side_name, coin_bet_str, "" if coin_bet == 1 else "s")) - @Utils.hook("received.command.sendcoins", min_args=2, - usage=" ", authenticated=True) + @Utils.hook("received.command.sendcoins", min_args=2, authenticated=True) def send(self, event): """ - Send coins to another user + :help: Send coins to another user + :usage: """ if event["user"].get_id() == event["server"].get_user(event[ "args_split"][0]).get_id(): @@ -245,11 +247,11 @@ class Module(object): str(coins)) event["timer"].redo() - @Utils.hook("received.command.roulette", min_args=2, - usage=" ", authenticated=True) + @Utils.hook("received.command.roulette", min_args=2, authenticated=True) def roulette(self, event): """ - Spin a roulette wheel + :help: Spin a roulette wheel + :usage: """ bets = event["args_split"][0].lower().split(",") if "0" in bets: diff --git a/modules/commands.py b/modules/commands.py index faa9740f..e58697a7 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -151,12 +151,15 @@ class Module(ModuleManager.BaseModule): self.message(event, command) def _get_help(self, hook): - return hook.kwargs.get("help", None) or hook.function.__doc__ + return hook.get_kwarg("help", None) or hook.docstring.description + def _get_usage(self, hook): + return hook.get_kwarg("usage", None) - @Utils.hook("received.command.help", usage="") + @Utils.hook("received.command.help") def help(self, event): """ - Show help for a given command + :help: Show help for a given command + :usage: [command] """ if event["args"]: command = event["args_split"][0].lower() @@ -166,11 +169,6 @@ class Module(ModuleManager.BaseModule): help = self._get_help(hooks[0]) if help: - help = [line.strip() for line in help.split("\n")] - help = [line.strip() for line in help] - help = filter(None, help) - help = " ".join(help) - event["stdout"].write("%s: %s" % (command, help)) else: event["stderr"].write("No help available for %s" % command) @@ -186,10 +184,11 @@ class Module(ModuleManager.BaseModule): help_available = sorted(help_available) event["stdout"].write("Commands: %s" % ", ".join(help_available)) - @Utils.hook("received.command.usage", min_args=1, usage="") + @Utils.hook("received.command.usage", min_args=1) def usage(self, event): """ - Show the usage for a given command + :help: Show the usage for a given command + :usage: """ command_prefix = "" if event["is_channel"]: @@ -200,9 +199,11 @@ class Module(ModuleManager.BaseModule): if command in self.events.on("received").on( "command").get_children(): hooks = self.events.on("received.command").on(command).get_hooks() - if hooks and "usage" in hooks[0].kwargs: + usage = self._get_usage(hooks[0]) + + if usage: event["stdout"].write("Usage: %s%s %s" % (command_prefix, - command, hooks[0].kwargs["usage"])) + command, usage)) else: event["stderr"].write("No usage help available for %s" % command) else: @@ -211,16 +212,17 @@ class Module(ModuleManager.BaseModule): @Utils.hook("received.command.more", skip_out=True) def more(self, event): """ - Show more output from the last command + :help: Show more output from the last command """ if event["target"].last_stdout and event["target"].last_stdout.has_text(): event["target"].last_stdout.send() - @Utils.hook("received.command.ignore", min_args=1, usage="", - permission="ignore") + @Utils.hook("received.command.ignore", min_args=1) def ignore(self, event): """ - Ignore commands from a given user + :help: Ignore commands from a given user + :usage: + :permission: ignore """ user = event["server"].get_user(event["args_split"][0]) if user.get_setting("ignore", False): @@ -230,11 +232,12 @@ class Module(ModuleManager.BaseModule): user.set_setting("ignore", True) event["stdout"].write("Now ignoring '%s'" % user.nickname) - @Utils.hook("received.command.unignore", min_args=1, usage="", - permission="unignore") + @Utils.hook("received.command.unignore", min_args=1) def unignore(self, event): """ - Unignore commands from a given user + :help: Unignore commands from a given user + :usage: + :permission: unignore """ user = event["server"].get_user(event["args_split"][0]) if not user.get_setting("ignore", False): diff --git a/modules/define.py b/modules/define.py index 315099fe..dbd1e420 100644 --- a/modules/define.py +++ b/modules/define.py @@ -19,10 +19,11 @@ class Module(ModuleManager.BaseModule): return page - @Utils.hook("received.command.define", usage="") + @Utils.hook("received.command.define") def define(self, event): """ - Define a provided term + :help: Define a provided term + :usage: """ if event["args"]: word = event["args"] @@ -42,7 +43,7 @@ class Module(ModuleManager.BaseModule): @Utils.hook("received.command.randomword") def random_word(self, event): """ - Define a random word + :help: Define a random word """ if not self._last_called or (time.time()-self._last_called >= RANDOM_DELAY_SECONDS): diff --git a/modules/dice.py b/modules/dice.py index cb48efae..ee93f570 100644 --- a/modules/dice.py +++ b/modules/dice.py @@ -4,10 +4,11 @@ from src import ModuleManager, Utils ERROR_FORMAT = "Incorrect format! Format must be [number]d[number], e.g. 1d20" class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.roll", min_args=1, usage="[1-5]d[1-20]") + @Utils.hook("received.command.roll", min_args=1) def roll_dice(self, event): """ - Roll some dice, DND style! + :help: Roll some dice, DND style! + :usage: [1-5]d[1-20] """ raw_input = event["args_split"][0] roll = raw_input.split("d") diff --git a/modules/dns.py b/modules/dns.py index 19ef7ea0..aa00b870 100644 --- a/modules/dns.py +++ b/modules/dns.py @@ -4,10 +4,11 @@ from src import ModuleManager, Utils class Module(ModuleManager.BaseModule): _name = "DNS" - @Utils.hook("received.command.dns", min_args=1, usage="") + @Utils.hook("received.command.dns", min_args=1) def dns(self, event): """ - Get all addresses for a given hostname (IPv4/IPv6) + :help: Get all addresses for a given hostname (IPv4/IPv6) + :usage: """ hostname = event["args_split"][0] try: diff --git a/modules/ducks.py b/modules/ducks.py index 84e22942..296f6430 100644 --- a/modules/ducks.py +++ b/modules/ducks.py @@ -119,7 +119,7 @@ class Module(object): @Utils.hook("received.command.decoy") def duck_decoy(self, event): """ - Prepare a decoy duck + :help: Prepare a decoy duck """ channel = event["target"] if self.is_duck_channel(channel) == False: @@ -225,7 +225,7 @@ class Module(object): @Utils.hook("received.command.bef") def befriend(self, event): """ - Befriend a duck + :help: Befriend a duck """ channel = event["target"] user = event["user"] @@ -263,7 +263,7 @@ class Module(object): @Utils.hook("received.command.bang") def shoot(self, event): """ - Shoot a duck + :help: Shoot a duck """ channel = event["target"] user = event["user"] @@ -302,7 +302,7 @@ class Module(object): @Utils.hook("received.command.duckstats") def duck_stats(self, event): """ - Show your duck stats + :help: Show your duck stats """ user = event["user"] channel = event["target"].name @@ -347,7 +347,7 @@ class Module(object): @Utils.hook("received.command.killers") def duck_enemies(self, event): """ - Show the top duck shooters + :help: Show the top duck shooters """ the_enemy = event["server"].find_all_user_channel_settings("ducks-shot") @@ -385,7 +385,7 @@ class Module(object): @Utils.hook("received.command.friends") def duck_friends(self, event): """ - Show the top duck friends + :help: Show the top duck friends """ friends = event["server"].find_all_user_channel_settings( "ducks-befriended") diff --git a/modules/eval.py b/modules/eval.py index 3db6bd3e..72131f70 100644 --- a/modules/eval.py +++ b/modules/eval.py @@ -4,10 +4,11 @@ from src import ModuleManager, Utils EVAL_URL = "https://eval.appspot.com/eval" class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.eval", min_args=1, usage="") + @Utils.hook("received.command.eval", min_args=1) def eval(self, event): """ - Evaluate a python statement + :help: Evaluate a python statement + :usage: """ try: code, page = Utils.get_url(EVAL_URL, get_params={ diff --git a/modules/geoip.py b/modules/geoip.py index f20df6aa..38cc6043 100644 --- a/modules/geoip.py +++ b/modules/geoip.py @@ -5,10 +5,11 @@ URL_GEOIP = "http://ip-api.com/json/%s" class Module(ModuleManager.BaseModule): _name = "GeoIP" - @Utils.hook("received.command.geoip", min_args=1, usage="") + @Utils.hook("received.command.geoip", min_args=1) def geoip(self, event): """ - Get geoip data on a given IPv4/IPv6 address + :help: Get geoip data on a given IPv4/IPv6 address + :usage: """ page = Utils.get_url(URL_GEOIP % event["args_split"][0], json=True) diff --git a/modules/google.py b/modules/google.py index f6d8469c..e30e6cda 100644 --- a/modules/google.py +++ b/modules/google.py @@ -8,10 +8,11 @@ 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", usage="[search term]") + @Utils.hook("received.command.google|g") def google(self, event): """ - Get first Google result for a given search term + :help: Get first Google result for a given search term + :usage: [search term] """ phrase = event["args"] or event["target"].buffer.get() if phrase: diff --git a/modules/hash.py b/modules/hash.py index 4508d613..04b2f99c 100644 --- a/modules/hash.py +++ b/modules/hash.py @@ -2,10 +2,11 @@ import hashlib from src import ModuleManager, Utils class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.hash", min_args=2, usage=" ") + @Utils.hook("received.command.hash", min_args=2) def hash(self, event): """ - Hash a given string with a given algorithm + :help: Hash a given string with a given algorithm + :usage: """ algorithm = event["args_split"][0].lower() if algorithm in hashlib.algorithms_available: diff --git a/modules/haveibeenpwned.py b/modules/haveibeenpwned.py index 0a328c3e..62566823 100644 --- a/modules/haveibeenpwned.py +++ b/modules/haveibeenpwned.py @@ -4,12 +4,12 @@ URL_HAVEIBEENPWNEDAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/%s" URL_HAVEIBEENPWNED = "https://haveibeenpwned.com/" class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.beenpwned", usage="", - min_args=1) + @Utils.hook("received.command.beenpwned", min_args=1) def beenpwned(self, event): """ - Find out if a username, email or similar has appeared in any - hacked databases + :help: Find out if a username, email or similar has appeared in any + hacked databases + :usage: """ page = Utils.get_url(URL_HAVEIBEENPWNEDAPI % event["args"], json=True, code=True) diff --git a/modules/ids.py b/modules/ids.py index fb81f492..8a71c7f5 100644 --- a/modules/ids.py +++ b/modules/ids.py @@ -6,7 +6,7 @@ class Module(ModuleManager.BaseModule): @Utils.hook("received.command.myid") def my_id(self, event): """ - Show your user ID + :help: Show your user ID """ event["stdout"].write("%s: %d" % (event["user"].nickname, event["user"].get_id())) @@ -14,7 +14,7 @@ class Module(ModuleManager.BaseModule): @Utils.hook("received.command.channelid", channel_only=True) def channel_id(self, event): """ - Show the current channel's ID + :help: Show the current channel's ID """ event["stdout"].write("%s: %d" % (event["target"].name, event["target"].id)) diff --git a/modules/imdb.py b/modules/imdb.py index 1d3a8ab5..a584a9e4 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -9,10 +9,11 @@ URL_IMDBTITLE = "http://imdb.com/title/%s" class Module(ModuleManager.BaseModule): _name = "IMDb" - @Utils.hook("received.command.imdb", min_args=1, usage="") + @Utils.hook("received.command.imdb", min_args=1) def imdb(self, event): """ - Search for a given title on IMDb + :help: Search for a given title on IMDb + :usage: """ page = Utils.get_url(URL_OMDB, get_params={ "t": event["args"], diff --git a/modules/in.py b/modules/in.py index 7fb7d7ea..f237bee6 100644 --- a/modules/in.py +++ b/modules/in.py @@ -5,10 +5,11 @@ SECONDS_MAX = Utils.SECONDS_WEEKS*8 SECONDS_MAX_DESCRIPTION = "8 weeks" class Module(ModuleManager.BaseModule): - @Utils.hook("received.command.in", min_args=2, usage="