Skip to content

Instantly share code, notes, and snippets.

@thomkenn
Last active April 8, 2016 05:10
Show Gist options
  • Save thomkenn/457ab8d7da3312a49aaf12b8f9c56e4f to your computer and use it in GitHub Desktop.
Save thomkenn/457ab8d7da3312a49aaf12b8f9c56e4f to your computer and use it in GitHub Desktop.
import re
import time
# delays for 5 seconds
def check_condition(c):
if inc % 500 == 0:
return True
def bot_action(c, verbose=True, respond=False):
global res
res = 1 + res
res = res % 5
time.sleep(30)
if res == 1:
head = "Woosh"
c.reply(head)
if res == 2:
head = "Comment of the year"
c.reply(head)
if res == 3:
head = "Are you for real?"
c.reply(head)
if res == 4:
head = "I'm taking a screenshot so I can remember this moment forever"
c.reply(head)
if __name__ is '__main__':
import praw
UA = 'ListFormatFixer praw demo, Created by /u/shaggorama'
r = praw.Reddit(UA)
inc = 0
res = 0
# Provide a descriptive user-agent string. Explain what your bot does, reference
# yourself as the author, and offer some preferred contact method. A reddit
# username is sufficient, but nothing wrong with adding an email in here.
# If you want the bot to be able to respond to people, you will need to login.
# It is strongly recommended you login with oAuth
# http://praw.readthedocs.org/en/stable/pages/oauth.html
# NB: This login method is being deprecated soon
r.login('get-a-way', 'nottellingyou')
for c in praw.helpers.comment_stream(r, 'all'):
inc = inc + 1
inc = inc % 4001
if check_condition(c):
# set 'respond=True' to activate bot responses. Must be logged in.
bot_action(c, respond=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment