GithubHelp home page GithubHelp logo

maxgoldtbot's Introduction

MaxGoldtBot

This is a Reddit bot. It reads all submissions and comments from a subreddit and checks if they contain any links to bild.de. If so, the bot responds with the following quote from German writer Max Goldt:

Diese Zeitung ist ein Organ der Niedertracht. Es ist falsch, sie zu lesen. Jemand, der zu dieser Zeitung beiträgt, ist gesellschaftlich absolut inakzeptabel. Es wäre verfehlt, zu einem ihrer Redakteure freundlich oder auch nur höflich zu sein. Man muß so unfreundlich zu ihnen sein, wie es das Gesetz gerade noch zuläßt. Es sind schlechte Menschen, die Falsches tun.

The response comment will also contain archive.is versions of the linked bild.de articles, so that future readers are not forced to visit bild.de if they want to read the article.

This program is licensed under the MIT license, see the LICENSE file. To see what has changed over time, have a look at CHANGELOG.md.

Prerequisites

To run this bot, you will need:

  • Python 3 (tested with 3.5.2 and 3.4.2 on Ubuntu and Debian)
  • The following packages (install via pip / pip3):
    • archiveis (a simple wrapper for archive.is)
    • praw (the Python Reddit wrapper)

Setup

Rename the MaxGoldtBot.ini.sample file to MaxGoldtBot.ini. In this file, store the configuration values for your bot. See section Configuration for more information.

Running the Bot

To run the bot, simply call it with the name of a subreddit as an argument:

$ ./MaxGoldtBot.py MySubreddit

Running the bot as a systemd service

If you wish to run this bot as a systemd user service, modify [email protected] and fill in the relevant paths. Then copy the file to ~/.config/systemd/user/:

$ mkdir -pv ~/.config/systemd/user && cp [email protected] ~/.config/systemd/user/

If you wish to run this service on boot (e.g. not only when you are logged in), you need to enable lingering (see loginctl man page):

# loginctl enable-linger YOURUSERNAME

After that, you can enable the bot service for any subreddit with the following command:

$ systemctl --user enable [email protected]

To start the bot immediately, run:

$ systemctl --user start [email protected]

Command-line options

Configuration file

By default, the bot reads its configuration from MaxGoldtBot.ini in the current directory. However, you can pass any configuration file name you like to the --config option.

Logging

By default, the bot will log to standard output and only display messages with a loglevel of WARNING or above. Use --loglevel to change the minimum loglevel (possible values are DEBUG, INFO, WARNING, ERROR, CRITICAL).

If you wish to log messages into a file instead of standard output, you can pass a filename to the --logfile option.

Processed comments

The bot keeps a list of already processed comments to avert responding to any comments twice. By default, this list is stored in a file called processed_comments_SUBREDDIT.txt in the current directory. You can override the path to this file with the --procfile option.

Processed submissions

The bot also keeps a list of already processed submissions to avert responding to any submissions twice. By default, this list is stored in a file called processed_submissions_SUBREDDIT.txt in the current directory. You can override the path to this file with the --prosfile option.

Sleep time

When the bot gets an API exception from Reddit (e.g. because the bot is trying too hard or because there are connectivity issues), it will go to sleep for a while. By default, this sleep time is 15 minutes. However, you can override this time with --sleeptime SECONDS.

Configuration

The sample configuration file (MaxGoldtBot.ini.sample) should give you a good idea of what you need to configure to make this bot work. The configuration file should contain the following items in a section called [MaxGoldtBot]:

  • client_id -- this is the ID of your Reddit application. To obtain one, go to reddit.com > preferences > apps and create a new app of type "script". The client ID is displayed beneath your application's name.
  • client_secret -- this is the secret key of your Reddit application. Never let anyone see this! You can find it in the details of your app under reddit.com > preferences > apps.
  • user_agent -- this is a User-Agent string that the bot will provide to Reddit when making requests. The default sample is a good idea. Generally, the User-Agent string should have the following format: platform:tld.yourdomain.yourapp:vX.Y.Z (by /u/YourUsername)
  • username -- this is the username of your Reddit bot.
  • password -- this is your Reddit bot's password. Without it, the bot can read Reddit comments, but cannot reply to them.

Subreddit

This bot has its own subreddit where you can ask questions and make suggestions: /r/MaxGoldtBot

maxgoldtbot's People

Contributors

pille1842 avatar

Stargazers

Nikolaus Schlemm avatar Olaf Dimigen avatar  avatar  avatar Max Muth avatar Jakob avatar  avatar  avatar Albert Armea avatar Stefan R. Grotz avatar Lucas Werkmeister avatar

Watchers

James Cloos avatar Stefan R. Grotz avatar  avatar  avatar

Forkers

jonasschatz

maxgoldtbot's Issues

Ports for slack & rocketchat

First of all: great work, I love it.
It would be a great thing to let this bot live on other chat systems and social networks too. Slack suports bots written in python, so a port should be pretty easy and a bot for rocketchat could be possible as well. I will have a look at the issue and let you know how far I came. (I've never written a bot before) Is anyone else interested in a port?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.