- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| helpers | ||
| services | ||
| utils | ||
| ChatBot.py | ||
| LICENSE | ||
| obschatbot.py | ||
| README.md | ||
OBS Chat Bot (obschatbot)
A Twitch chat-bot that could directly interact with OBS Studio and Spotify. Please note this bot runs on broadcaster's side and is not hosted on a server.
Requirements
- python = 3.6
- requests
- websockets
Usage
Installation
Extract to your working directory, and import obschatbot.py in OBS-Studio Scripts window.
Configuration
Default messages (optional)
You can set some messages for your bot to answer to users in the chat.
- "Help message" will appear before the list of known commands
- "Unknown command message" will spawn if someone try an unknown command (starting with "!" but an unknown keyword)
- "Welcome message" will spawn when starting the bot
- "Farewell message" will appear when stopping the bot
Backend (mandatory)
"Channel" is your Twitch streaming channel name.
"Username" is the bot's username (currently only working with the streamer username).
"Client ID" is the app generated client ID, you'll have to register an app in your dev dashboard in order to use it (https://dev.twitch.tv/console)
"Client secret" is the app generated client secret, you'll have to generated it for your app in the dev dashboard.
Services (optional)
Services are optional sets of commands for your bot, you can enable them by ticking the checkbox for each of them when the bot is offline.
Command Service
This service allows your bot to receive custom commands. Only moderators and broadcasters can define them.
The custom commands are stored in a text file, defined in the "Commands list" field.
adding a command
!cmd add <command name> <printed text>
"add", "edit" and "update" have the same results.
"<command name>" with or without the "!" (exclamation mark) character will have the same result. Custom commands are always used with the "!" prefix.
"<printed text>" is the text returned by the custom command. It can support multiple arguments, for instance:
!cmd add !so Shout out to {1} for being an awesome person, please visit https://twitch.tv/{1}where {1} will be replaced by the first argument following the custom command, like in "!so kholo" will result in "Shout out to kholo for being an awesome person, please visit https://twitch.tv/kholo" (I'm kholo by the way :D ) (and I... may... be that awesome! Who knows?)!cmd add !vs Hey look out, {1} and {2} are fighting! Taking the bets!where {1} will be replaced by the first argument, {2} by the second argument, and so on. "!vs kholo anonlogics" will result in "Hey look out, kholo and anonlogics are fighting! Taking the bets!" (anonlogics is my bot, powered by the very current script) (and I think it will beat the hell out of me)
It also supports multiple responses, separated with "||" (two vertical bars), that will be returned randomly when invoking the custom command, for instance:
!cmd add !dance (_\_) (_|_) (_/_)||\o\ |o| /o/ will make the "!dance" command returns either "(_\_) (_|_) (_/_)" or "\o\ |o| /o/"
removing a command
!cmd del <command name>
"del", "delete" and "remove" have the same results.
custom commands
Added commands are triggered by calling their name prefixed with a "!" (exclamation mark) character, and can receive arguments if defined in the .
Dice Service
This service allows your viewers to roll dices in your chat room.
rolling a dice
!<n>d<f>
where is the number of dices to roll, and the number of faces per dice. For instance: !5d6 will roll five dices with six faces each.
getting the last roll resuls
!lastrolls
This command prints the last rolls for every viewer in the chat room who has rolled dices.
clearing the last roll results
!clearlast
This command clears the last rolls for every viewer in the chat room.
Timed Message Service
This service allows your moderators as well as yourself to add some messages that will spawn every n minutes, like reminders or self-promotion for your social networks…
When two or more messages have the same interval, a 2 minutes offset will be iteratively added to each of them in order to avoid them to spawn at the same time.
adding a timed message
!addmsg <identifier> <interval> <message>
where <identifier> is a unique keyword, which could be use to further delete the message if needed ; <interval> is the interval in minutes before the message spawn again ; and <message> is the full message you want to display.
deleting a timed message
!delmsg <identifier>
where <identifier> is the unique keyword identifying the message
listing all the messages set
!listmsg
this will list all the identifier currently set.
Start and stop
Simply use the "Start Bot" and "Stop Bot" buttons!
Current status
The bot is fully working as is, however no error or exception are currently catched.
Interaction with OBS is in progress (Manager Service) and, as far as I can tell, fully working (can switch scenes, toggle sources visibility, mute, unmute and change volume for audio sources) however source visibility toggling is currently making my OBS crash if used more than twice. As I'm only using OBS API, I'm not sure this is related to my script, maybe a bug in OBS or with my OS/computer. This service will need to be tested a bit more before being pushed in the repository.