Chatto
A unified API wrapper for YouTube and Twitch chat bots.
CPython versions 3.8 through 3.10 and PyPy version 3.8 are officially supported.
Windows, MacOS, and Linux are all supported.
Installation
To install the latest stable version of Chatto:
pip install chatto
# If you need types:
pip install "chatto[types]"
To install the latest development version:
pip install git+https://github.com/parafoxia/chatto
You may need to prefix these commands with a call to the Python interpreter depending on your OS and Python configuration.
Setup
Before you begin, you will need to have a Google Developers project with the YouTube Data API V3 enabled. You need an API key, and if you want to send and delete messages, you will need an OAuth client ID.
I made a video walking through all the necessary steps.
Creating a YouTube bot
To create a simple YouTube bot, you could do something like this:
import os
from chatto import YouTubeBot
from chatto.events import MessageCreatedEvent
bot = YouTubeBot(
# Your project's API key.
os.environ["API_KEY"],
# The ID of the channel whose stream you want to connect to.
os.environ["CHANNEL_ID"],
# Your OAuth client ID secrets file.
secrets_file="secrets.json",
)
# Listen for MessageCreatedEvents, and run this awaitable whenever a
# new message is received.
@bot.listen(MessageCreatedEvent)
async def on_message_created(event):
# Ignore messages sent by the broadcaster.
if event.message.channel.is_owner:
return
# Respond to messages starting with "!hello".
if event.message.content.startswith("!hello"):
await bot.send_message(f"Hi {event.message.channel.name}!")
if __name__ == "__main__":
# This is blocking, so should be the last thing you call.
bot.run()
Chatto relies on the /search endpoint to find a live broadcast from a channel, which is not 100% reliable. If you are having major issues getting Chatto to find your channel's live stream, you can pass the stream ID directly:
bot.run(with_stream_id=os.environ["STREAM_ID"])
If you don't want to use OAuth, you can launch Chatto in read-only mode. Note that your bot will not be able to send or delete messages in this mode:
bot.run(read_only=True)
To learn how to make more advanced bots, check the documentation.
Creating a Twitch bot
Twitch bots are not yet supported.
Contributing
Contributions are very much welcome! To get started:
- Familiarise yourself with the code of conduct
- Have a look at the contributing guide
License
The Chatto module for Python is licensed under the BSD 3-Clause License.
Metadata
Release files for chatto 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chatto-0.5.0.tar.gz | 18.8 kB | Without provenance | Details for chatto-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chatto-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for chatto-0.5.0-py3-none-any.whl |
Total release size: 46.4 kB
Release files / chatto-0.5.0.tar.gz
| Download URL | chatto-0.5.0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a8ebabc0ff059ce36801b13a970c34990b7d0acefbad1ad73615d1f1137f705
|
|
BLAKE2b-256 checksum How to use checksums |
33056fdc3202dd970c772f6b6ea65449d8edc38e9c9327305fff35aa2076ce12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
|
Release files / chatto-0.5.0-py3-none-any.whl
| Download URL | chatto-0.5.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8488c737c22063bb9e51d9c02fdabc6607513d016f48248be7a426c090e1bac
|
|
BLAKE2b-256 checksum How to use checksums |
ed3d776cae0a9c15d2417381238c55cedb55955e303d58d9d6c1df4ea6823b0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
|
Security for chatto 0.5.0
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.