From bb35612ce2d2e340f2012ec6ec5c8fc5e452936a Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Thu, 2 Mar 2017 11:48:42 -0500 Subject: [PATCH] Added command to pull random joke from /r/Jokes --- helpcommand.txt | 3 ++- pocketbot.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/helpcommand.txt b/helpcommand.txt index 60b927c..0322fd7 100644 --- a/helpcommand.txt +++ b/helpcommand.txt @@ -14,4 +14,5 @@ **!xkcd x**: Posts xkcd comic number x (if it exists) **!earth** or **!earthporn**: Posts a random submission from /r/EarthPorn's top this week **!porn**: Posts a random link from one of the 'porn' subreddits (not actually NSFW) -**!kill** or **!restart**: Kill the bot process so that it can automatically restart with the new version (only pocketjawa can use these) \ No newline at end of file +**!kill** or **!restart**: Kill the bot process so that it can automatically restart with the new version (only pocketjawa can use these) +**!joke**: Posts a random joke from /r/Jokes \ No newline at end of file diff --git a/pocketbot.py b/pocketbot.py index 95fe604..eea33c4 100644 --- a/pocketbot.py +++ b/pocketbot.py @@ -149,6 +149,13 @@ def on_message(message): else: yield from client.send_message(message.channel, 'Booooo you\'re not Onii-chan. You\'re not allowed to use this command!') + #Random jokes from /r/jokes + elif message.content.lower().startswith('!joke'): + jokes = reddit.subreddit('jokes').top('week') + jokesr = random.choice(list(jokes)) + jokemsg = jokesr.title + '\n\n' + jokesr.selftext + yield from client.send_message(message.channel, jokemsg) + client.loop.create_task(ups_check()) client.run(token) \ No newline at end of file