Skip to main content

tweebot

Build Status

A twitter bot client, written in Python. This can be used as either a command-line tool, or as a library imported into your Python applications.

Requirements

  1. Python 3.3+

  2. A twitter account

Installation

To install:

make install

Development

To build the dev environment:

make venv
. venv/bin/activate
python main.py

Configuration

The application will only try to tweet if you provide a key file, which is formatted like:

CONSUMER_KEY: dsafsafafsd
CONSUMER_SECRET: iuhbfusdfiu44
ACCESS_KEY: vjhbv99889
ACCESS_SECRET: ivfjslfiguhg98

OR the equivalent JSON.

The filename must be provided using the --keys command-line argument.

Command-line usage

Tweeting

To tweet a simple status update:

tweebot --keys {twitter-key-file} tweet "Hello world, this is my Tweebot status update!" -vv

You can control verbosity with the number of vs.

More command-line options are possible, try --help to see them all.

If you use - for the tweet text, the application will use standard input, which can be handy for piping info from your bots – ie, use an arbitrary application to pipe to tweebot which can tweet it out.

Following

To automatically follow new followers, and unfollow unfollowers:

tweebot --keys {twitter-key-file} follow --auto

Library usage

There are two basic ways you can use this in a library: you can either import the TwitterClient class and control that from your application, or you can import tweebot’s main function and provide it with a callback that will generate your status updates.

tweebot.main

If you provide a callable to tweebot.main, then tweebot will use it as a callback when the main function is called. The main method implements all the command-line tweebot arguments, the difference is that if the program is asked to tweet an empty status, it will instead tweet the results of your method, called with no arguments. If you tweet a non-empty status, that string will be handed to your method, and the result will be tweeted:

mytweebot --keys {twitter-key-file} tweet -vv

Thus, this provides a simple way to define new twitter-bots: define a method of the form:

def my_tweet_builder(status, directives):
    new_status = do_something()
    return new_status
    # or
    return new_status, new_directives

This can either ignore the status it’s given, or use it in any way you wish. If you have multiple bots that modify the status when given, then you could run them independently, or pipe them together in novel ways without recompiling – your choice.

Direct client use

If you want your application to be in control, you can simply import tweebot.TwitterClient and use its methods directly. This includes direct API access (via tweepy) to twitter, and few custom, convenience methods.

Metadata

Release files for tweebot 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tweebot 0.2.1
File Size Uploaded Provenance Actions
tweebot-0.2.1.tar.gz 7.9 kB Without provenance Details for tweebot-0.2.1.tar.gz

Release files / tweebot-0.2.1.tar.gz

Download URL tweebot-0.2.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0cb906609c8d941577147c91fb5edf4a279b6eb15ed794d9302db199b8a1ccdf
BLAKE2b-256 checksum
How to use checksums
76df0d1d1d6130da126dedd65a0b803ec891f01322b8308d544b900ba20a4fb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for tweebot 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page