Skip to main content

A Python framework for easily creating Mastodon bots with pluggable content generation and filtering capabilities

Project description

RoboTooter

A Python framework for easily creating Mastodon bots with pluggable content generation and filtering capabilities.

Features

  • Multiple Bot Types: Currently supports Markov chain-based text generation
  • Flexible Filtering: Extensible filter system for processing input text (Gutenberg, blank line removal, paragraph combining)
  • Mastodon Integration: Built-in support for posting to Mastodon instances
  • CLI Interface: Easy-to-use command line interface for bot management
  • Configuration Management: Simple bot configuration and data management

Installation

This project uses Poetry for dependency management. To install:

git clone <repository-url>
cd robotooter
poetry install

Quick Start

  1. Configure the framework:

    robotooter configure
    
  2. Create a new bot:

    robotooter create-bot
    
  3. Set up your bot's data (for Markov bots, add a sources.txt file to the bot directory):

    robotooter --bot <bot-name> setup
    
  4. Authorize your bot with Mastodon:

    robotooter --bot <bot-name> authorize
    
  5. Generate content locally:

    robotooter --bot <bot-name> speak
    
  6. Post to Mastodon:

    robotooter --bot <bot-name> toot
    

Bot Types

Markov Bot

The Markov bot generates text using Markov chains trained on source material.

Setup Requirements:

  • Create a sources.txt file in your bot's working directory
  • Each line should contain a URL to a text file to use as training data
  • Run robotooter --bot <bot-name> setup to download and process the sources

CLI Commands

  • robotooter info - Display information about the local setup
  • robotooter configure - Initialize configuration
  • robotooter create-bot - Create a new bot
  • robotooter --bot <name> setup - Download and process bot training data
  • robotooter --bot <name> authorize [--force] - Authorize bot with Mastodon
  • robotooter --bot <name> speak [--count N] - Generate content locally
  • robotooter --bot <name> toot - Generate and post content to Mastodon

Project Structure

src/robotooter/
\x00\x00 bots/           # Bot implementations
   \x00\x00 base_bot.py # Base bot class
   \x00\x00 markov/     # Markov chain bot
\x00\x00 cli/            # Command line interface
\x00\x00 filters/        # Text processing filters
\x00\x00 mastodon_manager.py  # Mastodon API integration
\x00\x00 models.py       # Data models
\x00\x00 util.py         # Utility functions

Development

Requirements

  • Python 3.12+
  • Poetry for dependency management

Development Setup

poetry install --with dev

Running Tests

poetry run pytest

Code Quality

The project uses Ruff for linting and MyPy for type checking:

# Linting
./scripts/lint

# Type checking  
./scripts/type

Dependencies

  • requests: HTTP client for downloading source material
  • markovify: Markov chain text generation
  • mastodon.py: Mastodon API client
  • pydantic: Data validation and settings management
  • jinja2: Template engine

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See the LICENSE file for details.

The AGPL-3.0 is a copyleft license that requires anyone who distributes the code or runs it on a server to make the source code available under the same license terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotooter-0.2.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotooter-0.2.0-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file robotooter-0.2.0.tar.gz.

File metadata

  • Download URL: robotooter-0.2.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/24.6.0

File hashes

Hashes for robotooter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2e21efda1ce4971b538ca1354481f1a6e0cb0f1e17e3712567fbaf9f0f3cd4e2
MD5 95731e4357189578efeb6d99779c067c
BLAKE2b-256 b4709f65a9c735a53fb47452eb695d76d0dd6b50d56f16b02669037ec89f812e

See more details on using hashes here.

File details

Details for the file robotooter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: robotooter-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/24.6.0

File hashes

Hashes for robotooter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68240824206d81672d14b7159699717a2fe31709aeb9b3b6f0dcdfea29d3da1e
MD5 aec2e763d05f24255fc0db1d977ad84a
BLAKE2b-256 8aa5f6e3c167059825ad557f5e6fc9551c776077bc85c07d647aac36be13708b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page