SpiceBot/spicebot_command_dadjoke/__init__.py
deathbybandaid 3ff6f08c17 test
2022-05-06 13:42:44 -04:00

23 lines
512 B
Python

import requests
from sopel import plugin
from sopel_SpiceBot_Core_Prerun import prerun
@prerun()
@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