From c7532143174a6693a697b86e268662fffa3ea387 Mon Sep 17 00:00:00 2001 From: pocketjawa Date: Sun, 19 Mar 2017 02:47:09 -0400 Subject: [PATCH] Added emoji-reaction based giveaway command --- helpcommand.txt | 3 ++- pocketbot.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/helpcommand.txt b/helpcommand.txt index e6e5772..6e0c2aa 100644 --- a/helpcommand.txt +++ b/helpcommand.txt @@ -17,4 +17,5 @@ **!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 **!8ball**: You ask a question, it answeres. Simple! -**!conch** or **!magicconch**: Same as the 8ball command but waaaaay cooler \ No newline at end of file +**!conch** or **!magicconch**: Same as the 8ball command but waaaaay cooler +**!giveaway prize**: Do a giveaway based on users reacting with the emoji you react with secretly. Use in private and replace prize with an actual prize! \ No newline at end of file diff --git a/pocketbot.py b/pocketbot.py index 96ab94d..730e7a9 100644 --- a/pocketbot.py +++ b/pocketbot.py @@ -177,6 +177,29 @@ def on_message(message): else: yield from client.send_message(message.channel, 'The Magic Conch Shell says... ' + random.choice(ball_responses)) + #Create a message that will send the person who reacts correctly the contents of message. Use in either DMs or a channel the public cannot see. + elif message.content.lower().startswith('!giveaway'): + + #Split off the text to send to the winner + args = message.content.partition(' ')[2] + + if (args is ''): + yield from client.send_message(message.channel, 'Please include something to send to the winner!') + return + + #Get the secret emoji + sourcemsg = yield from client.send_message(message.channel, 'React with the secret emoji :3') + sourceres = yield from client.wait_for_reaction(message=sourcemsg, timeout=30) + reactemoji = sourceres.reaction.emoji + + #Send the poll to public + msg = yield from client.send_message(public_channel_id, 'React to this pls') + res = yield from client.wait_for_reaction(reactemoji, message=msg, timeout=30) + + #Congratulate and ,essage the winner + yield from client.send_message(public_channel_id, 'Congrats to {0.user}!'.format(res)) + yield from client.send_message(res.user, args) + client.loop.create_task(ups_check()) client.run(token) \ No newline at end of file