From b7cf524e9869828ff85954cb731f7fee98bee8d9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 31 Aug 2018 12:55:52 +0100 Subject: Give modules event objects with "context"s, to facilitate purging all the event hooks for a module --- modules/accept_invite.py | 5 ++--- modules/admin.py | 8 ++++---- modules/auto_mode.py | 8 ++++---- modules/bitcoin.py | 4 ++-- modules/bitly.py | 9 ++++---- modules/books.py | 6 +++--- modules/channel_op.py | 28 ++++++++++++------------- modules/channel_save.py | 9 ++++---- modules/check_mode.py | 5 ++--- modules/coins.py | 18 ++++++++-------- modules/commands.py | 41 +++++++++++++++++++------------------ modules/ctcp.py | 6 +++--- modules/define.py | 4 ++-- modules/dns.py | 4 ++-- modules/ducks.py | 27 ++++++++++++------------ modules/geoip.py | 4 ++-- modules/google.py | 4 ++-- modules/hash.py | 4 ++-- modules/haveibeenpwned.py | 4 ++-- modules/ids.py | 6 +++--- modules/imdb.py | 4 ++-- modules/in.py | 6 +++--- modules/join.py | 8 ++++---- modules/karma.py | 17 +++++++-------- modules/lastfm.py | 6 +++--- modules/nickname_aliases.py | 10 ++++----- modules/nickserv.py | 6 +++--- modules/nr.py | 18 ++++++++-------- modules/perform.py | 4 ++-- modules/permissions.py | 20 +++++++++--------- modules/pong.py | 5 ++--- modules/print_activity.py | 34 +++++++++++++++--------------- modules/quit.py | 4 ++-- modules/quotes.py | 10 ++++----- modules/random_number.py | 6 +++--- modules/sasl.py | 10 ++++----- modules/sed.py | 13 ++++++------ modules/seen.py | 6 +++--- modules/set.py | 17 +++++++-------- modules/signals.py | 8 +++++--- modules/soundcloud.py | 4 ++-- modules/spotify.py | 4 ++-- modules/stats.py | 6 +++--- modules/strax.py | 4 ++-- modules/telegram.py | 11 +++++----- modules/tfl.py | 14 ++++++------- modules/thesaurus.py | 4 ++-- modules/title.py | 50 ++++++++++++++++++++++----------------------- modules/to.py | 6 +++--- modules/todo.py | 8 ++++---- modules/trakt.py | 6 +++--- modules/translate.py | 4 ++-- modules/twitter.py | 4 ++-- modules/upc.py | 4 ++-- modules/urbandictionary.py | 4 ++-- modules/weather.py | 4 ++-- modules/wikipedia.py | 4 ++-- modules/wolframalpha.py | 6 +++--- modules/words.py | 12 +++++------ modules/youtube.py | 11 +++++----- 60 files changed, 296 insertions(+), 290 deletions(-) (limited to 'modules') diff --git a/modules/accept_invite.py b/modules/accept_invite.py index 57ba9d70..e25aea76 100644 --- a/modules/accept_invite.py +++ b/modules/accept_invite.py @@ -1,9 +1,8 @@ class Module(object): - def __init__(self, bot): - bot.events.on("received").on("invite").hook( - self.on_invite) + def __init__(self, bot, events): + events.on("received").on("invite").hook(self.on_invite) def on_invite(self, event): if event["server"].get_setting("accept-invites", True): diff --git a/modules/admin.py b/modules/admin.py index 400c54df..5578febe 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -1,16 +1,16 @@ class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("changenickname" + events.on("received").on("command").on("changenickname" ).hook(self.change_nickname, permission="changenickname", min_args=1, help="Change my nickname", usage="") - bot.events.on("received").on("command").on("raw" + events.on("received").on("command").on("raw" ).hook(self.raw, permission="raw", min_args=1, help="Send a raw IRC line through the bot", usage="") - bot.events.on("received").on("command").on("part" + events.on("received").on("command").on("part" ).hook(self.part, permission="part", min_args=1, help="Part from a channel", usage="<#channel>") diff --git a/modules/auto_mode.py b/modules/auto_mode.py index 2c33f260..3e800591 100644 --- a/modules/auto_mode.py +++ b/modules/auto_mode.py @@ -1,16 +1,16 @@ import Utils class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="automode", help="Disable/Enable automode", validate=Utils.bool_or_none) - bot.events.on("channel").on("mode").hook(self.on_mode) - bot.events.on("received").on("join").hook(self.on_join) + events.on("channel").on("mode").hook(self.on_mode) + events.on("received").on("join").hook(self.on_join) def on_mode(self, event): if event["channel"].get_setting("automode", False): diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 17408322..f15c5266 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -2,9 +2,9 @@ import Utils class Module(object): _name = "BTC" - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("btc").hook( + events.on("received").on("command").on("btc").hook( self.btc, help="Get the exchange rate of bitcoins", usage="[currency]") diff --git a/modules/bitly.py b/modules/bitly.py index f31ca347..05489fb0 100644 --- a/modules/bitly.py +++ b/modules/bitly.py @@ -7,10 +7,11 @@ URL_BITLYSHORTEN = "https://api-ssl.bitly.com/v3/shorten" REGEX_URL = re.compile("https?://", re.I) class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("get").on("shortlink").hook(self.shortlink) - bot.events.on("received").on("command").on("shorten" + self.events = events + events.on("get").on("shortlink").hook(self.shortlink) + events.on("received").on("command").on("shorten" ).hook(self.shorten, min_args=1, help="Shorten a URL.", usage="") @@ -25,7 +26,7 @@ class Module(object): return data["data"]["url"] def shorten(self, event): - link = self.bot.events.on("get").on("shortlink" + link = self.events.on("get").on("shortlink" ).call_for_result(url=event["args"]) if link: event["stdout"].write("Short URL: %s" % link) diff --git a/modules/books.py b/modules/books.py index 5f7c0627..9c94c656 100644 --- a/modules/books.py +++ b/modules/books.py @@ -7,12 +7,12 @@ REGEX_BOOKID = re.compile("id=([\w\-]+)") class Module(object): _name = "ISBN" - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("isbn").hook( + events.on("received").on("command").on("isbn").hook( self.isbn, help="Get book information from a provided ISBN", min_args=1, usage="") - bot.events.on("received").on("command").on("book").hook( + events.on("received").on("command").on("book").hook( self.book, help="Get book information from a provided title", min_args=1, usage="") diff --git a/modules/channel_op.py b/modules/channel_op.py index b488f224..9e20d693 100644 --- a/modules/channel_op.py +++ b/modules/channel_op.py @@ -2,57 +2,57 @@ import Utils class Module(object): _name = "Channel Op" - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("kick", "k" + events.on("received").on("command").on("kick", "k" ).hook(self.kick, channel_only=True, require_mode="o", min_args=1, help="Kick a user from the channel", usage=" [reason]") - bot.events.on("received").on("command").on("ban" + events.on("received").on("command").on("ban" ).hook(self.ban, channel_only=True, require_mode="o", min_args=1, help="Ban a user/hostmask from the channel", usage="") - bot.events.on("received").on("command").on("unban" + events.on("received").on("command").on("unban" ).hook(self.unban, channel_only=True, require_mode="o", min_args=1, help="Unban a user/hostmask from the channel", usage="") - bot.events.on("received").on("command").on("kickban", "kb" + events.on("received").on("command").on("kickban", "kb" ).hook(self.kickban, channel_only=True, require_mode="o", min_args=1, help="Kickban a user from the channel", usage=" [reason]") - bot.events.on("received").on("command").on("op" + events.on("received").on("command").on("op" ).hook(self.op, channel_only=True, require_mode="o", help="Give +o to a user", usage="[nickname]") - bot.events.on("received").on("command").on("deop" + events.on("received").on("command").on("deop" ).hook(self.deop, channel_only=True, require_mode="o", help="Take +o from a user", usage="[nickname]") - bot.events.on("received").on("command").on("voice" + events.on("received").on("command").on("voice" ).hook(self.voice, channel_only=True, require_mode="o", help="Give +v to a user", usage="[nickname]") - bot.events.on("received").on("command").on("devoice" + events.on("received").on("command").on("devoice" ).hook(self.devoice, channel_only=True, require_mode="o", help="Take +v from a user", usage="[nickname]") - bot.events.on("received").on("message").on("channel").hook( + events.on("received").on("message").on("channel").hook( self.highlight_spam) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="highlight-spam-threshold", help="Set the number of nicknames in a message that " "qualifies as spam", validate=Utils.int_or_none) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="highlight-spam-protection", help="Enable/Disable highlight spam protection", validate=Utils.bool_or_none) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="highlight-spam-ban", help="Enable/Disable banning highlight spammers " "instead of just kicking", validate=Utils.bool_or_none) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="ban-format", help="Set ban format ($n = nick, $u = username, $h = hostname)") diff --git a/modules/channel_save.py b/modules/channel_save.py index c70d8751..afbd4200 100644 --- a/modules/channel_save.py +++ b/modules/channel_save.py @@ -1,11 +1,10 @@ class Module(object): - def __init__(self, bot): - bot.events.on("received.numeric.001").hook( - self.on_connect) - bot.events.on("self.join").hook(self.on_join) - bot.events.on("self.kick").hook(self.on_kick) + def __init__(self, bot, events): + events.on("received.numeric.001").hook(self.on_connect) + events.on("self.join").hook(self.on_join) + events.on("self.kick").hook(self.on_kick) def on_connect(self, event): channels = event["server"].get_setting("autojoin", []) diff --git a/modules/check_mode.py b/modules/check_mode.py index a7a8e788..4fb2b783 100644 --- a/modules/check_mode.py +++ b/modules/check_mode.py @@ -1,10 +1,9 @@ class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("preprocess").on("command").hook( - self.preprocess_command) + events.on("preprocess").on("command").hook(self.preprocess_command) def preprocess_command(self, event): if event["is_channel"] and event["hook"].kwargs.get( diff --git a/modules/coins.py b/modules/coins.py index 4fa0377e..307f171f 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -26,26 +26,26 @@ THIRD_COLUMN = list(range(1, 37))[2::3] REGEX_STREET = re.compile("street([1-9]|1[0-2])$") class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received.command.coins").hook(self.coins, + events.on("received.command.coins").hook(self.coins, help="Show how many coins you have") - bot.events.on("received").on("command").on("resetcoins").hook( + events.on("received").on("command").on("resetcoins").hook( self.reset_coins, permission="resetcoins", min_args=1, help= "Reset a specified user's coins to %s" % str(DECIMAL_ZERO), usage="") - bot.events.on("received.command.richest").hook( + events.on("received.command.richest").hook( self.richest, help="Show the top 10 richest users") - bot.events.on("received.command.redeemcoins").hook( + events.on("received.command.redeemcoins").hook( self.redeem_coins, help="Redeem free coins") - bot.events.on("received.command.flip").hook(self.flip, + events.on("received.command.flip").hook(self.flip, help="Bet coins on a coin flip", usage= "heads|tails ", min_args=2, protect_registered=True) - bot.events.on("received.command.sendcoins").hook( + events.on("received.command.sendcoins").hook( self.send, min_args=2, help="Send coins to a user", usage=" ", authenticated=True) - bot.events.on("received.command.roulette").hook( + events.on("received.command.roulette").hook( self.roulette, min_args=2, help="Spin the roulette wheel", usage=" ", protect_registered=True) @@ -53,7 +53,7 @@ class Module(object): until_next_hour = 60-now.second until_next_hour += ((60-(now.minute+1))*60) - bot.events.on("timer").on("coin-interest").hook(self.interest) + events.on("timer").on("coin-interest").hook(self.interest) bot.add_timer("coin-interest", INTEREST_INTERVAL, persist=False, next_due=time.time()+until_next_hour) diff --git a/modules/commands.py b/modules/commands.py index fbce393d..5084f690 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -45,27 +45,28 @@ class StdErr(Out): self.module_name, Utils.FONT_RESET) class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("message").on("channel").hook( + self.events = events + events.on("received").on("message").on("channel").hook( self.channel_message) - bot.events.on("received").on("message").on("private").hook( + events.on("received").on("message").on("private").hook( self.private_message) - bot.events.on("received").on("command").on("help").hook(self.help, + events.on("received").on("command").on("help").hook(self.help, help="Show help for commands", usage="") - bot.events.on("received").on("command").on("usage").hook(self.usage, + events.on("received").on("command").on("usage").hook(self.usage, help="Show usage help for commands", min_args=1, usage="") - bot.events.on("received").on("command").on("more").hook(self.more, + events.on("received").on("command").on("more").hook(self.more, help="Get more output from the last command", skip_out=True) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="command-prefix", help="Set the command prefix used in this channel") - bot.events.on("new").on("user", "channel").hook(self.new) - bot.events.on("send").on("stdout").hook(self.send_stdout) - bot.events.on("send").on("stderr").hook(self.send_stderr) + events.on("new").on("user", "channel").hook(self.new) + events.on("send").on("stdout").hook(self.send_stdout) + events.on("send").on("stderr").hook(self.send_stderr) def new(self, event): if "user" in event: @@ -76,10 +77,10 @@ class Module(object): target.last_stderr = None def has_command(self, command): - return command.lower() in self.bot.events.on("received").on( + return command.lower() in self.events.on("received").on( "command").get_children() def get_hook(self, command): - return self.bot.events.on("received").on("command").on(command + return self.events.on("received").on("command").on(command ).get_hooks()[0] def is_highlight(self, server, s): @@ -108,7 +109,7 @@ class Module(object): stdout, stderr = StdOut(module_name, target), StdErr(module_name, target) - returns = self.bot.events.on("preprocess").on("command" + returns = self.events.on("preprocess").on("command" ).call(hook=hook, user=event["user"], server=event["server"], target=target, is_channel=is_channel) for returned in returns: @@ -129,7 +130,7 @@ class Module(object): args = " ".join(args_split) server = event["server"] user = event["user"] - self.bot.events.on("received").on("command").on(command + self.events.on("received").on("command").on(command ).call_limited(1, user=user, server=server, target=target, buffer=buffer, args=args, args_split=args_split, stdout=stdout, stderr=stderr, @@ -162,9 +163,9 @@ class Module(object): def help(self, event): if event["args"]: command = event["args_split"][0].lower() - if command in self.bot.events.on("received").on( + if command in self.events.on("received").on( "command").get_children(): - hooks = self.bot.events.on("received").on("command").on(command).get_hooks() + hooks = self.events.on("received").on("command").on(command).get_hooks() if hooks and "help" in hooks[0].kwargs: event["stdout"].write("%s: %s" % (command, hooks[0].kwargs["help"])) else: @@ -173,8 +174,8 @@ class Module(object): event["stderr"].write("Unknown command '%s'" % command) else: help_available = [] - for child in self.bot.events.on("received").on("command").get_children(): - hooks = self.bot.events.on("received").on("command").on(child).get_hooks() + for child in self.events.on("received").on("command").get_children(): + hooks = self.events.on("received").on("command").on(child).get_hooks() if hooks and "help" in hooks[0].kwargs: help_available.append(child) help_available = sorted(help_available) @@ -182,9 +183,9 @@ class Module(object): def usage(self, event): command = event["args_split"][0].lower() - if command in self.bot.events.on("received").on( + if command in self.events.on("received").on( "command").get_children(): - hooks = self.bot.events.on("received").on("command").on(command).get_hooks() + hooks = self.events.on("received").on("command").on(command).get_hooks() if hooks and "usage" in hooks[0].kwargs: event["stdout"].write("Usage: %s %s" % (command, hooks[0].kwargs["usage"])) else: diff --git a/modules/ctcp.py b/modules/ctcp.py index 031b39cd..5320369a 100644 --- a/modules/ctcp.py +++ b/modules/ctcp.py @@ -1,10 +1,10 @@ import datetime class Module(object): - def __init__(self, bot): - bot.events.on("received").on("message").on("private").hook( - self.private_message) + def __init__(self, bot, events): self.bot = bot + events.on("received").on("message").on("private").hook( + self.private_message) def private_message(self, event): if event["message"][0] == "\x01" and event["message"][-1] == "\x01": diff --git a/modules/define.py b/modules/define.py index c5e62b6a..6f17164c 100644 --- a/modules/define.py +++ b/modules/define.py @@ -5,9 +5,9 @@ import Utils URL_WORDNIK = "http://api.wordnik.com:80/v4/word.json/%s/definitions" class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("define").hook( + events.on("received").on("command").on("define").hook( self.define, help="Define a provided term", usage="") diff --git a/modules/dns.py b/modules/dns.py index 2935e1bf..43499601 100644 --- a/modules/dns.py +++ b/modules/dns.py @@ -2,8 +2,8 @@ import socket class Module(object): _name = "DNS" - def __init__(self, bot): - bot.events.on("received").on("command").on("dns").hook( + def __init__(self, bot, events): + events.on("received").on("command").on("dns").hook( self.dns, min_args=1, help="Get all addresses for a given hostname (IPv4/IPv6)", usage="") diff --git a/modules/ducks.py b/modules/ducks.py index 685a49f9..d67c2608 100644 --- a/modules/ducks.py +++ b/modules/ducks.py @@ -7,23 +7,24 @@ DUCK_LAST_SEEN = datetime.datetime.now() class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.log = IRCLogging.Log self.bot = bot + self.events = events self.active_duck = 0 - bot.events.on("received.command.bef").hook(self.duck_bef, + events.on("received.command.bef").hook(self.duck_bef, help="Befriend a duck!") - bot.events.on("received.command.bang").hook(self.duck_bang, + events.on("received.command.bang").hook(self.duck_bang, help="Shoot a duck! Meanie.") - bot.events.on("received.command.decoy").hook(self.set_decoy, + events.on("received.command.decoy").hook(self.set_decoy, help="Be a sneaky fellow and make a decoy duck.") - # bot.events.on("received.command.friends").hook(self.duck_friends, + # events.on("received.command.friends").hook(self.duck_friends, # help="See who the friendliest people to ducks are!") - # bot.events.on("received.command.killers").hook(self.duck_killers, + # events.on("received.command.killers").hook(self.duck_killers, # help="See who shoots the most amount of ducks.") - # bot.events.on("received.command.ducks").hook(self.duck_list, + # events.on("received.command.ducks").hook(self.duck_list, # help="Shows a list of the most popular duck superstars.") now = datetime.datetime.now() @@ -35,22 +36,22 @@ class Module(object): tricky = next_duck_time - now.second tricky += ((next_duck_time - (now.minute + 1)) * 2) - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="ducks-enabled", help="Toggles ducks! (1 or 0)") - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="min-duck-time", help="Minimum seconds before a duck is summoned") - bot.events.on("postboot").on("configure").on( + events.on("postboot").on("configure").on( "channelset").assure_call(setting="max-duck-time", help="Max seconds before a duck is summoned") - bot.events.on("timer").on("duck-appear").hook(self.show_duck) + events.on("timer").on("duck-appear").hook(self.show_duck) bot.add_timer("duck-appear", next_duck_time, persist=False) - bot.events.on("received.numeric.366").hook(self.bootstrap) + events.on("received.numeric.366").hook(self.bootstrap) def bootstrap(self, event): for server in self.bot.servers.values(): @@ -198,7 +199,7 @@ class Module(object): def set_decoy(self, event): next_decoy_time = self.decoy_time() - self.bot.events.on("timer").on("duck-decoy").hook(self.duck_decoy) + self.events.on("timer").on("duck-decoy").hook(self.duck_decoy) self.bot.add_timer("duck-decoy", next_decoy_time, persist=False) # def coins(self, event): diff --git a/modules/geoip.py b/modules/geoip.py index 7615575c..bd874d76 100644 --- a/modules/geoip.py +++ b/modules/geoip.py @@ -4,8 +4,8 @@ URL_GEOIP = "http://ip-api.com/json/%s" class Module(object): _name = "GeoIP" - def __init__(self, bot): - bot.events.on("received").on("command").on("geoip").hook( + def __init__(self, bot, events): + events.on("received").on("command").on("geoip").hook( self.geoip, min_args=1, help="Get geoip data on a given IPv4/IPv6 address", usage="") diff --git a/modules/google.py b/modules/google.py index b8d5c653..632c5fd2 100644 --- a/modules/google.py +++ b/modules/google.py @@ -6,9 +6,9 @@ import Utils URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1" class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("google", + events.on("received").on("command").on("google", "g").hook(self.google, help="Google feeling lucky", usage="[search term]") diff --git a/modules/hash.py b/modules/hash.py index 86657bd1..19f0591f 100644 --- a/modules/hash.py +++ b/modules/hash.py @@ -1,9 +1,9 @@ import hashlib class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("hash" + events.on("received").on("command").on("hash" ).hook(self.hash, min_args=2, help="Hash a string", usage=" ") diff --git a/modules/haveibeenpwned.py b/modules/haveibeenpwned.py index fa10129c..854f69f3 100644 --- a/modules/haveibeenpwned.py +++ b/modules/haveibeenpwned.py @@ -4,8 +4,8 @@ URL_HAVEIBEENPWNEDAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/%s" URL_HAVEIBEENPWNED = "https://haveibeenpwned.com/" class Module(object): - def __init__(self, bot): - bot.events.on("received").on("command").on("beenpwned").hook( + def __init__(self, bot, events): + events.on("received").on("command").on("beenpwned").hook( self.beenpwned, min_args=1, help="Find out if a username, email or similar has appeared " "in any hacked databases", usage="") diff --git a/modules/ids.py b/modules/ids.py index c8bd8042..0c8ba0bf 100644 --- a/modules/ids.py +++ b/modules/ids.py @@ -2,10 +2,10 @@ class Module(object): _name = "IDs" - def __init__(self, bot): - bot.events.on("received.command.myid").hook(self.my_id, + def __init__(self, bot, events): + events.on("received.command.myid").hook(self.my_id, help="Show your user ID") - bot.events.on("received.command.channelid").hook( + events.on("received.command.channelid").hook( self.channel_id, channel_only=True, help="Show the current channel's ID") diff --git a/modules/imdb.py b/modules/imdb.py index c24b4c0a..71458638 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -8,9 +8,9 @@ URL_IMDBTITLE = "http://imdb.com/title/%s" class Module(object): _name = "IMDb" - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("imdb").hook( + events.on("received").on("command").on("imdb").hook( self.imdb, min_args=1, help="Search for a given title on IMDb", usage="") diff --git a/modules/in.py b/modules/in.py index 4f4aef51..2ac6a9bc 100644 --- a/modules/in.py +++ b/modules/in.py @@ -5,12 +5,12 @@ SECONDS_MAX = Utils.SECONDS_WEEKS*8 SECONDS_MAX_DESCRIPTION = "8 weeks" class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot - bot.events.on("received").on("command").on("in").hook( + events.on("received").on("command").on("in").hook( self.in_command, min_args=2, help="Set a reminder", usage="