23 lines
516 B
Python
23 lines
516 B
Python
|
|
import requests
|
|
|
|
from sopel import plugin
|
|
|
|
from sopel_SpiceBot_Core_Prerun import sbprerun
|
|
|
|
|
|
@sbprerun()
|
|
@plugin.command('dad', 'dadjoke')
|
|
def upper(bot, trigger, comrun):
|
|
fetched_str = fetch_string()
|
|
if not fetched_str:
|
|
fetched_str = 'My humor module is broken.'
|
|
comrun.say(fetched_str)
|
|
|
|
|
|
def fetch_string():
|
|
content_url = 'https://icanhazdadjoke.com'
|
|
content_page = requests.get(content_url, headers={'Accept': 'text/plain'})
|
|
fetched_str = content_page.text
|
|
return fetched_str
|