Add wotd cron. Needs to be repeated every 60 seconds with Scheduler
This commit is contained in:
parent
abf4124900
commit
dd738bc95c
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue