ROS Package tioros
TwitchIO ROS Chatbot Nodes. A ROS 2 - Twitch Chat Bridge.
Installation Prerequisites
Use the package manager pip3 to install the below dependencies.
pip3 install twitchio requests
Setup Package
# run in your ros2_ws/src folder
git clone https://github.com/bob-ros2/tioros.git
cd ..
colcon build --packages-select tioros
. install/setup.bash
Authentication Methods
There are two primary ways to authenticate with Twitch, depending on the node you are using. You can store both in a unified ~/.credentials file:
OAuth Flow (Traditional IRC Chatbot):
What is it?: A single long-living Access Token.
Storage: A plain text file containing just the token (e.g.,
oauth:xxxxxxxxxxxxx) OR aaccess_tokenfield in a JSON file.Usage: Standard for sending/receiving chat messages.
Env Var:
TIOROS_TOKEN(direct token) orTIOROS_CREDENTIALS(path to file).
App Credentials (EventSub Node):
What is it?:
client_id,client_secretand arefresh_token.Storage: A JSON file (recommended for automation with
auth.py).Example
.credentials(JSON):{ "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET", "refresh_token": "YOUR_REFRESH_TOKEN", "access_token": "YOUR_CURRENT_OAUTH_TOKEN", "webhook_secret": "YOUR_WEBHOOK_SECRET", "callback_route": "https://your.callback.url/path" }
Usage: Required for rich events (follows, raids).
ROS Node: chatbot
Usage
# Set token directly via environment variable
export TIOROS_TOKEN=oauth:xxxxxxxxxxxxxx
ros2 run tioros chatbot --ros-args -p channel:=myTwitchTv
# Or use a credentials file (Smart Load: supports plain text or JSON field)
export TIOROS_CREDENTIALS=~/.credentials
ros2 run tioros chatbot --ros-args -p channel:=myTwitchTv
Supported TwitchIO Events
The following received Twitch events are published as std_msgs/String messages.
event_ready:
event_ready %user_id %nickevent_join:
event_join 0 %user_name(Note: User ID 0 is used to avoid Twitch API rate-limiting during high traffic)event_message:
event_message %user_id %author_name %message_content
Node Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Twitch channel to join. (Env: |
|
string |
|
Direct Twitch Access Token. (Env: |
|
string |
|
Path to credentials file (plain or JSON). (Env: |
|
string |
|
Frame ID for published messages. (Env: |
|
string |
|
Command prefix for the bot. (Env: |
Topics
Subscribed:
chat_input(std_msgs/String) - Messages to send to Twitch.Published:
chat(std_msgs/String) - Raw chat events.Published:
json(std_msgs/String) - Structured event data.
ROS Node: eventsub
This node uses the Twitch EventSub extension for rich event tracking (follows, raids, etc.).
Usage
export TIOROS_CREDENTIALS=~/.credentials
ros2 run tioros eventsub --ros-args \
-p channel:=myChannelName \
-p broadcaster_id:="'123456'"
Node Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Twitch channel name. (Env: |
|
string |
|
The numeric Twitch ID of the broadcaster. (Env: |
|
string |
|
The numeric Twitch ID of the moderator account. (Env: |
|
string |
|
Path to JSON file with API credentials. (Env: |
|
int |
|
Port for incoming webhook notifications. (Env: |
|
bool |
|
If true, disables automated “Thank you” messages in chat. (Env: |
|
string |
|
Frame ID for message headers. (Env: |
Topics
Published:
eventsub(std_msgs/String) - Human-readable event string.Published:
json(std_msgs/String) - Structured event data.
ROS Node: filter
Usage
# Use a whitelist and regex substitution
ros2 run tioros filter --ros-args \
-r chat:=/chat_source \
-p "substitute:=['^[^ ]+ [^ ]+ ([^ ]+) (.*)', '\\1: \\2']"
Node Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
string array |
|
Comma-separated list for whitelist rules. (Env: |
|
string array |
|
Comma-separated list for blacklist rules. (Env: |
|
string |
|
Path to YAML file with whitelist regex. (Env: |
|
string |
|
Path to YAML file with blacklist regex. (Env: |
|
string array |
|
Regex pairs: |
Topics
Subscribed:
chat(std_msgs/String) - Incoming chat messages.Published:
chat_filtered(std_msgs/String) - Messages passing filters.Published:
rejected(std_msgs/String) - Blocked messages.
Tool: AUTH
Simple Twitch authentication and token management.
Usage
# Help output
ros2 run tioros auth -h
# Generate token from refresh token
ros2 run tioros auth -f ~/.credentials -r YOUR_REFRESH_TOKEN