Last active
February 7, 2017 16:37
-
-
Save arshbot/23121e5f91d91a462f150db7d68e68cd to your computer and use it in GitHub Desktop.
Dynamic pugbomb for chatbot's in python. Uses reddit api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| #Created by Harsha Goli | |
| #Remember to register your script with reddit at https://ssl.reddit.com/prefs/apps | |
| #You will use those credentials and input them in the praw.Reddit() parameters. Your script will fail otherwise. | |
| import praw | |
| #pug bombs the chat and destroys this poor bot's soul | |
| def pugbomb(response, args): | |
| #gets the number | |
| #num = [int(s) for s in response["text"].split() if s.isdigit()] | |
| payload = int(args[0]) | |
| #Uncomment these lines if you'd like a limit on the intensity of the bomb | |
| #if payload > 10: | |
| # payload = 10 | |
| reddit = praw.Reddit(client_id='<client_id>', | |
| client_secret='<client_secret>', | |
| user_agent='my user agent', | |
| password='<password>', | |
| username='<username>') | |
| pug_urls=[] | |
| for submission in reddit.subreddit('pugs').hot(limit=payload): | |
| pug_urls.append(submission.url) | |
| return pug_urls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment