Skip to content

Endogen/idena-tg-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IDENA Telegram Bot

IDENA Telegram Bot is a Telegram bot created by @endogen for the IDENA community.

Overview

The bot is build around the python-telegram-bot module and is polling based. Webhook mode is implemented but untested.

General bot features

  • Every command is a plugin
  • Every plugin can be enabled / disabled without restarting the bot
  • Every plugin can be updated by drag & dropping the plugin file into the bot chat
  • Restart or shutdown the bot via command
  • Bot can be administered by more then one user

IDENA specific features

  • Show current price on all supported exchanges
  • Show chart for overall price

Configuration

Before starting up the bot you have to take care of some settings and add a Telegram API token. The configuration file and toke file are located in the config folder.

config.json

This file holds the configuration for the bot. You have to at least edit the value for admin_id. Everything else is optional.

  • admin - ids: This is a list of Telegram user IDs that will be able to control the bot. You can add your own user or multiple users if you want. If you don't know your Telegram user ID, get in a conversation with Telegram bot @userinfobot and if you write him (anything) he will return you your user ID.
  • admin - notify_on_error: If set to true then all user IDs in the "admin - ids" list will be notified if some error comes up.
  • telegram - read_timeout: Read timeout in seconds as integer. Usually this value doesn't have to be changed.
  • telegram - connect_timeout: Connect timeout in seconds as integer. Usually this value doesn't have to be changed.
  • webhook - listen: Required only for webhook mode. IP to listen to.
  • webhook - port: Required only for webhook mode. Port to listen on.
  • webhook - privkey_path: Required only for webhook mode. Path to private key (.pem file).
  • webhook - cert_path: Required only for webhook mode. Path to certificate (.pem file).
  • webhook - url: Required only for webhook mode. URL under which the bot is hosted.
  • database - use_db: If true then new database files (SQLite) will be created if a plugin tries to execute some SQL statements. If false, no databases will be used.

token.json

This file holds the Telegram bot token. You have to provide one and you will get it in a conversation with Telegram bot @BotFather while registering your bot.

If you don't want to provide the token in a file then you have two other options:

  • Provide it as a command line argument while starting your bot: -tkn <your token>
  • Provide it as an command line input (MOST SECURE): --input-tkn

Starting

In order to run the bot you need to execute it with the Python interpreter. If you don't have any idea where to host the bot, take a look at Where to host Telegram Bots. Services like Heroku (free) will work fine. You can also run the script locally on your own computer for testing purposes.

Prerequisites

You have to use at least Python 3.7 to execute the scripts. Everything else is not supported.

Installation

Install all needed Python modules

pip3 install -r requirements.txt

Starting

  1. First you have to make the script run.sh executable with
chmod +x run.sh
  1. Then you need to start the script file
./run.sh &

Stopping

The recommended way to stop the bot is by using the bot command /shutdown. If you don't want or can't use this, you can shut the bot down with:

pkill python3.7

which will kill every Python 3.7 process that is currently running.

Usage

Available commands

Bot
/about - Show info about the bot
/backup - Backup whole bot folder
/help - Show all available commands
/log - Download current logfile
/restart - Restart the bot
/shutdown - Shutdown the bot
IDENA
/price - Show current price
/chart - Show price chart
/stats - Show general information

If you want to show a list of available commands as you type, open a chat with Telegram bot @BotFather and execute the command /setcommands. Then choose the bot you want to activate the list for and after that send the list of commands with description. Something like this:

price - Show current price
chart - Show price chart
stats - Show general information