cheerlights / cheerlights-telegram

MIT License
2 stars 0 forks source link
cheerlights python telegram telegram-bot telegram-bot-api

CheerLights Telegram Bot

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.


Bot Commands

The following are the commands the bot will recognize.

Command Description Example
/start Displays the starting Keyboard to select functions with /start

Installation/Setup

Installation Steps

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.

Obtaining API Keys

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.

Telegram

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.

Installing the Script

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)

Manual Installation

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.

Docker Configuration (Recommended)

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.

Configure the Script

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"
    }
  }

}

Save the file once the settings have been configured.

Running the Script

Once you have the config file edited, you will need to install the database.

Run the Following command:

python3 db_setup.py
Manually Running

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
Running with Docker
docker compose build

docker compose up -d

Change Log