SHOW:
|
|
- or go back to the newest paste.
| 1 | import praw | |
| 2 | import config | |
| 3 | ||
| 4 | def bot_login(): | |
| 5 | print ("Logging in...")
| |
| 6 | r = praw.Reddit(username = config.username, | |
| 7 | password = config.password, | |
| 8 | client_id = config.client_id, | |
| 9 | client_secret = config.client_secret, | |
| 10 | user_agent = "kree's dog comment responder v0.1") | |
| 11 | print ("Successfullly logged in!")
| |
| 12 | ||
| 13 | return r | |
| 14 | ||
| 15 | def run_bot(r): | |
| 16 | for comment in r.subreddit('test').comments(limit=25):
| |
| 17 | if "dog" in comment.body: | |
| 18 | print ("String found!")
| |
| 19 | ||
| 20 | ||
| 21 | - | print("Hi there!")
|
| 21 | + | if __name__ == '__main__': |
| 22 | - | r = bot_login() |
| 22 | + | print("Hi there!")
|
| 23 | - | run_bot(r) |
| 23 | + | r = bot_login() |
| 24 | run_bot(r) | |
| 25 | ||
| 26 | //Terminal Output | |
| 27 | //Kevins-MacBook-Pro:Reddit_Dog_bot kevinlee$ python reddit_dog_bot.py | |
| 28 | //Kevins-MacBook-Pro:Reddit_Dog_bot kevinlee$ python reddit_dog_bot.py | |
| 29 | //Kevins-MacBook-Pro:Reddit_Dog_bot kevinlee$ python reddit_dog_bot.py | |
| 30 | //Kevins-MacBook-Pro:Reddit_Dog_bot kevinlee$ |