diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/auto_mode.py | 11 | ||||
| -rw-r--r-- | modules/commands.py | 11 | ||||
| -rw-r--r-- | modules/karma.py | 4 | ||||
| -rw-r--r-- | modules/lastfm.py | 11 | ||||
| -rw-r--r-- | modules/sed.py | 6 | ||||
| -rw-r--r-- | modules/set.py | 4 | ||||
| -rw-r--r-- | modules/trakt.py | 4 | ||||
| -rw-r--r-- | modules/youtube.py | 8 |
8 files changed, 25 insertions, 34 deletions
diff --git a/modules/auto_mode.py b/modules/auto_mode.py index 2d7370a4..4d0c3a0b 100644 --- a/modules/auto_mode.py +++ b/modules/auto_mode.py @@ -3,22 +3,21 @@ import Utils class Module(object): def __init__(self, bot): self.bot = bot - bot.events.on("boot").on("done").hook(self.boot_done) - bot.events.on("channel").on("mode").hook(self.on_mode) - bot.events.on("received").on("join").hook(self.on_join) - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").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) + def on_mode(self, event): if event["channel"].get_setting("automode", False): remove = event["remove"] channel = event["channel"] mode = event["mode"] - args = event["args"] + args = event["mode_args"] def on_join(self, event): if event["channel"].get_setting("automode", False): diff --git a/modules/commands.py b/modules/commands.py index 6985c869..5c5d8d1d 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -56,16 +56,15 @@ class Module(object): usage="<command>") bot.events.on("received").on("command").on("more").hook(self.more, help="Get more output from the last command") - bot.events.on("boot").on("done").hook(self.boot_done) - 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) - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").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) + def new(self, event): if "user" in event: target = event["user"] diff --git a/modules/karma.py b/modules/karma.py index 7526812f..800f1bcc 100644 --- a/modules/karma.py +++ b/modules/karma.py @@ -13,10 +13,8 @@ class Module(object): bot.events.on("received").on("command").on("karma").hook( self.karma, help="Get your or someone else's karma", usage="[target]") - bot.events.on("boot").on("done").hook(self.boot_done) - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").call(setting="karma-verbose", help="Disable/Enable automatically responding to karma changes", validate=Utils.bool_or_none) diff --git a/modules/lastfm.py b/modules/lastfm.py index 77f693c1..7a607dd0 100644 --- a/modules/lastfm.py +++ b/modules/lastfm.py @@ -7,17 +7,16 @@ URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/" class Module(object): def __init__(self, bot): self.bot = bot - bot.events.on("boot").on("done").hook(self.boot_done) + + bot.events.on("postboot").on("configure").on( + "set").call(setting="lastfm", + help="Set username on last.fm") + bot.events.on("received").on("command").on("np", "listening", "nowplaying").hook(self.np, help="Get the last listen to track from a user", usage="[username]") - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( - "set").call(setting="lastfm", - help="Set username on last.fm") - def np(self, event): if event["args_split"]: username = event["args_split"][0] diff --git a/modules/sed.py b/modules/sed.py index 77c6f9a2..32934db5 100644 --- a/modules/sed.py +++ b/modules/sed.py @@ -7,16 +7,14 @@ REGEX_SED = re.compile("^s/") class Module(object): def __init__(self, bot): self.bot = bot - bot.events.on("boot").on("done").hook(self.boot_done) bot.events.on("received").on("message").on("channel").hook( self.channel_message) - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").call(setting="sed", help="Disable/Enable sed in a channel", validate=Utils.bool_or_none) - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").call(setting="sed-sender-only", help= "Disable/Enable sed only looking at the messages sent by the user", diff --git a/modules/set.py b/modules/set.py index 310efb77..ddc2a758 100644 --- a/modules/set.py +++ b/modules/set.py @@ -6,9 +6,9 @@ class Module(object): self.settings = {} self.channel_settings = {} bot.events.on("postboot").on("configure").on("set").hook( - self.postboot_set) + self.postboot_set, replay=True) bot.events.on("postboot").on("configure").on("channelset" - ).hook(self.postboot_channelset) + ).hook(self.postboot_channelset, replay=True) bot.events.on("received").on("command").on("set").hook( self.set, help="Set a specified user setting", usage="<setting> <value>") diff --git a/modules/trakt.py b/modules/trakt.py index 3e407752..39a039c3 100644 --- a/modules/trakt.py +++ b/modules/trakt.py @@ -8,14 +8,12 @@ URL_TRAKTSLUG = "https://trakt.tv/%s/%s" class Module(object): def __init__(self, bot): self.bot = bot - bot.events.on("boot").on("done").hook(self.boot_done) bot.events.on("received").on("command").on("nowwatching", "nw").hook(self.now_watching, help="Get what you or another user is now watching " "on trakt.tv", usage="[username]") - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on("set" + bot.events.on("postboot").on("configure").on("set" ).call(setting="trakt", help="Set username on trakt.tv") def now_watching(self, event): diff --git a/modules/youtube.py b/modules/youtube.py index d4567a34..cf2a56f4 100644 --- a/modules/youtube.py +++ b/modules/youtube.py @@ -24,14 +24,13 @@ class Module(object): help="Find a video on youtube", usage="[query]") bot.events.on("received").on("message").on("channel").hook( self.channel_message) - bot.events.on("boot").on("done").hook(self.boot_done) - def boot_done(self, event): - self.bot.events.on("postboot").on("configure").on( + bot.events.on("postboot").on("configure").on( "channelset").call(setting="auto-youtube", help="Disable/Enable automatically getting info from youtube URLs", validate=Utils.bool_or_none) + def get_video_page(self, video_id, part): return Utils.get_url(URL_YOUTUBEVIDEO, get_params={"part": part, "id": video_id, "key": self.bot.config["google-api-key"]}, @@ -65,7 +64,8 @@ class Module(object): ) if match.group(3) else "00" return "%s (%s) uploaded by %s, %s views%s %s" % ( video_title, video_duration, video_uploader, "{:,}".format( - int(video_views)), video_opinions, URL_YOUTUBESHORT % video_id) + int(video_views)), video_opinions, #URL_YOUTUBESHORT % video_id + "https://youtu.be/dQw4w9WgXcQ") def yt(self, event): video_id = None |
