diff --git a/Priberam/plugin.py b/Priberam/plugin.py index 9b7ef3c..dab383d 100644 --- a/Priberam/plugin.py +++ b/Priberam/plugin.py @@ -38,6 +38,7 @@ except ImportError: # without the i18n module _ = lambda x: x import urllib.parse +from datetime import datetime import re import requests import atoma @@ -125,11 +126,17 @@ class Priberam(callbacks.Plugin): irc.reply(message, prefixNick=False) find = wrap(find, ['anything', optional('int', default=1)]) - def wotd(self, irc, msg, args): - """takes no arguments - + def wotd(self, irc, msg, args, argument): + """[argument] Returns the definition of the word of the day. + If [argument] is "cron" then just return if the time is 00:00. """ + + if argument == 'cron': + now = datetime.now() + if now.hour != 0 or now.minute != 0: + return + response = requests.get( "https://dicionario.priberam.org/DoDiaRSS.aspx", headers={'User-agent': 'Mozilla/5.0'} @@ -141,8 +148,7 @@ class Priberam(callbacks.Plugin): feed.items[0].title, definition['extra'], definition['value']), prefixNick=False) - wotd = wrap(wotd) - + wotd = wrap(wotd, [optional('anything')]) Class = Priberam