Python-Telegram-Bot is a bot made from python obviously as the name suggests. The bot can be used in Telegram groups. The bot comes with new and added features from the normal Telegram bots. Let's get started.
-
Introduction
_ -
Telegram API support
_ -
Installing
_ -
Getting started
_#.
Learning by example
_#.
Logging
_#.
Documentation
_ -
Getting help
_ -
Contributing
_ -
License
_
This library provides a pure Python interface for the
Telegram Bot API <https://core.telegram.org/bots/api>
.
It's compatible with Python versions 3.6+. PTB might also work on PyPy <http://pypy.org/>
, though there have been a lot of issues before. Hence, PyPy is not officially supported.
In addition to the pure API implementation, this library features a number of high-level classes to
make the development of bots easy and straightforward. These classes are contained in the
telegram.ext
submodule.
All types and methods of the Telegram Bot API 5.0 are supported.
You can install or upgrade python-telegram-bot with:
.. code:: shell
$ pip install python-telegram-bot --upgrade
Or you can install from source with:
.. code:: shell
$ git clone https://github.com/HackWeiser360/python-telegram-bot --recursive
$ cd python-telegram-bot
$ python setup.py install
In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:
.. code:: shell
$ git submodule update --init --recursive
Our Wiki(under development) contains a lot of resources to get you started with python-telegram-bot
:
Introduction to the API <https://github.com/HackWeiser360/python-telegram-bot/wiki/Introduction-to-the-API>
_- Tutorial:
Your first Bot <https://github.com/HackWeiser360/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot>
_
Other references:
Telegram API documentation <https://core.telegram.org/bots/api>
_python-telegram-bot documentation <https://python-telegram-bot.readthedocs.io/>
_
We believe that the best way to learn this package is by example. Here
are some examples for you to review. Even if it is not your approach for learning, please take a
look at echobot.py
, it is the de facto base for most of the bots out there. Best of all,
the code for these examples are released to the public domain, so you can start by grabbing the
code and building on top of it.
Visit this page <https://github.com/HackWeiser360/python-telegram-bot/blob/master/examples/README.md>
_ to discover the official examples or look at the examples on the wiki <https://github.com/HackWeiser360/python-telegram-bot/wiki/Examples>
_ to see other bots the community has built. The Wiki is under construction and should be ready in 2-3 weeks.
This library uses the logging
module. To set up logging to standard output, put:
.. code:: python
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
at the beginning of your script.
You can also use logs in your application by calling logging.getLogger()
and setting the log level you want:
.. code:: python
logger = logging.getLogger()
logger.setLevel(logging.INFO)
If you want DEBUG logs instead:
.. code:: python
logger.setLevel(logging.DEBUG)