Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/braun-steven/bottr
Python Reddit Bot Framework
https://github.com/braun-steven/bottr
bot praw reddit
Last synced: 3 months ago
JSON representation
Python Reddit Bot Framework
- Host: GitHub
- URL: https://github.com/braun-steven/bottr
- Owner: braun-steven
- License: mit
- Created: 2018-01-17T09:20:39.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-13T00:09:26.000Z (over 6 years ago)
- Last Synced: 2024-10-07T17:37:50.328Z (3 months ago)
- Topics: bot, praw, reddit
- Language: Python
- Homepage: https://bottr.readthedocs.io
- Size: 87.9 KB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=====
Bottr
=====Bottr makes writing bots for reddit easy. It currently provides three predefined bots:
:CommentBot: Listens to new comments in a list of subreddits
:SubmissionBot: Listens to new submission in a list of subreddits
:MessageBot: Listens to new messages of the inboxBottr makes use of the `Python Reddit API Wrapper`
`PRAW `_.Documentation: `bottr.readthedocs.io `_
Check out `bottr-template `_ for a convenient code template to start with.
Installation
------------
Bottr is available on PyPi and can be installed via.. code:: bash
$ pip install bottr
:Latest version: :code:`0.1.4`
Quick Start
-----------The following is a quick example on how to monitor `r/AskReddit` for new comments. If a comment
contains the string :code:`'banana'`, the bot prints the comment information.. code:: python
import praw
import timefrom bottr.bot import CommentBot
def parse_comment(comment):
"""Define what to do with a comment"""
if 'banana' in comment.body:
print('ID: {}'.format(comment.id))
print('Author: {}'.format(comment.author))
print('Body: {}'.format(comment.body))if __name__ == '__main__':
# Get reddit instance with login details
reddit = praw.Reddit(client_id='id',
client_secret='secret',
password='botpassword',
user_agent='Script by /u/...',
username='botname')# Create Bot with methods to parse comments
bot = CommentBot(reddit=reddit,
func_comment=parse_comment,
subreddits=['AskReddit'])# Start Bot
bot.start()# Run bot for 10 minutes
time.sleep(10*60)# Stop Bot
bot.stop()