Skip to main content

Simple Reddit Bot Library

Project description

Bottr makes writing bots for reddit easy. It currently provides two predefined bots:

CommentBot:

Listens to new comments in a list of subreddits

SubmissionBot:

Listens to new submission in a list of subreddits

Bottr makes use of the Python Reddit API Wrapper PRAW.

Documentation: bottr.readthedocs.io

Check out [bottr-template](https://github.com/slang03/bottr-template) for a convenient code template to start with.

Installation

Bottr is available on PyPi and can be installed via

$ pip install bottr

Quick Start

The following is a quick example on how to monitor r/AskReddit for new comments. If a comment contains the string 'banana', the bot replies 'This comment is bananas.'

import praw
import time

from bottr.bot import CommentBot

def parse_comment(comment):
    """Define what to do with a comment"""
    if 'banana' in comment.body:
        comment.reply('This comment is bananas.')

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bottr-0.1.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

bottr-0.1.4-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file bottr-0.1.4.tar.gz.

File metadata

  • Download URL: bottr-0.1.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bottr-0.1.4.tar.gz
Algorithm Hash digest
SHA256 af897583a8d599e25dac6433e3c9930f98d3d190f9cc8310d09c95a7a139ac4b
MD5 06f5eb0152a39e89a11468c4055a53f3
BLAKE2b-256 0036d9544cf3002d456848a45bcc18ea5f1fdec0fd6d95113ca9069201a546e0

See more details on using hashes here.

File details

Details for the file bottr-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for bottr-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1eb249e940658906b494fdf096abc5f8f084bc2f714345dffc3f3963951873bd
MD5 c47443c3d2764e71608fd62a2e84d553
BLAKE2b-256 6aaecc6d7707e3222fc79422738ced52b6e7a14e39d60451b43d9cff4f702417

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page