From 8b0314b190b02f7e83fe0dae3c349ce4dffdcb4f Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 27 Sep 2018 11:46:10 +0100 Subject: Use ModuleManager.BaseModule in more modules --- modules/define.py | 8 +++----- modules/google.py | 7 ++----- modules/imdb.py | 6 ++---- modules/in.py | 7 ++----- modules/isgd.py | 7 ++----- modules/modules.py | 5 +---- modules/nickname_aliases.py | 6 ++---- modules/nr.py | 9 +++------ modules/print_activity.py | 7 ++----- modules/set.py | 7 ++----- modules/soundcloud.py | 6 ++---- modules/stats.py | 7 ++----- modules/tfl.py | 8 +++----- modules/thesaurus.py | 7 ++----- modules/tweets.py | 7 ++----- modules/weather.py | 7 ++----- modules/wolframalpha.py | 6 ++---- src/ModuleManager.py | 4 +++- 18 files changed, 39 insertions(+), 82 deletions(-) diff --git a/modules/define.py b/modules/define.py index 178a9c5a..57b3a762 100644 --- a/modules/define.py +++ b/modules/define.py @@ -1,17 +1,15 @@ #--require-config wordnik-api-key import time -from src import Utils +from src import ModuleManager, Utils URL_WORDNIK = "https://api.wordnik.com/v4/word.json/%s/definitions" URL_WORDNIK_RANDOM = "https://api.wordnik.com/v4/words.json/randomWord" RANDOM_DELAY_SECONDS = 3 -class Module(object): - def __init__(self, bot, events, exports): - self.bot = bot - self._last_called = 0 +class Module(ModuleManager.BaseModule): + _last_called = 0 def _get_definition(self, word): word = event["args"] if "args" in event else event diff --git a/modules/google.py b/modules/google.py index f98ed2ad..fb487db1 100644 --- a/modules/google.py +++ b/modules/google.py @@ -2,15 +2,12 @@ #--require-config google-search-id import json -from src import Utils +from src import ModuleManager, Utils URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1" URL_GOOGLESUGGEST = "http://google.com/complete/search" -class Module(object): - def __init__(self, bot, events, exports): - self.bot = bot - +class Module(ModuleManager.BaseModule): @Utils.hook("received.command.google|g", usage="[search term]") def google(self, event): """ diff --git a/modules/imdb.py b/modules/imdb.py index d735910f..1d3a8ab5 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -1,15 +1,13 @@ #--require-config omdbapi-api-key import json -from src import Utils +from src import ModuleManager, Utils URL_OMDB = "http://www.omdbapi.com/" URL_IMDBTITLE = "http://imdb.com/title/%s" -class Module(object): +class Module(ModuleManager.BaseModule): _name = "IMDb" - def __init__(self, bot, events, exports): - self.bot = bot @Utils.hook("received.command.imdb", min_args=1, usage="") def imdb(self, event): diff --git a/modules/in.py b/modules/in.py index 52363fec..36b84f28 100644 --- a/modules/in.py +++ b/modules/in.py @@ -1,13 +1,10 @@ import time -from src import Utils +from src import ModuleManager, Utils SECONDS_MAX = Utils.SECONDS_WEEKS*8 SECONDS_MAX_DESCRIPTION = "8 weeks" -class Module(object): - def __init__(self, bot, events, exports): - self.bot = bot - +class Module(ModuleManager.BaseModule): @Utils.hook("received.command.in", min_args=2, usage="