SpiceBot/spicebot_command_dadjoke/__init__.py
deathbybandaid 570b7c7148 test
2023-01-24 10:57:37 -05:00

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