Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
<p align="center">Both synchronous and asynchronous.</p>

## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#february-9-2026"><img src="https://img.shields.io/badge/Bot%20API-9.4-blue?logo=telegram" alt="Supported Bot API version"></a>
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#march-1-2026"><img src="https://img.shields.io/badge/Bot%20API-9.5-blue?logo=telegram" alt="Supported Bot API version"></a>

<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
Expand Down
144 changes: 72 additions & 72 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from datetime import datetime

# -- Project information -----------------------------------------------------

project = 'pyTelegramBotAPI'
author = 'coder2020official'
copyright = f'2022-{datetime.now().year}, {author}'

# The full version, including alpha/beta/rc tags
release = '4.31.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosectionlabel',
'sphinx.ext.autodoc',
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx_copybutton",

]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_logo = 'logo.png'
html_theme_options = {
"light_css_variables": {
"color-brand-primary": "#7C4DFF",
"color-brand-content": "#7C4DFF",
},
"light_logo": "logo.png",
"dark_logo": "logo2.png",
}

locale_dirs = ["locales/"]
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from datetime import datetime
# -- Project information -----------------------------------------------------
project = 'pyTelegramBotAPI'
author = 'coder2020official'
copyright = f'2022-{datetime.now().year}, {author}'
# The full version, including alpha/beta/rc tags
release = '4.32.0'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosectionlabel',
'sphinx.ext.autodoc',
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx_copybutton",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_logo = 'logo.png'
html_theme_options = {
"light_css_variables": {
"color-brand-primary": "#7C4DFF",
"color-brand-content": "#7C4DFF",
},
"light_logo": "logo.png",
"dark_logo": "logo2.png",
}
locale_dirs = ["locales/"]
12 changes: 12 additions & 0 deletions examples/asynchronous_telebot/chat_member_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,17 @@ async def my_chat_m(message: types.ChatMemberUpdated):
@bot.message_handler(content_types=util.content_type_service)
async def delall(message: types.Message):
await bot.delete_message(message.chat.id,message.message_id)


@bot.message_handler(commands=['set_tag'])
async def set_tag(message: types.Message):
tag = util.extract_arguments(message.text)
if not tag:
await bot.reply_to(message, "Usage: /set_tag your_tag")
return
await bot.set_chat_member_tag(message.chat.id, message.from_user.id, tag=tag)
await bot.reply_to(message, f"Tag updated: {tag}")


import asyncio
asyncio.run(bot.polling(allowed_updates=util.update_types))
21 changes: 19 additions & 2 deletions examples/asynchronous_telebot/formatting_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from telebot.async_telebot import AsyncTeleBot
from telebot import formatting
from telebot import formatting, types

bot = AsyncTeleBot('token')

Expand Down Expand Up @@ -50,5 +50,22 @@ async def start_message(message):
parse_mode='HTML'
)

# Bot API 9.5: date_time entity example
date_text = "2026-03-01 12:00:00"
text = f"Local time: {date_text}"
await bot.send_message(
message.chat.id,
text,
entities=[
types.MessageEntity(
type='date_time',
offset=len("Local time: "),
length=len(date_text),
unix_time=1772366400,
date_time_format='short'
)
]
)

import asyncio
asyncio.run(bot.polling())
asyncio.run(bot.polling())
22 changes: 22 additions & 0 deletions examples/asynchronous_telebot/send_message_draft_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncio

from telebot.async_telebot import AsyncTeleBot

bot = AsyncTeleBot("TOKEN")


@bot.message_handler(commands=['draft'])
async def send_draft(message):
if message.chat.type != 'private':
await bot.reply_to(message, "This example works in private chats.")
return

draft_id = message.from_user.id
await bot.send_message_draft(message.chat.id, draft_id, "Generating response...")
await asyncio.sleep(1)
await bot.send_message_draft(message.chat.id, draft_id, "Still working...")
await asyncio.sleep(1)
await bot.send_message(message.chat.id, "Done.")


