1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00
pyTelegramBotAPI/README.md

850 lines
40 KiB
Markdown
Raw Normal View History

2015-08-23 20:32:23 +03:00
[![PyPi Package Version](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
2015-10-26 17:36:32 +03:00
[![Build Status](https://travis-ci.org/eternnoir/pyTelegramBotAPI.svg?branch=master)](https://travis-ci.org/eternnoir/pyTelegramBotAPI)
2020-08-26 00:51:55 +03:00
[![PyPi downloads](https://img.shields.io/pypi/dm/pyTelegramBotAPI.svg)](https://pypi.org/project/pyTelegramBotAPI/)
2015-10-26 17:31:55 +03:00
2021-08-18 23:29:40 +03:00
# <p align="center">pyTelegramBotAPI
2021-12-04 19:43:33 +03:00
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
2021-12-04 19:43:01 +03:00
<p align="center">Supports both sync and async ways.</p>
2021-12-04 19:43:01 +03:00
## <p align="center">Supporting Bot API version: <a href="https://core.telegram.org/bots/api#november-5-2021">5.4</a>!
2021-08-19 22:46:12 +03:00
## Contents
* [Getting started](#getting-started)
2015-08-23 20:32:23 +03:00
* [Writing your first bot](#writing-your-first-bot)
* [Prerequisites](#prerequisites)
* [A simple echo bot](#a-simple-echo-bot)
* [General API Documentation](#general-api-documentation)
* [Types](#types)
* [Methods](#methods)
* [General use of the API](#general-use-of-the-api)
* [Message handlers](#message-handlers)
2021-09-12 20:02:49 +03:00
* [Edited Message handler](#edited-message-handler)
* [Channel Post handler](#channel-post-handler)
* [Edited Channel Post handler](#edited-channel-post-handler)
* [Callback Query handlers](#callback-query-handler)
2021-09-12 20:02:49 +03:00
* [Shipping Query Handler](#shipping-query-handler)
* [Pre Checkout Query Handler](#pre-checkout-query-handler)
* [Poll Handler](#poll-handler)
* [Poll Answer Handler](#poll-answer-handler)
* [My Chat Member Handler](#my-chat-member-handler)
* [Chat Member Handler](#chat-member-handler)
2021-11-06 17:56:10 +03:00
* [Chat Join request handler](#chat-join-request-handler)
2021-09-12 20:02:49 +03:00
* [Inline Mode](#inline-mode)
* [Inline handler](#inline-handler)
* [Chosen Inline handler](#chosen-inline-handler)
* [Answer Inline Query](#answer-inline-query)
* [Additional API features](#additional-api-features)
* [Middleware handlers](#middleware-handlers)
* [Custom filters](#custom-filters)
2015-08-23 20:32:23 +03:00
* [TeleBot](#telebot)
* [Reply markup](#reply-markup)
* [Advanced use of the API](#advanced-use-of-the-api)
2021-09-12 20:02:49 +03:00
* [Using local Bot API Server](#using-local-bot-api-sever)
2021-12-03 19:13:02 +03:00
* [Asynchronous TeleBot](#asynchronous-telebot)
2015-08-23 20:32:23 +03:00
* [Sending large text messages](#sending-large-text-messages)
* [Controlling the amount of Threads used by TeleBot](#controlling-the-amount-of-threads-used-by-telebot)
* [The listener mechanism](#the-listener-mechanism)
* [Using web hooks](#using-web-hooks)
* [Logging](#logging)
2017-06-28 12:44:07 +03:00
* [Proxy](#proxy)
* [Testing](#testing)
2020-04-27 21:56:37 +03:00
* [API conformance](#api-conformance)
2021-12-04 19:41:25 +03:00
* [AsyncTeleBot](#asynctelebot)
2015-08-23 21:01:09 +03:00
* [F.A.Q.](#faq)
* [How can I distinguish a User and a GroupChat in message.chat?](#how-can-i-distinguish-a-user-and-a-groupchat-in-messagechat)
2021-01-18 01:45:23 +03:00
* [How can I handle reocurring ConnectionResetErrors?](#how-can-i-handle-reocurring-connectionreseterrors)
2015-08-23 20:32:23 +03:00
* [The Telegram Chat Group](#the-telegram-chat-group)
* [More examples](#more-examples)
* [Bots using this API](#bots-using-this-api)
2015-08-23 20:32:23 +03:00
## Getting started
2015-08-23 20:32:23 +03:00
2021-11-27 22:29:57 +03:00
This API is tested with Python 3.6-3.10 and Pypy 3.
2015-08-23 20:32:23 +03:00
There are two ways to install the library:
2015-08-23 21:01:09 +03:00
* Installation using pip (a Python package manager)*:
2015-06-28 17:34:27 +03:00
2015-08-23 20:32:23 +03:00
```
$ pip install pyTelegramBotAPI
```
* Installation from source (requires git):
2015-06-26 17:52:09 +03:00
```
$ git clone https://github.com/eternnoir/pyTelegramBotAPI.git
$ cd pyTelegramBotAPI
$ python setup.py install
```
2015-08-23 20:32:23 +03:00
It is generally recommended to use the first option.
2015-06-26 17:52:09 +03:00
2015-08-23 21:01:09 +03:00
**While the API is production-ready, it is still under development and it has regular updates, do not forget to update it regularly by calling `pip install pytelegrambotapi --upgrade`*
2015-08-23 20:32:23 +03:00
## Writing your first bot
2015-06-26 17:52:09 +03:00
2015-08-23 20:32:23 +03:00
### Prerequisites
2015-06-26 09:58:20 +03:00
2015-08-23 20:32:23 +03:00
It is presumed that you [have obtained an API token with @BotFather](https://core.telegram.org/bots#botfather). We will call this token `TOKEN`.
Furthermore, you have basic knowledge of the Python programming language and more importantly [the Telegram Bot API](https://core.telegram.org/bots/api).
2015-06-26 13:05:23 +03:00
2015-08-23 20:32:23 +03:00
### A simple echo bot
The TeleBot class (defined in \__init__.py) encapsulates all API calls in a single class. It provides functions such as `send_xyz` (`send_message`, `send_document` etc.) and several ways to listen for incoming messages.
Create a file called `echo_bot.py`.
Then, open the file and create an instance of the TeleBot class.
2015-06-26 09:58:20 +03:00
```python
import telebot
bot = telebot.TeleBot("TOKEN", parse_mode=None) # You can set parse_mode by default. HTML or MARKDOWN
2015-08-23 20:32:23 +03:00
```
2015-08-23 21:01:09 +03:00
*Note: Make sure to actually replace TOKEN with your own API token.*
2015-06-26 09:58:20 +03:00
2015-08-23 20:32:23 +03:00
After that declaration, we need to register some so-called message handlers. Message handlers define filters which a message must pass. If a message passes the filter, the decorated function is called and the incoming message is passed as an argument.
Let's define a message handler which handles incoming `/start` and `/help` commands.
```python
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Howdy, how are you doing?")
2015-06-26 09:58:20 +03:00
```
2015-08-23 20:32:23 +03:00
A function which is decorated by a message handler __can have an arbitrary name, however, it must have only one parameter (the message)__.
2015-06-26 13:05:23 +03:00
2015-08-23 20:32:23 +03:00
Let's add another handler:
```python
2015-08-23 23:23:18 +03:00
@bot.message_handler(func=lambda m: True)
2015-08-23 20:32:23 +03:00
def echo_all(message):
bot.reply_to(message, message.text)
```
2015-08-23 23:06:11 +03:00
This one echoes all incoming text messages back to the sender. It uses a lambda function to test a message. If the lambda returns True, the message is handled by the decorated function. Since we want all messages to be handled by this function, we simply always return True.
2015-06-26 13:05:23 +03:00
2015-08-23 21:01:09 +03:00
*Note: all handlers are tested in the order in which they were declared*
2015-08-23 23:23:18 +03:00
We now have a basic bot which replies a static message to "/start" and "/help" commands and which echoes the rest of the sent messages. To start the bot, add the following to our source file:
2015-06-26 13:05:23 +03:00
```python
2021-09-28 19:17:09 +03:00
bot.infinity_polling()
2015-08-23 20:32:23 +03:00
```
Alright, that's it! Our source file now looks like this:
```python
import telebot
2015-06-26 13:05:23 +03:00
2021-09-28 19:17:09 +03:00
bot = telebot.TeleBot("YOUR_BOT_TOKEN")
2015-06-26 13:05:23 +03:00
2015-08-23 20:32:23 +03:00
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Howdy, how are you doing?")
2015-06-26 13:05:23 +03:00
2015-08-23 23:23:18 +03:00
@bot.message_handler(func=lambda message: True)
2015-08-23 20:32:23 +03:00
def echo_all(message):
bot.reply_to(message, message.text)
2015-06-26 13:05:23 +03:00
2021-09-28 19:17:09 +03:00
bot.infinity_polling()
2015-06-26 13:05:23 +03:00
```
2015-08-23 20:32:23 +03:00
To start the bot, simply open up a terminal and enter `python echo_bot.py` to run the bot! Test it by sending commands ('/start' and '/help') and arbitrary text messages.
## General API Documentation
### Types
2015-06-26 16:56:49 +03:00
2015-08-23 22:56:42 +03:00
All types are defined in types.py. They are all completely in line with the [Telegram API's definition of the types](https://core.telegram.org/bots/api#available-types), except for the Message's `from` field, which is renamed to `from_user` (because `from` is a Python reserved token). Thus, attributes such as `message_id` can be accessed directly with `message.message_id`. Note that `message.chat` can be either an instance of `User` or `GroupChat` (see [How can I distinguish a User and a GroupChat in message.chat?](#how-can-i-distinguish-a-user-and-a-groupchat-in-messagechat)).
The Message object also has a `content_type`attribute, which defines the type of the Message. `content_type` can be one of the following strings:
`text`, `audio`, `document`, `photo`, `sticker`, `video`, `video_note`, `voice`, `location`, `contact`, `new_chat_members`, `left_chat_member`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`, `supergroup_chat_created`, `channel_chat_created`, `migrate_to_chat_id`, `migrate_from_chat_id`, `pinned_message`.
2015-06-27 05:25:22 +03:00
You can use some types in one function. Example:
```content_types=["text", "sticker", "pinned_message", "photo", "audio"]```
2015-08-23 20:32:23 +03:00
### Methods
All [API methods](https://core.telegram.org/bots/api#available-methods) are located in the TeleBot class. They are renamed to follow common Python naming conventions. E.g. `getMe` is renamed to `get_me` and `sendMessage` to `send_message`.
### General use of the API
Outlined below are some general use cases of the API.
#### Message handlers
A message handler is a function that is decorated with the `message_handler` decorator of a TeleBot instance. Message handlers consist of one or multiple filters.
2021-05-25 23:47:49 +03:00
Each filter must return True for a certain message in order for a message handler to become eligible to handle that message. A message handler is declared in the following way (provided `bot` is an instance of TeleBot):
2015-09-08 11:44:31 +03:00
```python
@bot.message_handler(filters)
def function_name(message):
bot.reply_to(message, "This is a message handler")
```
`function_name` is not bound to any restrictions. Any function name is permitted with message handlers. The function must accept at most one argument, which will be the message that the function must handle.
`filters` is a list of keyword arguments.
A filter is declared in the following manner: `name=argument`. One handler may have multiple filters.
2015-09-08 11:44:31 +03:00
TeleBot supports the following filters:
2015-09-08 12:29:35 +03:00
2015-09-08 11:44:31 +03:00
|name|argument(s)|Condition|
|:---:|---| ---|
|content_types|list of strings (default `['text']`)|`True` if message.content_type is in the list of strings.|
2020-01-28 21:56:03 +03:00
|regexp|a regular expression as a string|`True` if `re.search(regexp_arg)` returns `True` and `message.content_type == 'text'` (See [Python Regular Expressions](https://docs.python.org/2/library/re.html))|
2015-09-08 11:44:31 +03:00
|commands|list of strings|`True` if `message.content_type == 'text'` and `message.text` starts with a command that is in the list of strings.|
2021-12-04 19:41:25 +03:00
|chat_types|list of chat types|`True` if `message.chat.type` in your filter|
|func|a function (lambda or function reference)|`True` if the lambda or function reference returns `True`|
2021-09-12 18:27:01 +03:00
2015-09-08 11:44:31 +03:00
Here are some examples of using the filters and message handlers:
2016-04-16 10:08:01 +03:00
2015-06-27 05:25:22 +03:00
```python
import telebot
2015-08-23 20:32:23 +03:00
bot = telebot.TeleBot("TOKEN")
2015-06-27 05:25:22 +03:00
2015-08-23 20:32:23 +03:00
# Handles all text messages that contains the commands '/start' or '/help'.
@bot.message_handler(commands=['start', 'help'])
def handle_start_help(message):
pass
# Handles all sent documents and audio files
@bot.message_handler(content_types=['document', 'audio'])
def handle_docs_audio(message):
pass
# Handles all text messages that match the regular expression
@bot.message_handler(regexp="SOME_REGEXP")
def handle_message(message):
pass
2015-06-27 05:25:22 +03:00
# Handles all messages for which the lambda returns True
2015-08-23 20:32:23 +03:00
@bot.message_handler(func=lambda message: message.document.mime_type == 'text/plain', content_types=['document'])
def handle_text_doc(message):
pass
2015-07-07 06:51:11 +03:00
# Which could also be defined as:
2015-08-23 20:32:23 +03:00
def test_message(message):
return message.document.mime_type == 'text/plain'
2015-07-07 06:51:11 +03:00
2015-08-23 20:32:23 +03:00
@bot.message_handler(func=test_message, content_types=['document'])
2020-02-08 17:44:28 +03:00
def handle_text_doc(message):
2015-08-23 20:32:23 +03:00
pass
# Handlers can be stacked to create a function which will be called if either message_handler is eligible
# This handler will be called if the message starts with '/hello' OR is some emoji
@bot.message_handler(commands=['hello'])
@bot.message_handler(func=lambda msg: msg.text.encode("utf-8") == SOME_FANCY_EMOJI)
def send_something(message):
pass
2015-08-23 20:32:23 +03:00
```
2015-09-08 11:44:31 +03:00
**Important: all handlers are tested in the order in which they were declared**
2016-04-16 10:08:01 +03:00
2021-09-12 20:02:49 +03:00
#### Edited Message handler
Handle edited messages
`@bot.edited_message_handler(filters) # <- passes a Message type object to your function`
2016-06-07 14:40:35 +03:00
2021-09-12 20:02:49 +03:00
#### Channel Post handler
Handle channel post messages
`@bot.channel_post_handler(filters) # <- passes a Message type object to your function`
2016-12-03 08:56:22 +03:00
2021-09-12 20:02:49 +03:00
#### Edited Channel Post handler
Handle edited channel post messages
`@bot.edited_channel_post_handler(filters) # <- passes a Message type object to your function`
2016-12-03 08:56:22 +03:00
2016-04-16 10:08:01 +03:00
#### Callback Query Handler
Handle callback queries
2016-04-16 10:08:01 +03:00
```python
@bot.callback_query_handler(func=lambda call: True)
2021-09-25 19:10:29 +03:00
def test_callback(call): # <- passes a CallbackQuery type object to your function
2016-04-16 10:08:01 +03:00
logger.info(call)
```
#### Shipping Query Handler
Handle shipping queries
`@bot.shipping_query_handeler() # <- passes a ShippingQuery type object to your function`
#### Pre Checkout Query Handler
Handle pre checkoupt queries
`@bot.pre_checkout_query_handler() # <- passes a PreCheckoutQuery type object to your function`
#### Poll Handler
Handle poll updates
`@bot.poll_handler() # <- passes a Poll type object to your function`
#### Poll Answer Handler
Handle poll answers
`@bot.poll_answer_handler() # <- passes a PollAnswer type object to your function`
#### My Chat Member Handler
Handle updates of a the bot's member status in a chat
`@bot.my_chat_member_handler() # <- passes a ChatMemberUpdated type object to your function`
#### Chat Member Handler
Handle updates of a chat member's status in a chat
`@bot.chat_member_handler() # <- passes a ChatMemberUpdated type object to your function`
*Note: "chat_member" updates are not requested by default. If you want to allow all update types, set `allowed_updates` in `bot.polling()` / `bot.infinity_polling()` to `util.update_types`*
2021-11-06 17:56:10 +03:00
#### Chat Join Request Handler
Handle chat join requests using:
`@bot.chat_join_request_handler() # <- passes ChatInviteLink type object to your function`
2021-09-12 20:02:49 +03:00
### Inline Mode
More information about [Inline mode](https://core.telegram.org/bots/inline).
#### Inline handler
Now, you can use inline_handler to get inline queries in telebot.
```python
@bot.inline_handler(lambda query: query.query == 'text')
def query_text(inline_query):
# Query message is text
```
#### Chosen Inline handler
Use chosen_inline_handler to get chosen_inline_result in telebot. Don't forgot add the /setinlinefeedback
command for @Botfather.
More information : [collecting-feedback](https://core.telegram.org/bots/inline#collecting-feedback)
```python
@bot.chosen_inline_handler(func=lambda chosen_inline_result: True)
def test_chosen(chosen_inline_result):
# Process all chosen_inline_result.
```
#### Answer Inline Query
```python
@bot.inline_handler(lambda query: query.query == 'text')
def query_text(inline_query):
try:
r = types.InlineQueryResultArticle('1', 'Result', types.InputTextMessageContent('Result message.'))
r2 = types.InlineQueryResultArticle('2', 'Result2', types.InputTextMessageContent('Result message2.'))
bot.answer_inline_query(inline_query.id, [r, r2])
except Exception as e:
print(e)
```
2021-09-12 20:02:49 +03:00
### Additional API features
#### Middleware Handlers
2020-04-11 23:41:34 +03:00
A middleware handler is a function that allows you to modify requests or the bot context as they pass through the
Telegram to the bot. You can imagine middleware as a chain of logic connection handled before any other handlers are
executed. Middleware processing is disabled by default, enable it by setting `apihelper.ENABLE_MIDDLEWARE = True`.
2020-04-11 23:41:34 +03:00
```python
apihelper.ENABLE_MIDDLEWARE = True
2020-04-11 23:41:34 +03:00
@bot.middleware_handler(update_types=['message'])
def modify_message(bot_instance, message):
# modifying the message before it reaches any other handler
message.another_text = message.text + ':changed'
@bot.message_handler(commands=['start'])
def start(message):
# the message is already modified when it reaches message handler
assert message.another_text == message.text + ':changed'
```
There are other examples using middleware handler in the [examples/middleware](examples/middleware) directory.
2021-09-12 18:30:32 +03:00
#### Custom filters
2021-09-12 18:30:32 +03:00
Also, you can use built-in custom filters. Or, you can create your own filter.
[Example of custom filter](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/custom_filters/general_custom_filters.py)
2021-09-12 18:30:32 +03:00
Also, we have examples on them. Check this links:
You can check some built-in filters in source [code](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/telebot/custom_filters.py)
Example of [filtering by id](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/custom_filters/id_filter_example.py)
2021-09-12 18:30:32 +03:00
Example of [filtering by text](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/custom_filters/text_filter_example.py)
2021-09-12 18:30:32 +03:00
2021-09-12 18:32:16 +03:00
If you want to add some built-in filter, you are welcome to add it in custom_filters.py file.
2021-09-12 18:40:31 +03:00
Here is example of creating filter-class:
2021-09-12 18:41:26 +03:00
```python
class IsAdmin(telebot.custom_filters.SimpleCustomFilter):
2021-09-12 18:40:31 +03:00
# Class will check whether the user is admin or creator in group or not
key='is_admin'
@staticmethod
def check(message: telebot.types.Message):
return bot.get_chat_member(message.chat.id,message.from_user.id).status in ['administrator','creator']
2021-09-12 18:43:09 +03:00
# To register filter, you need to use method add_custom_filter.
bot.add_custom_filter(IsAdmin())
2021-09-12 18:40:31 +03:00
2021-09-12 18:43:09 +03:00
# Now, you can use it in handler.
@bot.message_handler(is_admin=True)
def admin_of_group(message):
2021-12-04 19:41:25 +03:00
bot.send_message(message.chat.id, 'You are admin of this group!')
2021-09-12 18:40:31 +03:00
```
2016-04-16 10:08:01 +03:00
2015-08-23 20:32:23 +03:00
#### TeleBot
```python
import telebot
TOKEN = '<token_string>'
tb = telebot.TeleBot(TOKEN) #create a new Telegram Bot object
2015-07-24 04:22:02 +03:00
# Upon calling this function, TeleBot starts polling the Telegram servers for new messages.
2021-09-28 19:17:09 +03:00
# - interval: int (default 0) - The interval between polling requests
# - timeout: integer (default 20) - Timeout in seconds for long polling.
# - allowed_updates: List of Strings (default None) - List of update types to request
2021-09-28 19:17:09 +03:00
tb.infinity_polling(interval=0, timeout=20)
2015-06-27 05:25:22 +03:00
# getMe
user = tb.get_me()
# setWebhook
tb.set_webhook(url="http://example.com", certificate=open('mycert.pem'))
# unset webhook
tb.remove_webhook()
2015-09-05 13:12:52 +03:00
# getUpdates
updates = tb.get_updates()
2021-09-28 19:17:09 +03:00
# or
2015-09-05 13:12:52 +03:00
updates = tb.get_updates(1234,100,20) #get_Updates(offset, limit, timeout):
2015-06-27 05:25:22 +03:00
# sendMessage
tb.send_message(chat_id, text)
2015-06-27 05:25:22 +03:00
2021-01-18 01:34:54 +03:00
# editMessageText
2021-01-18 01:47:03 +03:00
tb.edit_message_text(new_text, chat_id, message_id)
2021-01-18 01:34:54 +03:00
2015-06-27 05:25:22 +03:00
# forwardMessage
tb.forward_message(to_chat_id, from_chat_id, message_id)
2015-08-23 22:56:42 +03:00
# All send_xyz functions which can take a file as an argument, can also take a file_id instead of a file.
# sendPhoto
2015-06-27 05:25:22 +03:00
photo = open('/tmp/photo.png', 'rb')
tb.send_photo(chat_id, photo)
2015-08-23 22:56:42 +03:00
tb.send_photo(chat_id, "FILEID")
2015-06-27 05:25:22 +03:00
# sendAudio
2015-08-21 18:09:35 +03:00
audio = open('/tmp/audio.mp3', 'rb')
2015-06-27 05:25:22 +03:00
tb.send_audio(chat_id, audio)
2015-08-23 22:56:42 +03:00
tb.send_audio(chat_id, "FILEID")
2015-08-23 20:32:23 +03:00
2015-08-21 18:09:35 +03:00
## sendAudio with duration, performer and title.
tb.send_audio(CHAT_ID, file_data, 1, 'eternnoir', 'pyTelegram')
2015-06-27 05:25:22 +03:00
2015-08-21 18:09:35 +03:00
# sendVoice
voice = open('/tmp/voice.ogg', 'rb')
tb.send_voice(chat_id, voice)
2015-08-23 22:56:42 +03:00
tb.send_voice(chat_id, "FILEID")
2015-08-21 18:09:35 +03:00
2015-06-27 05:25:22 +03:00
# sendDocument
doc = open('/tmp/file.txt', 'rb')
tb.send_document(chat_id, doc)
2015-08-23 22:56:42 +03:00
tb.send_document(chat_id, "FILEID")
2015-06-27 05:25:22 +03:00
# sendSticker
sti = open('/tmp/sti.webp', 'rb')
tb.send_sticker(chat_id, sti)
2015-08-23 22:56:42 +03:00
tb.send_sticker(chat_id, "FILEID")
2015-06-27 05:25:22 +03:00
# sendVideo
video = open('/tmp/video.mp4', 'rb')
tb.send_video(chat_id, video)
2015-08-23 22:56:42 +03:00
tb.send_video(chat_id, "FILEID")
2015-06-27 05:25:22 +03:00
# sendVideoNote
videonote = open('/tmp/videonote.mp4', 'rb')
tb.send_video_note(chat_id, videonote)
tb.send_video_note(chat_id, "FILEID")
2015-06-27 17:11:18 +03:00
# sendLocation
tb.send_location(chat_id, lat, lon)
2015-06-28 12:58:15 +03:00
# sendChatAction
# action_string can be one of the following strings: 'typing', 'upload_photo', 'record_video', 'upload_video',
# 'record_audio', 'upload_audio', 'upload_document' or 'find_location'.
2015-06-28 12:58:15 +03:00
tb.send_chat_action(chat_id, action_string)
# getFile
# Downloading a file is straightforward
# Returns a File object
import requests
file_info = tb.get_file(file_id)
file = requests.get('https://api.telegram.org/file/bot{0}/{1}'.format(API_TOKEN, file_info.file_path))
2015-08-23 20:32:23 +03:00
```
#### Reply markup
All `send_xyz` functions of TeleBot take an optional `reply_markup` argument. This argument must be an instance of `ReplyKeyboardMarkup`, `ReplyKeyboardRemove` or `ForceReply`, which are defined in types.py.
2015-06-28 12:58:15 +03:00
2015-08-23 20:32:23 +03:00
```python
2015-07-01 04:55:25 +03:00
from telebot import types
2015-08-23 22:56:42 +03:00
# Using the ReplyKeyboardMarkup class
2015-08-23 20:32:23 +03:00
# It's constructor can take the following optional arguments:
# - resize_keyboard: True/False (default False)
# - one_time_keyboard: True/False (default False)
# - selective: True/False (default False)
# - row_width: integer (default 3)
# row_width is used in combination with the add() function.
# It defines how many buttons are fit on each row before continuing on the next row.
markup = types.ReplyKeyboardMarkup(row_width=2)
2016-04-16 10:08:01 +03:00
itembtn1 = types.KeyboardButton('a')
itembtn2 = types.KeyboardButton('v')
itembtn3 = types.KeyboardButton('d')
markup.add(itembtn1, itembtn2, itembtn3)
2015-08-23 22:56:42 +03:00
tb.send_message(chat_id, "Choose one letter:", reply_markup=markup)
2016-04-25 18:54:30 +03:00
# or add KeyboardButton one row at a time:
2015-06-30 08:20:44 +03:00
markup = types.ReplyKeyboardMarkup()
2016-04-16 10:08:01 +03:00
itembtna = types.KeyboardButton('a')
itembtnv = types.KeyboardButton('v')
itembtnc = types.KeyboardButton('c')
itembtnd = types.KeyboardButton('d')
itembtne = types.KeyboardButton('e')
markup.row(itembtna, itembtnv)
markup.row(itembtnc, itembtnd, itembtne)
2015-08-23 22:56:42 +03:00
tb.send_message(chat_id, "Choose one letter:", reply_markup=markup)
```
The last example yields this result:
2015-08-23 23:23:18 +03:00
2017-03-05 15:17:46 +03:00
![ReplyKeyboardMarkup](https://farm3.staticflickr.com/2933/32418726704_9ef76093cf_o_d.jpg "ReplyKeyboardMarkup")
2015-06-30 08:20:44 +03:00
2015-08-23 22:56:42 +03:00
```python
# ReplyKeyboardRemove: hides a previously sent ReplyKeyboardMarkup
2015-08-23 20:32:23 +03:00
# Takes an optional selective argument (True/False, default False)
markup = types.ReplyKeyboardRemove(selective=False)
2015-08-23 20:32:23 +03:00
tb.send_message(chat_id, message, reply_markup=markup)
2015-08-23 22:56:42 +03:00
```
2015-08-01 16:03:40 +03:00
2015-08-23 22:56:42 +03:00
```python
# ForceReply: forces a user to reply to a message
2015-08-23 20:32:23 +03:00
# Takes an optional selective argument (True/False, default False)
markup = types.ForceReply(selective=False)
2015-08-23 22:56:42 +03:00
tb.send_message(chat_id, "Send me another word:", reply_markup=markup)
2015-06-28 12:35:47 +03:00
```
2015-08-23 23:23:18 +03:00
ForceReply:
2015-08-01 16:03:40 +03:00
2017-03-05 15:17:46 +03:00
![ForceReply](https://farm4.staticflickr.com/3809/32418726814_d1baec0fc2_o_d.jpg "ForceReply")
2015-08-23 22:56:42 +03:00
2016-01-19 08:56:44 +03:00
2021-09-12 20:02:49 +03:00
### Working with entities
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
2016-05-14 20:29:21 +03:00
Attributes:
* `type`
* `url`
* `offset`
* `length`
* `user`
2016-05-14 20:29:21 +03:00
**Here's an Example:**`message.entities[num].<attribute>`<br>
Here `num` is the entity number or order of entity in a reply, for if incase there are multiple entities in the reply/message.<br>
`message.entities` returns a list of entities object. <br>
`message.entities[0].type` would give the type of the first entity<br>
Refer [Bot Api](https://core.telegram.org/bots/api#messageentity) for extra details
2016-01-05 16:54:47 +03:00
2015-08-23 20:32:23 +03:00
## Advanced use of the API
2015-08-01 16:03:40 +03:00
### Using local Bot API Sever
Since version 5.0 of the Bot API, you have the possibility to run your own [Local Bot API Server](https://core.telegram.org/bots/api#using-a-local-bot-api-server).
pyTelegramBotAPI also supports this feature.
```python
from telebot import apihelper
apihelper.API_URL = "http://localhost:4200/bot{0}/{1}"
```
**Important: Like described [here](https://core.telegram.org/bots/api#logout), you have to log out your bot from the Telegram server before switching to your local API server. in pyTelegramBotAPI use `bot.log_out()`**
*Note: 4200 is an example port*
2021-12-03 19:13:02 +03:00
### Asynchronous TeleBot
2021-12-04 19:41:25 +03:00
New: There is an asynchronous implementation of telebot.
2015-08-23 20:32:23 +03:00
To enable this behaviour, create an instance of AsyncTeleBot instead of TeleBot.
```python
2015-08-23 20:32:23 +03:00
tb = telebot.AsyncTeleBot("TOKEN")
```
2021-12-03 19:13:02 +03:00
Now, every function that calls the Telegram API is executed in a separate asynchronous task.
Using AsyncTeleBot allows you to do the following:
```python
import telebot
2015-08-23 23:23:18 +03:00
tb = telebot.AsyncTeleBot("TOKEN")
2021-12-03 19:13:02 +03:00
@tb.message_handler(commands=['start'])
async def start_message(message):
2021-12-04 19:41:25 +03:00
await bot.send_message(message.chat.id, 'Hello!')
```
2021-12-03 19:13:02 +03:00
See more in [examples](https://github.com/eternnoir/pyTelegramBotAPI/tree/master/examples/asynchronous_telebot)
2015-08-01 16:03:40 +03:00
2015-08-23 20:32:23 +03:00
### Sending large text messages
2015-08-23 23:23:18 +03:00
Sometimes you must send messages that exceed 5000 characters. The Telegram API can not handle that many characters in one request, so we need to split the message in multiples. Here is how to do that using the API:
```python
from telebot import util
2015-08-23 20:32:23 +03:00
large_text = open("large_text.txt", "rb").read()
2015-08-23 23:23:18 +03:00
2021-06-28 16:44:49 +03:00
# Split the text each 3000 characters.
# split_string returns a list with the splitted text.
splitted_text = util.split_string(large_text, 3000)
for text in splitted_text:
tb.send_message(chat_id, text)
```
Or you can use the new `smart_split` function to get more meaningful substrings:
```python
from telebot import util
large_text = open("large_text.txt", "rb").read()
# Splits one string into multiple strings, with a maximum amount of `chars_per_string` (max. 4096)
# Splits by last '\n', '. ' or ' ' in exactly this priority.
# smart_split returns a list with the splitted text.
splitted_text = util.smart_split(large_text, chars_per_string=3000)
2015-08-23 20:32:23 +03:00
for text in splitted_text:
tb.send_message(chat_id, text)
```
2015-08-23 20:32:23 +03:00
### Controlling the amount of Threads used by TeleBot
The TeleBot constructor takes the following optional arguments:
2015-08-23 23:23:18 +03:00
2016-07-17 18:38:37 +03:00
- threaded: True/False (default True). A flag to indicate whether
2015-08-23 23:23:18 +03:00
TeleBot should execute message handlers on it's polling Thread.
2015-08-01 16:03:40 +03:00
2015-08-23 20:32:23 +03:00
### The listener mechanism
As an alternative to the message handlers, one can also register a function as a listener to TeleBot.
NOTICE: handlers won't disappear! Your message will be processed both by handlers and listeners. Also, it's impossible to predict which will work at first because of threading. If you use threaded=False, custom listeners will work earlier, after them handlers will be called.
Example:
```python
2015-08-23 21:07:06 +03:00
def handle_messages(messages):
2016-06-15 14:30:57 +03:00
for message in messages:
2015-08-23 20:32:23 +03:00
# Do something with the message
2015-08-23 21:07:06 +03:00
bot.reply_to(message, 'Hi')
2015-08-23 20:32:23 +03:00
bot.set_update_listener(handle_messages)
2021-09-28 19:17:09 +03:00
bot.infinity_polling()
```
2015-06-28 12:35:47 +03:00
### Using web hooks
When using webhooks telegram sends one Update per call, for processing it you should call process_new_messages([update.message]) when you recieve it.
There are some examples using webhooks in the [examples/webhook_examples](examples/webhook_examples) directory.
2015-07-20 05:38:33 +03:00
2015-08-23 20:32:23 +03:00
### Logging
2015-08-23 23:23:18 +03:00
You can use the Telebot module logger to log debug info about Telebot. Use `telebot.logger` to get the logger of the TeleBot module.
2015-09-08 20:56:05 +03:00
It is possible to add custom logging Handlers to the logger. Refer to the [Python logging module page](https://docs.python.org/2/library/logging.html) for more info.
2015-07-20 05:38:33 +03:00
```python
2015-09-08 20:56:05 +03:00
import logging
2015-07-20 05:38:33 +03:00
logger = telebot.logger
2015-09-08 20:56:05 +03:00
telebot.logger.setLevel(logging.DEBUG) # Outputs debug messages to console.
2015-07-20 05:38:33 +03:00
```
2017-06-28 12:44:07 +03:00
### Proxy
You can use proxy for request. `apihelper.proxy` object will use by call `requests` proxies argument.
```python
from telebot import apihelper
apihelper.proxy = {'http':'http://127.0.0.1:3128'}
2017-06-28 12:44:07 +03:00
```
If you want to use socket5 proxy you need install dependency `pip install requests[socks]` and make sure, that you have the latest version of `gunicorn`, `PySocks`, `pyTelegramBotAPI`, `requests` and `urllib3`.
2017-06-28 13:01:07 +03:00
```python
2018-04-18 11:10:22 +03:00
apihelper.proxy = {'https':'socks5://userproxy:password@proxy_address:port'}
2017-06-28 13:01:07 +03:00
```
### Testing
You can disable or change the interaction with real Telegram server by using
```python
apihelper.CUSTOM_REQUEST_SENDER = your_handler
```
parameter. You can pass there your own function that will be called instead of _requests.request_.
For example:
```python
def custom_sender(method, url, **kwargs):
print("custom_sender. method: {}, url: {}, params: {}".format(method, url, kwargs.get("params")))
result = util.CustomRequestResponse('{"ok":true,"result":{"message_id": 1, "date": 1, "chat": {"id": 1, "type": "private"}}}')
return result
```
Then you can use API and proceed requests in your handler code.
```python
apihelper.CUSTOM_REQUEST_SENDER = custom_sender
tb = TeleBot("test")
res = tb.send_message(123, "Test")
```
Result will be:
`custom_sender. method: post, url: https://api.telegram.org/botololo/sendMessage, params: {'chat_id': '123', 'text': 'Test'}`
2017-06-28 13:01:07 +03:00
## API conformance
2019-06-06 21:54:06 +03:00
2021-11-08 18:51:42 +03:00
* ✔ [Bot API 5.4](https://core.telegram.org/bots/api#november-5-2021)
* [Bot API 5.3](https://core.telegram.org/bots/api#june-25-2021) - ChatMemberXXX classes are full copies of ChatMember
* ✔ [Bot API 5.2](https://core.telegram.org/bots/api#april-26-2021)
* ✔ [Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021)
* ✔ [Bot API 5.0](https://core.telegram.org/bots/api-changelog#november-4-2020)
* ✔ [Bot API 4.9](https://core.telegram.org/bots/api-changelog#june-4-2020)
* ✔ [Bot API 4.8](https://core.telegram.org/bots/api-changelog#april-24-2020)
* ✔ [Bot API 4.7](https://core.telegram.org/bots/api-changelog#march-30-2020)
* ✔ [Bot API 4.6](https://core.telegram.org/bots/api-changelog#january-23-2020)
* [Bot API 4.5](https://core.telegram.org/bots/api-changelog#december-31-2019) - No nested MessageEntities and Markdown2 support
* ✔ [Bot API 4.4](https://core.telegram.org/bots/api-changelog#july-29-2019)
* ✔ [Bot API 4.3](https://core.telegram.org/bots/api-changelog#may-31-2019)
* ✔ [Bot API 4.2](https://core.telegram.org/bots/api-changelog#april-14-2019)
* [Bot API 4.1](https://core.telegram.org/bots/api-changelog#august-27-2018) - No Passport support
* [Bot API 4.0](https://core.telegram.org/bots/api-changelog#july-26-2018) - No Passport support
* ✔ [Bot API 3.6](https://core.telegram.org/bots/api-changelog#february-13-2018)
* ✔ [Bot API 3.5](https://core.telegram.org/bots/api-changelog#november-17-2017)
* ✔ [Bot API 3.4](https://core.telegram.org/bots/api-changelog#october-11-2017)
* ✔ [Bot API 3.3](https://core.telegram.org/bots/api-changelog#august-23-2017)
* ✔ [Bot API 3.2](https://core.telegram.org/bots/api-changelog#july-21-2017)
* ✔ [Bot API 3.1](https://core.telegram.org/bots/api-changelog#june-30-2017)
* ✔ [Bot API 3.0](https://core.telegram.org/bots/api-changelog#may-18-2017)
* ✔ [Bot API 2.3.1](https://core.telegram.org/bots/api-changelog#december-4-2016)
* ✔ [Bot API 2.3](https://core.telegram.org/bots/api-changelog#november-21-2016)
* ✔ [Bot API 2.2](https://core.telegram.org/bots/api-changelog#october-3-2016)
* ✔ [Bot API 2.1](https://core.telegram.org/bots/api-changelog#may-22-2016)
* ✔ [Bot API 2.0](https://core.telegram.org/bots/api-changelog#april-9-2016)
2021-12-04 19:22:44 +03:00
## AsyncTeleBot
### Asynchronous version of telebot
We have a fully asynchronous version of TeleBot.
This class is not controlled by threads. Asyncio tasks are created to execute all the stuff.
### EchoBot
Echo Bot example on AsyncTeleBot:
```python
# This is a simple echo bot using the decorator mechanism.
# It echoes any incoming text messages.
from telebot.async_telebot import AsyncTeleBot
bot = AsyncTeleBot('TOKEN')
# Handle '/start' and '/help'
@bot.message_handler(commands=['help', 'start'])
async def send_welcome(message):
await bot.reply_to(message, """\
Hi there, I am EchoBot.
I am here to echo your kind words back to you. Just say anything nice and I'll say the exact same thing to you!\
""")
# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
@bot.message_handler(func=lambda message: True)
async def echo_message(message):
await bot.reply_to(message, message.text)
bot.polling()
```
As you can see here, keywords are await and async.
### Why should I use async?
Asynchronous tasks depend on processor performance. Many asynchronous tasks can run parallelly, while thread tasks will block each other.
### Differences in AsyncTeleBot
2021-12-04 19:23:23 +03:00
AsyncTeleBot has different middlewares. See example on [middlewares](https://github.com/coder2020official/pyTelegramBotAPI/tree/master/examples/asynchronous_telebot/middleware)
2021-12-04 19:22:44 +03:00
### Examples
See more examples in our [examples](https://github.com/coder2020official/pyTelegramBotAPI/tree/master/examples/asynchronous_telebot) folder
2015-08-23 21:01:09 +03:00
## F.A.Q.
### How can I distinguish a User and a GroupChat in message.chat?
2015-10-12 18:00:25 +03:00
Telegram Bot API support new type Chat for message.chat.
2015-08-23 21:01:09 +03:00
2015-10-12 18:00:25 +03:00
- Check the ```type``` attribute in ```Chat``` object:
-
2015-08-23 21:01:09 +03:00
```python
2019-03-04 10:24:55 +03:00
if message.chat.type == "private":
2021-12-04 19:41:25 +03:00
# private chat message
2015-08-23 21:01:09 +03:00
2019-03-04 10:24:55 +03:00
if message.chat.type == "group":
2015-10-12 18:00:25 +03:00
# group chat message
2019-03-04 10:24:55 +03:00
if message.chat.type == "supergroup":
# supergroup chat message
2015-10-12 18:00:25 +03:00
2019-03-04 10:24:55 +03:00
if message.chat.type == "channel":
2015-10-12 18:00:25 +03:00
# channel message
2015-08-23 21:01:09 +03:00
```
2021-01-18 01:45:23 +03:00
### How can I handle reocurring ConnectionResetErrors?
Bot instances that were idle for a long time might be rejected by the server when sending a message due to a timeout of the last used session. Add `apihelper.SESSION_TIME_TO_LIVE = 5 * 60` to your initialisation to force recreation after 5 minutes without any activity.
2015-08-23 20:32:23 +03:00
## The Telegram Chat Group
2015-07-17 16:40:33 +03:00
Get help. Discuss. Chat.
2016-06-03 12:21:33 +03:00
* Join the [pyTelegramBotAPI Telegram Chat Group](https://telegram.me/joinchat/Bn4ixj84FIZVkwhk2jag6A)
2015-07-17 16:40:33 +03:00
2015-08-23 20:32:23 +03:00
## More examples
2015-07-09 05:38:35 +03:00
* [Echo Bot](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/echo_bot.py)
* [Deep Linking](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/deep_linking.py)
2015-08-23 21:03:46 +03:00
* [next_step_handler Example](https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/step_example.py)
## Bots using this API
* [SiteAlert bot](https://telegram.me/SiteAlert_bot) ([source](https://github.com/ilteoood/SiteAlert-Python)) by *ilteoood* - Monitors websites and sends a notification on changes
2016-02-13 20:59:31 +03:00
* [TelegramLoggingBot](https://github.com/aRandomStranger/TelegramLoggingBot) by *aRandomStranger*
2021-09-12 21:12:19 +03:00
* [Telegram LMGTFY_bot](https://github.com/GabrielRF/telegram-lmgtfy_bot) by *GabrielRF* - Let me Google that for you.
* [Telegram Proxy Bot](https://github.com/mrgigabyte/proxybot) by *mrgigabyte*
2016-02-13 20:59:31 +03:00
* [RadRetroRobot](https://github.com/Tronikart/RadRetroRobot) by *Tronikart* - Multifunctional Telegram Bot RadRetroRobot.
* [League of Legends bot](https://telegram.me/League_of_Legends_bot) ([source](https://github.com/i32ropie/lol)) by *i32ropie*
* [NeoBot](https://github.com/neoranger/NeoBot) by [@NeoRanger](https://github.com/neoranger)
* [ColorCodeBot](https://t.me/colorcodebot) ([source](https://github.com/andydecleyre/colorcodebot)) - Share code snippets as beautifully syntax-highlighted HTML and/or images.
2016-06-05 20:20:17 +03:00
* [ComedoresUGRbot](http://telegram.me/ComedoresUGRbot) ([source](https://github.com/alejandrocq/ComedoresUGRbot)) by [*alejandrocq*](https://github.com/alejandrocq) - Telegram bot to check the menu of Universidad de Granada dining hall.
2016-09-29 08:35:42 +03:00
* [proxybot](https://github.com/p-hash/proxybot) - Simple Proxy Bot for Telegram. by p-hash
2021-09-12 21:12:19 +03:00
* [DonantesMalagaBot](https://github.com/vfranch/DonantesMalagaBot) - DonantesMalagaBot facilitates information to Malaga blood donors about the places where they can donate today or in the incoming days. It also records the date of the last donation so that it helps the donors to know when they can donate again. - by vfranch
* [DuttyBot](https://github.com/DmytryiStriletskyi/DuttyBot) by *Dmytryi Striletskyi* - Timetable for one university in Kiev.
2016-11-20 22:04:21 +03:00
* [wat-bridge](https://github.com/rmed/wat-bridge) by [*rmed*](https://github.com/rmed) - Send and receive messages to/from WhatsApp through Telegram
2017-01-14 19:57:05 +03:00
* [filmratingbot](http://t.me/filmratingbot)([source](https://github.com/jcolladosp/film-rating-bot)) by [*jcolladosp*](https://github.com/jcolladosp) - Telegram bot using the Python API that gets films rating from IMDb and metacritic
2017-07-24 20:28:27 +03:00
* [Send2Kindlebot](http://t.me/Send2KindleBot) ([source](https://github.com/GabrielRF/Send2KindleBot)) by *GabrielRF* - Send to Kindle service.
* [RastreioBot](http://t.me/RastreioBot) ([source](https://github.com/GabrielRF/RastreioBot)) by *GabrielRF* - Bot used to track packages on the Brazilian Mail Service.
2017-09-09 16:32:13 +03:00
* [Spbu4UBot](http://t.me/Spbu4UBot)([link](https://github.com/EeOneDown/spbu4u)) by *EeOneDown* - Bot with timetables for SPbU students.
2019-04-24 12:29:52 +03:00
* [SmartySBot](http://t.me/ZDU_bot)([link](https://github.com/0xVK/SmartySBot)) by *0xVK* - Telegram timetable bot, for Zhytomyr Ivan Franko State University students.
2018-03-19 10:13:48 +03:00
* [LearnIt](https://t.me/LearnItbot)([link](https://github.com/tiagonapoli/LearnIt)) - A Telegram Bot created to help people to memorize other languages vocabulary.
2018-08-09 03:45:07 +03:00
* [Bot-Telegram-Shodan ](https://github.com/rubenleon/Bot-Telegram-Shodan) by [rubenleon](https://github.com/rubenleon)
* [VigoBusTelegramBot](https://t.me/vigobusbot) ([GitHub](https://github.com/Pythoneiro/VigoBus-TelegramBot)) - Bot that provides buses coming to a certain stop and their remaining time for the city of Vigo (Galicia - Spain)
2019-04-21 18:34:10 +03:00
* [kaishnik-bot](https://t.me/kaishnik_bot) ([source](https://github.com/airatk/kaishnik-bot)) by *airatk* - bot which shows all the necessary information to KNTRU-KAI students.
2019-05-30 06:35:23 +03:00
* [Robbie](https://t.me/romdeliverybot) ([source](https://github.com/FacuM/romdeliverybot_support)) by @FacuM - Support Telegram bot for developers and maintainers.
2019-06-29 09:39:14 +03:00
* [AsadovBot](https://t.me/asadov_bot) ([source](https://github.com/desexcile/BotApi)) by @DesExcile - Сatalog of poems by Eduard Asadov.
* [thesaurus_com_bot](https://t.me/thesaurus_com_bot) ([source](https://github.com/LeoSvalov/words-i-learn-bot)) by @LeoSvalov - words and synonyms from [dictionary.com](https://www.dictionary.com) and [thesaurus.com](https://www.thesaurus.com) in the telegram.
2020-03-27 17:38:22 +03:00
* [InfoBot](https://t.me/info2019_bot) ([source](https://github.com/irevenko/info-bot)) by @irevenko - An all-round bot that displays some statistics (weather, time, crypto etc...)
2020-06-06 21:50:30 +03:00
* [FoodBot](https://t.me/ChensonUz_bot) ([source](https://github.com/Fliego/old_restaurant_telegram_chatbot)) by @Fliego - a simple bot for food ordering
* [Sporty](https://t.me/SportydBot) ([source](https://github.com/0xnu/sporty)) by @0xnu - Telegram bot for displaying the latest news, sports schedules and injury updates.
2020-07-16 14:09:37 +03:00
* [JoinGroup Silencer Bot](https://t.me/joingroup_silencer_bot) ([source](https://github.com/zeph1997/Telegram-Group-Silencer-Bot)) by [@zeph1997](https://github.com/zeph1997) - A Telegram Bot to remove "join group" and "removed from group" notifications.
* [TasksListsBot](https://t.me/TasksListsBot) ([source](https://github.com/Pablo-Davila/TasksListsBot)) by [@Pablo-Davila](https://github.com/Pablo-Davila) - A (tasks) lists manager bot for Telegram.
* [MyElizaPsychologistBot](https://t.me/TasksListsBot) ([source](https://github.com/Pablo-Davila/MyElizaPsychologistBot)) by [@Pablo-Davila](https://github.com/Pablo-Davila) - An implementation of the famous Eliza psychologist chatbot.
* [Frcstbot](https://t.me/frcstbot) ([source](https://github.com/Mrsqd/frcstbot_public)) by [Mrsqd](https://github.com/Mrsqd). A Telegram bot that will always be happy to show you the weather forecast.
2021-01-20 13:04:55 +03:00
* [MineGramBot](https://github.com/ModischFabrications/MineGramBot) by [ModischFabrications](https://github.com/ModischFabrications). This bot can start, stop and monitor a minecraft server.
* [Tabletop DiceBot](https://github.com/dexpiper/tabletopdicebot) by [dexpiper](https://github.com/dexpiper). This bot can roll multiple dices for RPG-like games, add positive and negative modifiers and show short descriptions to the rolls.
2021-03-18 10:38:47 +03:00
* [BarnameKon](https://t.me/BarnameKonBot) by [Anvaari](https://github.com/anvaari). This Bot make "Add to google calendar" link for your events. It give information about event and return link. It work for Jalali calendar and in Tehran Time. [Source code](https://github.com/anvaari/BarnameKon)
2021-09-12 21:12:19 +03:00
* [Translator bot](https://github.com/AREEG94FAHAD/translate_text_bot) by Areeg Fahad. This bot can be used to translate texts.
* [Digital Cryptocurrency bot](https://github.com/AREEG94FAHAD/currencies_bot) by Areeg Fahad. With this bot, you can now monitor the prices of more than 12 digital Cryptocurrency.
* [Anti-Tracking Bot](https://t.me/AntiTrackingBot) by Leon Heess [(source)](https://github.com/leonheess/AntiTrackingBot). Send any link, and the bot tries its best to remove all tracking from the link you sent.
2021-06-21 14:00:17 +03:00
* [Developer Bot](https://t.me/IndDeveloper_bot) by [Vishal Singh](https://github.com/vishal2376) [(source code)](https://github.com/vishal2376/telegram-bot) This telegram bot can do tasks like GitHub search & clone,provide c++ learning resources ,Stackoverflow search, Codeforces(profile visualizer,random problems)
* [oneIPO bot](https://github.com/aaditya2200/IPO-proj) by [Aadithya](https://github.com/aaditya2200) & [Amol Soans](https://github.com/AmolDerickSoans) This Telegram bot provides live updates , data and documents on current and upcoming IPOs(Initial Public Offerings)
2021-10-08 13:39:59 +03:00
* [CoronaGraphsBot](https://t.me/CovidGraph_bot) ([source](https://github.com/TrevorWinstral/CoronaGraphsBot)) by *TrevorWinstral* - Gets live COVID Country data, plots it, and briefs the user
* [ETHLectureBot](https://t.me/ETHLectureBot) ([source](https://github.com/TrevorWinstral/ETHLectureBot)) by *TrevorWinstral* - Notifies ETH students when their lectures have been uploaded
* [Vlun Finder Bot](https://github.com/resinprotein2333/Vlun-Finder-bot) by [Resinprotein2333](https://github.com/resinprotein2333). This bot can help you to find The information of CVE vulnerabilities.
2021-10-24 18:08:15 +03:00
* [ETHGasFeeTrackerBot](https://t.me/ETHGasFeeTrackerBot) ([Source](https://github.com/DevAdvik/ETHGasFeeTrackerBot]) by *DevAdvik* - Get Live Ethereum Gas Fees in GWEI
* [Google Sheet Bot](https://github.com/JoachimStanislaus/Tele_Sheet_bot) by [JoachimStanislaus](https://github.com/JoachimStanislaus). This bot can help you to track your expenses by uploading your bot entries to your google sheet.
2021-11-27 18:32:58 +03:00
* [GrandQuiz Bot](https://github.com/Carlosma7/TFM-GrandQuiz) by [Carlosma7](https://github.com/Carlosma7). This bot is a trivia game that allows you to play with people from different ages. This project addresses the use of a system through chatbots to carry out a social and intergenerational game as an alternative to traditional game development.
2021-09-12 21:12:19 +03:00
**Want to have your bot listed here? Just make a pull request. Only bots with public source code are accepted.**