Git Product home page Git Product logo

blabbr's Introduction

Blabbr

blabbr is a bot that tweets randomly-generated texts using Markov chains.

Setup

pip install blabbr

Then follow the interactive setup:

blabbr setup

You can also initialize a configuration file with blabbr config init then fill it by hand. Check the Config section below for more info.

Run

Running a bot with blabbr is done in two steps: first, feed the model. Then, use that model to generate tweets.

You can feed your model either from Twitter using a few users as a seed or from a file that contains one tweet per line:

# feed from Twitter
$ blabbr populate

# feed from a file
$ blabbr populate --from-raw mytweets.txt

You can also retrieve tweets in a file instead of feeding them directly to the model. This is useful in combination with --from-raw to check the tweets before feeding them:

# append tweets to tweets.txt, one per line
$ blabbr populate --raw tweets.txt

By default the model is stored in blabbr.json in the current directory. You can change that by using the --model option:

$ blabbr --model mymodel.json populate

Populating an existing model doesn’t erase its previous content.


Once you’re happy with your model run it:

blabbr run

The default bot follows a few rules to behave well with its human friends:

  • It doesn’t tweet during the night
  • It tweets less during work hours
  • It never tweets more than twice in a couple of minutes

Config

A bot needs a configuration file to run. By default it tries to find blabbr.cfg in the current directory and fallback on ~/.blabbr.cfg. You can give a custom path with --cfg <path>.

The default config file looks like this:

[seeds]
screen_names = 

[auth]
token = 
consumer_secret = 
consumer_key = 
token_secret = 

[bot]
timezone = Europe/Paris
unfollow = True
retweet = True
lang = en
like = True
follow = True
  • seeds.screen_names should be a comma-separated list of Twitter usernames. Those are used as seeds to retrieve tweets. By default it fetches their last 1000 tweets then check 10 of the users they follow and so on. See blabbr populate --help for more info on how to change that behavior.
  • auth.token and similar keys are needed for the Twitter API. Run blabbr setup --help for more info.
  • bot.timezone is the bot’s timezone. This is important so that it doesn’t tweet in the middle of the night.
  • bot.lang is used to filter tweets when populating the model.
  • bot.follow and other boolean options are flags to enable/disable some of the bot's actions. Right now only the tweet feature is implemented.

A few more variables can be set:

  • bot.screen_name: Your bot's screen name. It’ll be automatically set if you use blabbr setup. This is used to save an API call when the bot needs to know its own name, in order to e.g. filter out its own tweets from its home timeline.

You can print your configuration with blabbr config. Use --cfg to specify another path:

$ blabbr --cfg ~/.config/blabbr.cfg <command> [options...]

Check your authentication configuration with blabbr setup --check.

Limitations

The most notable limitation right now is that you have to build the model before running the bot. It’d be a lot more interesting if it could feed its model in (near-)real-time.

Additionally, I made this toolkit for my own usage and thus it’s best suited for tweets in French. It’ll work for other languages but the text cleaning step won’t be as good.

blabbr's People

Contributors

bfontaine avatar

Watchers

 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.