teamtalkbot/README.md
Umiko f0cedb1dff
Some checks are pending
Build-nightly / docker (push) Waiting to run
pushing new things, changelog.txt might help.
2025-05-14 04:00:49 +07:00

170 lines
6.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TTMediaBot
A media streaming bot for TeamTalk.
## Installation and usage
### Requirements
* To use the bot, you need to install Python 3.7 or later;
* The bot requires the TeamTalk SDK component to be downloaded using the integrated tool from the command line. In order to download and extract the mentioned component, on Linux, you need to install p7zip or p7zip-full, or if you want to run the bot on Windows, 7Zip must be installed;
* If you are going to use Linux as your main system for a bot, you will need pulseaudio and libmpv to route and play audio, but if you re using Windows, PulseAudio is not available, so you will need a virtual audio cable driver, such as VBCable and of course, the mpv player library must also be installed. on Windows this library can be installed using an integrated tool. On Debian-based systems the required package is libmpv1.
### Installation
* Download TTMediaBot;
* install all python requirements from requirements.txt, using the "pip3 install -r requirements.txt" or just "pip install -r requirements.txt" command, without quotes;;
* Run ttsdk_downloader.py from the tools folder;
* If you're using Windows run libmpv_win_downloader.py from the tools folder;
* Copy or rename config_default.json to config.json;
* Fill in all required fields in config.json (Config description will be there later);
* On Linux run TTMediaBot.sh --devices to list all available devices and their numbers;
* On Windows run TTMediaBot.py --devices to list all available devices with their numbers;
* Edit config.json (change device numbers appropriately for your purposes);
### Usage
* On Linux run ./TTMediaBot.sh;
* On Windows run python TTMediaBot.py directly.
## Scheduler Commands
TTMediaBot includes a built-in scheduler system (like `cron`) that allows you to schedule bot commands to be executed automatically at specific times.
### Enable or disable the scheduler
```bash
cr toggle
```
Use this to turn the scheduler **on or off**. It must be enabled before any scheduled tasks can run.
---
### Add a scheduled command
```bash
cr add <cron expression>|<command>
```
This adds a new scheduled task. The command should be split using `|`:
* The **left side** is the cron time expression.
* The **right side** is the bot command to run.
#### Examples:
```bash
cr add */15 * * * *|p something just like this
```
Every 15 minutes, the bot will play the song **"Something Just Like This"** using the `p` command.
```bash
cr add 0 3 * * *|rsrs
```
Every day at 3:00 AM, the bot will **restart itself** using the `rsrs` command.
---
### Remove a scheduled command
```bash
cr rm <task number>
```
Removes a task from the scheduler. You can find the task number using `cr ls`.
Example:
```bash
cr rm 1
```
This removes task number 1.
---
### View all scheduled tasks
```bash
cr ls
```
This command shows all currently scheduled tasks, including:
* Cron expression
* Command
* Last run time
* Next run time
---
### Cron Expression Guide (Quick)
### 📝 Cron Expression Guide (Quick)
| Field | Allowed Values | Description |
|---------------|---------------------------|-----------------------|
| Minute | 059 | Minute of the hour |
| Hour | 023 | Hour of the day |
| Day of month | 131 | Day of the month |
| Month | 112 | Month of the year |
| Day of week | 06 or SunSat | Day of the week |
**Example:**
- `*/10 * * * *` → Every 10 minutes
- `0 9 * * 1-5` → At 9:00 AM, Monday to Friday
For example:
* `*/10 * * * *` = every 10 minutes
* `0 9 * * 1-5` = every weekday at 9:00 AM
### Running in Docker
You can also run the bot in a Docker container.
First of all, You should build an image from the provided Dockerfile:
```sh
docker build -t ttmediabot .
```
Note: The first run could take some time.
Then you can run the Docker container with the following command:
```sh
docker run --rm --name ttmb_1 -dv <path/to/data/directory>:/home/ttbot/data ttmediabot
```
<path/to/data/directory> here means a directory where config.json file will be stored. It should not contain any other unrelated data.
The cache and log files will be stored in the specified directory.
## Startup options
* --devices - Shows the list of all available input and output audio devices;
* -c PATH - Sets the path to the configuration file.
## Config file options
* language - Sets the bot's interface language. Warning! to select a language you need an appropriate language folder inside the "locale" folder;
* sound devices - Here you have to enter audio device numbers. Devices should be connected to each other (like Virtual audio cable or pulseaudio);
* player - This section sets the configuration for the player such as default volume, maximum volume, etc;
* teamtalk - here are main options for bot to connect and login to your TeamTalk server;
* Services - Here you should configure available services for music search and playback;
* logger - Here you can configure various logging related options.
## Pulse audio or VB cable settings
### Linux variant
* Install pulseaudio.
* type $pulseaudio --start
* Next command creates null sink and this sink can be monitored by default pulse input device.
$pacmd load-module module-null-sink
* then run ./TTMediaBot.sh --devices and check its numbers.
output should be null audio output, input should be pulse.
* put this numbers to your config.json.
### windows variant
* install VB-cable, run "TTMediaBot.py --devices" and check numbers of VB-cable devices
* put this numbers to your config.json.
## Some notes about the Windows variant
* When listing input and output devices in the Windows variant of TTMediaBot, please note, that the input device will be doubled, i.e., if the output device is line 1 with number 3, the input device for line 1 will be listed twice, at number 5 and, for example, at number 7.
* The correct number will be the last one as input, that is, if we selected the output as line 1 with the number 3, the input device would be line 1 with number 7 of the two options, number 5 and number 7.
* The same method applies to all numbers and all Input / Outputs.
# support us
* paypal: https://paypal.me/rafli23115
# contacts
* E-mail: rafli@techlabs.lol