GithubHelp home page GithubHelp logo

sibelbd / internetlyingpolice_reddit_bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from antrikshy/internetlyingpolice_reddit_bot

0.0 0.0 0.0 186 KB

Sarcastic bot that replies when someone calls someone else out as a liar (documented for beginners).

License: MIT License

Python 100.00%

internetlyingpolice_reddit_bot's Introduction

/u/InternetLyingPolice

This is my first reddit bot. I created it to learn Python, PRAW and using APIs in general.

This is a simple example of a bot that scans all reddit comments as they come in. It looks for certain phrases in a comment (explained in the section "What it does") and makes a sarcastic reply.

Because this bot is built using PRAW (Python Reddit API Wrapper), it follows reddit's API guidelines automatically, not making too many API requests etc.

I have tried to document it so that it is easy for beginners to understand. I'm hoping that this code will be helpful to anyone learning to write their own first bot.

What it does

Sometimes on reddit, OP (Original Poster) is suspected of lying in their post. We see comments like "this never happened" or "OP is a big fat phony" or something like "would someone just go on the Internet and tell lies". These comments are references to popular TV shows like Family Guy and Arthur.

This bot scans for certain key phrases that suggest one of these references has been made and jumps into that thread, screaming that the Internet Police as arrived and the alleged liar should show themselves with their hands up.

It's a fun little project I did, and it might not be perfect because I'm only getting my feet wet. I would highly appreciate any improvements and pull requests.

How it works

This bot makes use of PRAW's comment_stream to continuously pull 1000 newest comments over and over in a forever loop. It scans each one using the list phrases_to_look_for. It runs until the program is interrupted manually.

The bot's authentication details (username/password) for login are stored in a very simple config file which I have not included in this repository. However, there's a description of how that works in the section "What you can do with this code".

What you can do with this code

You can feel free to fork this code, use it in your own bot, or whatever else you want to do with it.

Because this bot is open-source, I have not included the username and password for the reddit account in the code. Instead I put it into a .ini file which the bot reads when logging in.

If you were to run this bot on your computer, here's what you would do:

  • Install PRAW (along with Python, of course) because my bot needs its features to run.
  • Edit the policebot.ini.dist and rename it to remove the .dist. Add a reddit username and password in the placeholders.
  • Make changes on line 4 of InternetLyingPolice to point to the address of your .ini file.
  • Run the bot using this command from the directory you put it into: python InternetLyingPolice.py

Of course you shouldn't run this exact code from your computer without making any changes or we'll end up with two reddit bots doing the exact same thing and people will hate both of them.

Ways to help me out:

  • [High priority] The bot may sometimes comments twice (maybe when it looks at the same comment twice; stderr suggests that it scans the same batch over and over at times). Try to look for any logic problems with the green_light boolean. For now, repeat commenting is prevented by making the bot sleep for 15 seconds, which may also cause it to miss comments.
  • Make efficiency improvements in this program (I'm almost certain it looks at some comments twice because it doesn't sleep).
  • Add more common phrases to look for.
  • Maybe add a way to make the bot not comment when someone says "not saying OP is lying, but..."

internetlyingpolice_reddit_bot's People

Contributors

antrikshy avatar

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.