Framework to build a Telegram Bot based on a UWSGI Server
Project description
A Python Telegram Bot
Welcome to a UWSGI based abstract Telegram Bot. With this framework you are easily able to set up a complete Telegram Bot with self made commands without a lot of extra work. All abstract commands are implemented as GET-Responses as explained on https://core.telegram.org/bots/api. This means you don’t need to have experience in HTTP Requests or PHP: All you need is python.
In the next few chapters I will explain you all the Features and how to properly set up the bot.
Set Up
First of all, as we are talking about an abstract bot you first need to implement this package.
For programming with the bot, you need the following:
At least Python 3.X
A good supported Python IDE (for example PyCharm)
This python package , available on pypi
An example implementation of this bot will be soon available in the example folder.
For using your bot implemenation on a real server
At least Python 3.X
Install this package with pip install xxxx
Install regis with pip install redis
Install uwsgi with pip install uwsgi
Warning: It’s recommended that you install all packages used for your bot on a virtual environment to not mess up your OS. All infos about Virtual Environments can be read on http://docs.python-guide.org/en/latest/dev/virtualenvs/. With virtual environments you can keep all the used requirements only for this project / bot.
More instructions will follow.
Features
Commands and Inline Commands
This Bot support both the normal commands and the newly added inline commands. To add new commands you simply create methods inside either a Command- or InlineCommandClass. The name of the method is the command itself. To add more command- inlinecommandclasses to your bot you simply add the to the lists which you give the class TGBotWSGI when you initialise the bot. For more information check the example.
Configuration
All configurations are managed by *.ini - files.
UWSGI
Bot
For correctly configuring the bot, you need a file /resources/config/config.ini inside your bot project. All needed attributes will be explained here in future and will also be shown in the example.
Logging
The Bot supports a complete logger and can be accessed in telegram/tglogging/init.py .
Files
You are able to save several data in .json files. To define new files you simply define a folder for all your json filesm in the bot-configuration and define json-file-names in a list when implementing the class TGBotWSGI.
Redis
File Server
To save performance when e.g. loading files, a cache server is implemented. Every time a command has been recognized, all the created files will be loaded into the cache of this server, if the cache is empty. If it is not empty, every time a command has been recognized the cache will be used to make the bot more performant.
Limit Server
To prevent spam there is a limit cache server. In the config.ini you are able to set the amount and time of a limit: - Amount: How many commands are allowed until you start to restrict the use of the bot? - Time: What period are we looking at? When will the restriction be resetted?
Conversation Server
Furthermore a conversation cache server has also been added to add support for longer command conversations. If you , for example, start with a command, the bot then can answer back with a second question. You will then answer back etc. All these commands will be explained in the next sub-chapter.
More Documentation will follow.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tgbot-0.31.tar.gz
.
File metadata
- Download URL: tgbot-0.31.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c0b41226311fd3123c85d2fad4edadeb75072b67ba47a86505e95dd0efa07d0 |
|
MD5 | 463cb0a92453db027d10443a2dff932a |
|
BLAKE2b-256 | c17cf3430a52dadfef9572eef53886dfa6c5e298ecc7f631af8e785260395e64 |
File details
Details for the file tgbot-0.31-py3-none-any.whl
.
File metadata
- Download URL: tgbot-0.31-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec39528e7af96b48b7558fd7e7da8a5d9ed85f0ca559d1be256bc4d562feb77a |
|
MD5 | d9ea7372e9822f57fd4b3afb8fd545ee |
|
BLAKE2b-256 | 636ec9f82a202751c59c14b8867eb32141a589506f3d9b8bf0df61c8d25bd26a |