This bot was created for use with Telegram. This is for the Offical CheerLights Bot.
It will allow you to get the current color and set a new color.
The following are the commands the bot will recognize.
Command | Description | Example |
---|---|---|
/start | Displays the starting Keyboard to select functions with | /start |
1) Obtain API Keys 2) Clone Repo 3) Set Connection Configuration 4) Install Dependencies a) install library dependencies (if not running in Docker) b) Build container (if using Docker) 5) Start Script a) Use run scripts below (if not running in Docker) b) Start Container (if running in Docker)
Remember that all the commands shared here are for Linux. So if you want you can run this on a Linux Server or even a Raspberry Pi.
If you want to run this on a Windows or Mac machine, you will need to install Python3 and be familiar installing from a requirements.txt.
The first step in this process will be obtaining the API keys that you need. Some of the services you choose to use may take a couple of days to approve the access to their API's, so you will want to start this step before installing the script. That way when you are done installing the script and are ready to configure, you have everything ready to go.
Once you have the token you need, you will eventually copy them into the appropriate places in the config.json
file, but now we need to get the files and get things installed.
The next step is installing the needed packages, cloning the repo to get the script and then installing the needed libraries for the script to work properly.
There are two methods to run this script, Manually (bare metal essentially) or in Docker (Recommended)
If you choose to not run this in Docker, you will need to take some steps to get this script installed. First we need to install some additional programs and the libraries that the script needs.
Please run the following commands:
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade
sudo apt-get install python3 python3-pip git screen
git clone https://github.com/cheerlights/cheerlights-telegram
cd cheerlights-telegram
pip3 install -r requirements.txt
Now you have everything installed and are ready to configure the script. See the configuarion steps below.
To run using Docker, it is assumed you already have Docker and Docker compose installed on a host and working. There are plenty of installation instructions online to get Docker working.
Please run the following commands:
git clone https://github.com/cheerlights/cheerlights-telegram
cd cheerlights-telegram
pip3 install -r requirements.txt
Then edit the docker-compose.yaml
file in the repository.
Change the path under the volume that says /path/to/
to the actual path where you have the bot directory at and save the file.
Once you have done that, you will need to edit the config.json
file and configure the following:
{
"logging_enabled": true,
"msg_wait_time": 30,
"telegram": {
"token": "TELEGRAM BOT TOKEN HERE"
},
"cl_wh": "CL WEBHOOK HERE",
"wh_user": "CL WEBHOOK USER HERE",
"wh_password": "CL WEBHOOK USER PASSWORD HERE",
"database": {
"rdbms_type": "mssql",
"credentials": {
"username": "DB USER NAME HERE",
"password": "DB PASSWORD HERE",
"host": "DB HOST HERE",
"db": "LOGGING DB NAME HERE"
}
}
}
logging_enabled
: This is True
or False
. If True it is enabled and will log all messages sent through the bot. This does require a database system for this to work. Supported Databases are below.msg_wait_time
: This is the amount of time (in seconds) to delay letting a user send a message. This is to help with spamming.Telegram
: This section is Telegram Settings.
Token
: This is the bot token gotten from BotFather.cl_wh
: This is the CheerLights Processor Webhook.wh_user
: Webhook User Namewh_password
: Webhook Passworddatabase
: This is the database connection configuration for logging.
rdbms_type
: this is the database system type. Supported types are:
credentials
: These are the credentials to connect to the database. These are not used if using the SQLite database connection type.
username
: SQL Usernamepassword
: SQL Passwordhost
: ip address or FQDN of the host of the database serverdb
: database name to use for logging. Save the file once the settings have been configured.
Once you have the config file edited, you will need to install the database.
Run the Following command:
python3 db_setup.py
Start the bot by typing the following:
screen -R cheerlights-telegram-bot
Then in the new window:
cd cheerlights-telegram-bot
python3 cheerlights_telegram_bot.py
Once that is done, hit CTRL-A-D
to disconnect from the screen session. If something ever happens, you can reconnect to the session by typing:
screen -R cheerlights-telegram-bot
docker compose build
docker compose up -d