GithubHelp home page GithubHelp logo

frisnit / congratsbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hepwori/congratsbot

0.0 2.0 0.0 6 KB

A Twitter bot with the mission of congratulating those being congratulated

Python 100.00%

congratsbot's Introduction

congratsbot

A Twitter bot with the mission of congratulating those being congratulated.

Notes

This is the code which powers @congratsbot. You can read its birth story at https://medium.com/@isaach/the-birth-of-congratulatron-ba9fb313e543.

It uses the Twitter Streaming API to gather all tweets containing the words 'congrats' or 'congratulations'. It discards those which aren't replies; with the remainder it tallies up which tweets are being replied to with messages of congratulations. When it sees a tweet which has garnered five congratulatory replies it throws in its own congrats (with a few heuristically determined exceptions).

Some things:

  • obviously the reply_count dictionary grows without limit. In practice the bot will stall (see below) before that becomes an issue. Nonetheless it'll probably offend your sense of properness like it does mine;
  • by design the bot shrugs at most exceptions and just moves on. The main priority of the bot is staying connected to the stream and processing messages as best it can;
  • we start the bot with a blacklist of users comprising those which have been recently @-replied. Ideally this blacklist would expire; in practice, though, it mostly doesn't matter because of stalls;
  • the Twitter stream will occasionally "stall", ie. remain connected but deliver no more messages. I use an external process to monitor this condition and restart the bot as necessary; and finally
  • this is the most Python I've ever written in one place. I'm keen to learn about Pythonic idioms I missed, and so much more, but be gentle.

Some ideas:

  • this thing obviously generalizes into a "wtf-bot" or a "omg-bot". From my early tinkering these seem harder to get right (require more heuristics) but are perfectly within reach; and
  • bot-as-a-service.

Important

Twitter bots which spend their life @-replying users who aren't following them enjoy a precarious existence on Twitter—this is a behavior pattern which, surprise surprise, looks like spam. If users commonly mark you as spam, or block you, you will get suspended. Be respectful, delightful, and fun… and perhaps you won't.

congratsbot's People

Contributors

hepwori avatar

Watchers

 avatar  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.