asyncio.run(bot.polling())
12 changes: 12 additions & 0 deletions examples/chat_member_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,16 @@ def my_chat_m(message: types.ChatMemberUpdated):
@bot.message_handler(content_types=util.content_type_service)
def delall(message: types.Message):
bot.delete_message(message.chat.id,message.message_id)


@bot.message_handler(commands=['set_tag'])
def set_tag(message: types.Message):
tag = util.extract_arguments(message.text)
if not tag:
bot.reply_to(message, "Usage: /set_tag your_tag")
return
bot.set_chat_member_tag(message.chat.id, message.from_user.id, tag=tag)
bot.reply_to(message, f"Tag updated: {tag}")


bot.infinity_polling(allowed_updates=util.update_types)
21 changes: 19 additions & 2 deletions examples/formatting_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from telebot import TeleBot
from telebot import formatting
from telebot import formatting, types

bot = TeleBot('TOKEN')

Expand Down Expand Up @@ -50,4 +50,21 @@ def start_message(message):
parse_mode='HTML'
)

bot.infinity_polling()
# Bot API 9.5: date_time entity example
date_text = "2026-03-01 12:00:00"
text = f"Local time: {date_text}"
bot.send_message(
message.chat.id,
text,
entities=[
types.MessageEntity(
type='date_time',
offset=len("Local time: "),
length=len(date_text),
unix_time=1772366400,
date_time_format='short'
)
]
)

bot.infinity_polling()
22 changes: 22 additions & 0 deletions examples/send_message_draft_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import time

import telebot

bot = telebot.TeleBot("TOKEN")


@bot.message_handler(commands=['draft'])
def send_draft(message):
if message.chat.type != 'private':
bot.reply_to(message, "This example works in private chats.")
return

draft_id = message.from_user.id
bot.send_message_draft(message.chat.id, draft_id, "Generating response...")
time.sleep(1)
bot.send_message_draft(message.chat.id, draft_id, "Still working...")
time.sleep(1)
bot.send_message(message.chat.id, "Done.")


bot.infinity_polling()
92 changes: 46 additions & 46 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pyTelegramBotAPI"
version = "4.31.0"
description = "Python Telegram bot API."
authors = [{name = "eternnoir", email = "eternnoir@gmail.com"}]
license = {text = "GPL2"}
readme = "README.md"
requires-python = ">=3.9"
keywords = ["telegram", "bot", "api", "tools"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Environment :: Console",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)"
]
dependencies = ["requests"]

[project.urls]
Homepage = "https://github.com/eternnoir/pyTelegramBotAPI"
Documentation = "https://pytba.readthedocs.org"
Repository = "https://github.com/eternnoir/pyTelegramBotAPI"
Issues = "https://github.com/eternnoir/pyTelegramBotAPI/issues"


[project.optional-dependencies]
json = ["ujson"]
PIL = ["Pillow"]
redis = ["redis>=3.4.1"]
fastapi = ["fastapi"]
uvicorn = ["uvicorn"]
psutil = ["psutil"]
coloredlogs = ["coloredlogs"]
watchdog = ["watchdog"]


[tool.hatch.build.targets.wheel]
include = ["telebot/*"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "pyTelegramBotAPI"
version = "4.32.0"
description = "Python Telegram bot API."
authors = [{name = "eternnoir", email = "eternnoir@gmail.com"}]
license = {text = "GPL2"}
readme = "README.md"
requires-python = ">=3.9"
keywords = ["telegram", "bot", "api", "tools"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Environment :: Console",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)"
]
dependencies = ["requests"]
[project.urls]
Homepage = "https://github.com/eternnoir/pyTelegramBotAPI"
Documentation = "https://pytba.readthedocs.org"
Repository = "https://github.com/eternnoir/pyTelegramBotAPI"
Issues = "https://github.com/eternnoir/pyTelegramBotAPI/issues"
[project.optional-dependencies]
json = ["ujson"]
PIL = ["Pillow"]
redis = ["redis>=3.4.1"]
fastapi = ["fastapi"]
uvicorn = ["uvicorn"]
psutil = ["psutil"]
coloredlogs = ["coloredlogs"]
watchdog = ["watchdog"]
[tool.hatch.build.targets.wheel]
include = ["telebot/*"]
Loading