Add wotd cron. Needs to be repeated every 60 seconds with Scheduler

This commit is contained in:
Pedro de Oliveira 2020-02-10 22:57:47 +00:00
parent abf4124900
commit dd738bc95c
1 changed files with 11 additions and 5 deletions

View File

@ -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