A simple framework for building robust social media bots for multiple networks
Project description
Polybot
Polybot is a simple framework for building robust social media bots for multiple networks in Python.
Features
- Automatically post to X/Twitter, Mastodon, Bluesky.
- A friendly command-line setup interface to handle the authentication hassle for you.
- Automatic state persistence - just put your state in the
self.statedict and it'll get saved/restored across runs.
X/Twitter support is no longer regularly tested as the authors no longer use it. Reliability can't be guaranteed but pull requests are welcome.
Limitations/Wishlist
- Polybot currently doesn't have support for receiving messages, so it's only useful for post-only bots.
Getting started
from polybot import Bot
class HelloWorldBot(Bot):
def main(self):
while True:
self.post("Hello World")
sleep(300)
HelloWorldBot('helloworldbot').run()
To configure the accounts the bot uses, just run:
./helloworldbot.py --setup
You'll be guided through authenticating and a config file will be automatically created.
Use the --profile [name] to save and use a specific state/config.
By default, the bot will run in development mode, where it doesn't actually post to services. To run
in live mode, pass the --live flag.
Images
One or more images can be attached by creating an Image object, which can be
created from a path, a file object, or bytes.
from polybot import Image
self.post("Hello World",
images=[Image(path="/path/to/image", mime_type="image/png", description="Alt text")]
)
Images are automatically resized to below the maximum allowable size on each platform.
Handling post length limitations
Services have differing post length limits, so a list of messages can be passed to the post method,
and Polybot will choose the longest message which is supported by each configured service.
self.post(["This is a short message", "This is a much longer message......"])
Alternatively, the wrap argument can be used to split a message into multiple posts:
self.post("Long message...", wrap=True)
State management
Polybot provides a dictionary at self.state where your bot can store any data which needs to be
persisted, to avoid repeating posts.
The state dictionary is serialised to a file called <bot_name>.state in the local directory.
This automatically happens when the process is terminated, but you can also trigger this
by calling self.save_state().
Bots which use Polybot
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polybot-0.9.0.tar.gz.
File metadata
- Download URL: polybot-0.9.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c50896192dac01f81950074dfca9cd874522ebb599297864bad1b4d7022e46f3
|
|
| MD5 |
b24226eb6b439e2e196652c1ca1c17c9
|
|
| BLAKE2b-256 |
b1ee8b712ee72b4668ce72a006f23c8e758c3d3fc3a984afb462046a59c9e000
|
Provenance
The following attestation bundles were made for polybot-0.9.0.tar.gz:
Publisher:
publish.yml on russss/polybot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polybot-0.9.0.tar.gz -
Subject digest:
c50896192dac01f81950074dfca9cd874522ebb599297864bad1b4d7022e46f3 - Sigstore transparency entry: 153115634
- Sigstore integration time:
-
Permalink:
russss/polybot@a040f73fc93092d88e75d2c935e99137e1c25e8c -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/russss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a040f73fc93092d88e75d2c935e99137e1c25e8c -
Trigger Event:
release
-
Statement type:
File details
Details for the file polybot-0.9.0-py3-none-any.whl.
File metadata
- Download URL: polybot-0.9.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eb7ac756775fe1975726ba6a5499e3e12640996017145846f76d4361f0d9533
|
|
| MD5 |
20bc4a192308fe69e63b7e55c2ae2675
|
|
| BLAKE2b-256 |
bb72062368de74c9f7ad77f6e472b9f87c5205fb7afefbb497ca98f02cdc4773
|
Provenance
The following attestation bundles were made for polybot-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on russss/polybot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polybot-0.9.0-py3-none-any.whl -
Subject digest:
6eb7ac756775fe1975726ba6a5499e3e12640996017145846f76d4361f0d9533 - Sigstore transparency entry: 153115637
- Sigstore integration time:
-
Permalink:
russss/polybot@a040f73fc93092d88e75d2c935e99137e1c25e8c -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/russss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a040f73fc93092d88e75d2c935e99137e1c25e8c -
Trigger Event:
release
-
Statement type: