Compare commits

..
127 Commits
Author SHA1 Message Date
Davte 53802728a1 Compliance with bot API 7.9
Implemented a system to get administration privileges if running the bot in absence of administrators (the token is provided through the command line).

(cherry picked from commit db240ce199)
2024-08-17 21:12:47 +02:00
Davte 2cdb4e743f Get package version from metadata when package has no __version__ attribute 2024-08-04 18:49:16 +02:00
Davte 98fbbf0127 Compliance with bot API 7.8 2024-08-04 18:30:21 +02:00
Davte 856d53de1c Compliance with bot API 7.7
(cherry picked from commit fd4374f328)
2024-07-07 14:37:21 +02:00
Davte 5e8a2b65f5 Compliance with bot API 7.2
- Included python version in `/version` command
- Added the parameter `business_connection_id` to the methods sendMessage, sendPhoto, sendVideo, sendAnimation, sendAudio, sendDocument, sendSticker, sendVideoNote, sendVoice, sendLocation, sendVenue, sendContact, sendPoll, sendDice, sendGame, and sendMediaGroup, sendChatAction.
- Moved the parameter `format` to Sticker instead of StickerSet (and related methods)

(cherry picked from commit 6b489363de)
2024-04-13 11:17:11 +02:00
Davte 3b0bfb4880 Compliance with bot API 7.1
- Added the class ReplyParameters and replaced parameters reply_to_message_id and allow_sending_without_reply in the methods copyMessage, sendMessage, sendPhoto, sendVideo, sendAnimation, sendAudio, sendDocument, sendSticker, sendVideoNote, sendVoice, sendLocation, sendVenue, sendContact, sendPoll, sendDice, sendInvoice, sendGame, and sendMediaGroup with the field reply_parameters of type ReplyParameters.
- Added the class LinkPreviewOptions and replaced the parameter disable_web_page_preview with link_preview_options in the methods sendMessage and editMessageText.

(cherry picked from commit a343e095e8)
2024-04-13 11:17:07 +02:00
Davte a49e727e31 Allow to overwrite file when using bot.download_file method
(cherry picked from commit a3b28bc1d6)
2024-04-13 11:17:04 +02:00
Davte c78522d46b download_file behaves differently if a local bot API server is used. Wrong default API url was being used
(cherry picked from commit 3969794075)
2024-04-13 11:17:00 +02:00
Davte c4964105b4 Support Local Bot API Server (with custom api_url).
(cherry picked from commit 748ba624a4)
2024-02-17 14:47:28 +01:00
Davte 3396bc6f18 download_file method updated to handle exceptions and return information about downloaded file
(cherry picked from commit 41507067be)
2024-02-14 19:31:20 +01:00
Davte c1f4abc541 Specify encoding in send_part_of_text_file function
(cherry picked from commit ec747bef1d)
2024-02-14 19:31:17 +01:00
Davte c4a822e45d Compliance with bot API 6.8 and 6.9
Added the method `unpinAllGeneralForumTopicMessages` (6.8).

Added the new administrator privileges `can_post_stories`, `can_edit_stories` and `can_delete_stories` to the class `ChatAdministratorRights` and to the method `promoteChatMember` (6.9).
2023-11-12 11:55:03 +01:00
Davte 6b4a95be36 Method to add table columns if missing 2023-08-23 18:23:32 +02:00
Davte beaf3f8516 Allow non-null standard output and/or error pipe to be passed to aio_subprocess_shell function 2023-08-23 17:17:55 +02:00
Davte fc1f087d4a When answering inline queries, prevent invalid InlineQueryResultsButton instantiation
(cherry picked from commit eab81b065d)
2023-08-07 20:19:50 +02:00
Davte aeac4aea52 Better variable regex: accept only one decimal separator in float numbers
(cherry picked from commit 51a77c695b)
2023-07-25 18:58:45 +02:00
Davte 5ab22909cf Whitespace 2023-07-25 16:42:26 +02:00
Davte 9094955812 Config command implemented, allowing administrators to add variables to configuration files 2023-07-25 16:25:56 +02:00
Davte 173783e154 Moved join_path function to utilities module 2023-07-25 16:24:18 +02:00
Davte 92a986d090 Catch up with branch main (v 2.9.1) 2023-07-25 16:23:21 +02:00
Davte 3e6e364336 Compliance with Telegram Bot API 6.5 2023-02-03 21:40:09 +01:00
Davte f0a4c914e4 Compliance with Telegram Bot API 6.4 2023-01-06 10:30:25 +01:00
Davte 80a1440e75 Make the regex dot match any character at all, including a newline, when cleaning HTML strings (so multiline tag bodies are allowed, as they are in Telegram HTML markdown). 2022-12-26 14:12:23 +01:00
Davte b978022658 HTML parse_mode check upgraded.
All supported tags permitted, malformed tags replaced with escaped characters
2022-12-12 22:45:08 +01:00
Davte 50f561e7f9 Method to add a table and its columns to and ObjectWithDatabase 2022-12-10 18:46:29 +01:00
Davte a9b785f49d Compliance with Telegram Bot API 6.3 2022-12-08 16:19:45 +01:00
Davte b7d08ab2ba When admin A requests profile picture of user B, send B's picture and not A's. 2022-12-06 22:18:35 +01:00
Davte d362ec496b Browse users via /auth command 2022-12-05 22:04:59 +01:00
Davte 0bfc1e157b Working on users browsing via /auth command 2022-12-04 22:13:48 +01:00
Davte bc40957b27 Syntax-breaking typo 2022-10-12 14:19:46 +02:00
Davte 45117610f9 Bug fix: use a unique loop 2022-10-12 14:01:10 +02:00
Davte f91661927e Bug fix: use a unique loop 2022-10-12 13:34:01 +02:00
Davte 12f3a2cc73 Bug fix: asyncio.run cannot take asyncio.gather as coroutine 2022-10-12 13:31:23 +02:00
Davte 25abb80343 Bug fix: no running loop, need to create a new one. 2022-10-12 13:26:03 +02:00
Davte 76ea65a660 asyncio get_event_loop method is being deprecated; use new_event_loop / get_running_loop and asyncio.run instead
Major version change because it may not be backward-compatible
2022-10-12 13:24:40 +02:00
Davte e254dbf42a send_document method should not require a chat_id since it can be passed an update object 2020-12-20 20:30:49 +01:00
Davte b7b91a65ea send_photo method should not require a chat_id since it can be passed an update object 2020-12-11 08:21:57 +01:00
Davte abebff43d9 Avoid relative import statements 2020-11-19 15:18:50 +01:00
Davte a460f71b69 Items in __all__ must be str, not module 2020-11-19 14:37:33 +01:00
Davte 6ad5ec2865 Document can be None if document_path is provided 2020-11-19 12:32:50 +01:00
Davte cfae729270 Do not log chardet INFO and DEBUG levels 2020-11-16 23:05:24 +01:00
Davte dc9c2a7b14 Compliance with Telegram Bot API 5.0 and improved type hinting for API methods. 2020-11-16 22:54:25 +01:00
Davte a3cc676432 Identify edited methods (new or deprecated parameters) in addition to new methods. 2020-11-16 20:51:27 +01:00
Davte 15a7a58537 Version number 2020-11-15 21:35:45 +01:00
Davte ea30fd39cf Import statements refactored 2020-11-15 21:34:26 +01:00
Davte a5cabdd102 web should not be imported from aiohttp; use aiohttp.web instead 2020-11-15 20:55:22 +01:00
Davte 89fa73d1a5 Store user profile pictures in bot database and show them in authorization panel 2020-10-07 16:22:51 +02:00
Davte 4b22658bf5 MySQL compatibility: specify VARCHAR length
`db.types.string` becomes now `db.types.string(n)`
`db.types.text` is the wrong type to use (text blobs)
2020-10-07 16:19:03 +02:00
Davte bce8cff3cf Pass all information to command handler when using /start 2020-09-26 19:28:03 +02:00
Davte ea07aa47cf Make general_handler handle photo updates 2020-09-05 10:35:52 +02:00
Davte d49bab54ca Updated examples 2020-08-23 14:21:37 +02:00
Davte 83d01e4da9 Remove argument parameter from parser decorator 2020-08-23 14:07:51 +02:00
Davte 59dde0d25e In text message handler, make available both lowered and original text and inspect condition parameters 2020-08-23 14:03:42 +02:00
Davte 713f4ffd0e Accept language directly 2020-08-20 15:50:53 +02:00
Davte 51bc95332f General handler implemented and applied to contact updates 2020-08-17 23:52:16 +02:00
Davte 92758d923c Document handlers implemented 2020-08-16 15:17:09 +02:00
Davte 946e2a881f Declare packenv variable 2020-07-19 16:17:39 +02:00
Davte 0f4d31892f Prevent globbing and word splitting 2020-07-19 16:11:00 +02:00
Davte c4eaa0b9db Update default help messages with given ones, instead of replacing them 2020-07-17 09:48:52 +02:00
Davte 21214feb0a In default keyboard, show only buttons for commands the user is authorized to call 2020-07-16 10:05:28 +02:00
Davte f7ee5b71a1 Prevent decoding None objects 2020-07-15 13:16:21 +02:00
Davte fb58c0239d Async function to run shell commands 2020-07-15 13:11:04 +02:00
Davte c848bfc228 Script to merge split files 2020-06-22 22:53:25 +02:00
Davte f823057cbe Split outgoing documents bigger than 50 MB and send chunks 2020-06-22 20:30:03 +02:00
Davte d7a1acd23b Typos 2020-06-20 15:44:26 +02:00
Davte 70053c9279 Send error message if database could not be sent - new version 2020-06-20 15:34:39 +02:00
Davte 1c76c7d797 Send error message if database could not be sent 2020-06-20 15:31:42 +02:00
Davte dfffbff7c6 Merge 2020-06-20 15:20:22 +02:00
Davte a4b1ed09a2 longest_cooldown_timedelta property defined 2020-06-20 15:18:13 +02:00
Davte a1bd681cbf Merge 2020-06-20 15:16:46 +02:00
Davte 9c57677320 Accept both updates and raw_updates in maintenance exception criteria 2020-05-21 15:32:04 +02:00
Davte 956e982157 Pass to handlers the parameters they take and preserve update_id 2020-05-21 14:55:32 +02:00
Davte 4bd10894a8 Merge branch 'master' into develop 2020-05-19 15:21:02 +02:00
Davte 89a9863510 Send long text messages as files 2020-05-19 15:12:38 +02:00
Davte ed36e53a28 Consider _ as a digit when prettifying expressions 2020-05-19 15:11:58 +02:00
Davte 8977e0fbc3 Shorten buffer time for calculation sessions 2020-05-19 14:04:02 +02:00
Davte cf7e0c740b Redundant escape 2020-05-19 13:59:15 +02:00
Davte 12b18cff58 Prettify expressions removing whitespace around newlines and adjusting whitespace around parentheses 2020-05-19 12:53:20 +02:00
Davte 3160723aa7 TypeError bug fixed 2020-05-18 22:25:30 +02:00
Davte 8e2feb5ac2 Prevent message is not modified exceptions 2020-05-18 22:08:10 +02:00
Davte cbc7424a97 Prettify expressions 2020-05-18 19:31:26 +02:00
Davte 1e7c384b6d Multilanguage message in version command
(cherry picked from commit a7fd054106)
2020-05-18 18:58:23 +02:00
Davte 7cc2e02f47 Remove whitespace at the end of the expression after del button is pressed 2020-05-18 18:50:21 +02:00
Davte 6315c0dcc2 Track input via message of algebraic expressions as well as input via buttons. 2020-05-18 18:33:40 +02:00
Davte f06c525f5b Merged branch master 2020-05-18 15:09:05 +02:00
Davte ea5c63c1f8 Finished working on calc command 2020-05-18 15:04:18 +02:00
Davte ea549b63c8 Working on calc command 2020-05-18 13:04:19 +02:00
Davte e63b0f9265 Working on calc command 2020-05-18 12:42:04 +02:00
Davte cb9310437f Working on calc button 2020-05-17 19:45:39 +02:00
Davte 5bc58dd7d5 Working on calc button 2020-05-16 15:51:49 +02:00
Davte 5d35579e10 Working on /calc command 2020-05-15 19:48:04 +02:00
Davte b0132e0b30 /when command implemented 2020-05-14 22:18:21 +02:00
Davte 49ecee63d0 /info command implemented 2020-05-14 21:58:38 +02:00
Davte 273eda2b67 /ping command implemented
/length command returns characters in text message even, not only in reply
2020-05-14 20:25:29 +02:00
Davte b12f653096 Useful tools module added 2020-05-14 18:50:05 +02:00
Davte 05878f3fbd Language-labelled commands are accepted only for selected language. /father uses selected language for commands 2020-05-14 18:49:40 +02:00
Davte c583c3c3b0 Allow language-labelled commands 2020-05-14 15:32:06 +02:00
Davte 2d40903069 Finished working on /version command 2020-05-13 19:44:04 +02:00
Davte 217a445a65 Working on /version command 2020-05-13 15:54:38 +02:00
Davte b68dbe7a07 /ban command implemented 2020-05-13 15:31:59 +02:00
Davte 258ca9f6ef /ban command implemented 2020-05-13 15:31:20 +02:00
Davte 3648a36636 Version 2020-05-13 15:22:37 +02:00
Davte ef99493c7f Finished working on /ban 2020-05-13 15:22:14 +02:00
Davte 841f7f0c8d Working on /ban 2020-05-13 12:47:37 +02:00
Davte 23882e5b3b Implemented button to delete all commands stored by BotFather 2020-05-07 22:52:42 +02:00
Davte 6ba21f0115 Version 2020-05-07 15:29:10 +02:00
Davte ca6dca3cb7 Finished working on /father command 2020-05-07 15:07:45 +02:00
Davte 9072c3abe5 Working on /father command 2020-05-06 23:18:27 +02:00
Davte e74e38c6ae Comment 2020-05-06 15:39:45 +02:00
Davte 7a23045479 New parameters of sendPoll method 2020-05-06 15:33:23 +02:00
Davte 5ef449a542 Temp 2020-05-06 00:44:21 +02:00
Davte a2c83f8d9c Pass language to update handlers 2020-05-06 00:39:23 +02:00
Davte dddaf20ea2 Temp 2020-05-05 23:44:58 +02:00
Davte a828bb5d3c Move functions outside init 2020-05-05 12:29:55 +02:00
Davte 25f5514dff Type hinting
(cherry picked from commit 3896776f0e)
2020-04-28 12:08:01 +02:00
Davte 34f802732b Do not notify package updates too often
(cherry picked from commit ab6a0bc0ad)
2020-04-28 09:48:53 +02:00
Davte f6466b0540 Merge branch 'develop' of ssh://gogs.davte.it:8445/Davte/davtelepot into develop
# Conflicts:
#	davtelepot/__init__.py
2020-04-28 09:48:42 +02:00
Davte 7565df17ba New version
(cherry picked from commit e61d757c1a)
2020-04-28 00:36:28 +02:00
Davte 4be33370b9 Text made more clear
(cherry picked from commit e7274dce07)
2020-04-28 00:27:36 +02:00
Davte cf3f7a88fb Deprecated admin_tools submodule 2020-04-28 00:26:38 +02:00
Davte a4d464da58 Text made more clear 2020-04-27 19:07:10 +02:00
Davte 83c0a91919 Missing whitespace
(cherry picked from commit b107cc105d)
2020-04-27 18:03:24 +02:00
Davte 85a5ce3882 Merge branch 'develop' of ssh://gogs.davte.it:8445/Davte/davtelepot into develop 2020-04-27 17:30:05 +02:00
Davte 77405d2dd3 Merge branch 'master' into develop
# Conflicts:
#	davtelepot/__init__.py
#	davtelepot/administration_tools.py
2020-04-27 14:03:58 +02:00
Davte 1e2316e748 Package update notifier completed 2020-04-27 13:45:25 +02:00
Davte 16014c5a42 Working on package update notifier 2020-04-26 23:30:44 +02:00
Davte f0be5b5ff2 Working on package update notifier 2020-04-26 23:14:10 +02:00
4 changed files with 227 additions and 7 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.10.2" __version__ = "2.10.6"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"
+65 -5
View File
@@ -18,6 +18,7 @@ import re
import types import types
from collections import OrderedDict from collections import OrderedDict
from importlib.metadata import version as get_package_version_from_metadata
from typing import Union, List, Tuple from typing import Union, List, Tuple
# Third party modules # Third party modules
@@ -28,8 +29,8 @@ from davtelepot.messages import default_admin_messages, default_talk_messages
from davtelepot.bot import Bot from davtelepot.bot import Bot
from davtelepot.utilities import ( from davtelepot.utilities import (
async_wrapper, CachedPage, Confirmator, extract, get_cleaned_text, async_wrapper, CachedPage, Confirmator, extract, get_cleaned_text,
get_user, clean_html_string, line_drawing_unordered_list, make_button, get_secure_key, get_user, clean_html_string, line_drawing_unordered_list,
make_inline_keyboard, remove_html_tags, send_part_of_text_file, make_button, make_inline_keyboard, remove_html_tags, send_part_of_text_file,
send_csv_file, make_lines_of_buttons, join_path send_csv_file, make_lines_of_buttons, join_path
) )
@@ -44,6 +45,13 @@ variable_regex = re.compile(r"(?P<name>[a-zA-Z]\w*)\s*=\s*"
r"\"[^\"]*\")") r"\"[^\"]*\")")
def get_package_version(package: types.ModuleType):
"""Get version of given package."""
if hasattr(package, '__version__'):
return package.__version__
return get_package_version_from_metadata(package.__name__)
async def _forward_to(update, async def _forward_to(update,
bot: Bot, bot: Bot,
sender, sender,
@@ -865,7 +873,12 @@ async def get_new_versions(bot: Bot,
"skipping...") "skipping...")
continue continue
new_version = web_page['info']['version'] new_version = web_page['info']['version']
current_version = package.__version__ try:
current_version = get_package_version(package)
except TypeError:
current_version = "NA"
logging.error("Could not get current version of "
"package %s", package.__name__)
notification_record = bot.db['updates_notifications'].find_one( notification_record = bot.db['updates_notifications'].find_one(
package=package.__name__, package=package.__name__,
order_by=['-id'], order_by=['-id'],
@@ -895,7 +908,7 @@ async def version_command(bot: Bot, update: dict,
text += f'<b>Python: </b> <code>{platform.python_version()}</code>\n' text += f'<b>Python: </b> <code>{platform.python_version()}</code>\n'
text += '\n'.join( text += '\n'.join(
f"<b>{package.__name__}</b>: " f"<b>{package.__name__}</b>: "
f"<code>{package.__version__}</code>" f"<code>{get_package_version(package)}</code>"
for package in bot.packages for package in bot.packages
) )
temporary_message = await bot.send_message( temporary_message = await bot.send_message(
@@ -939,7 +952,7 @@ async def notify_new_version(bot: Bot):
order_by=['-id'] order_by=['-id']
) )
current_versions = { current_versions = {
f"{package.__name__}_version": package.__version__ f"{package.__name__}_version": get_package_version(package)
for package in bot.packages for package in bot.packages
} }
current_versions['last_commit'] = last_commit current_versions['last_commit'] = last_commit
@@ -1846,6 +1859,50 @@ async def config_command(bot: Bot, update: dict,
language=language) language=language)
async def become_administrator(bot: Bot, update: dict,
user_record: dict, language: str):
"""When the bot has no administrator, become one providing a token.
The token will be printed to the stdout on the machine running the bot.
"""
if len(bot.administrators) > 0:
return
def _get_message(*args):
return bot.get_message('admin', 'become_admin', *args,
update=update, user_record=user_record,
language=language)
token = get_cleaned_text(update=update, bot=bot,
replace=['become_administrator',
'00become_administrator'],
strip='/ @_')
if token != bot.administration_token:
return _get_message('wrong_token')
with bot.db as db:
db['users'].update({**user_record, 'privileges': 1},
['id'])
return _get_message('success')
async def create_promotion_command(bot: Bot):
"""If bot has no administrators, users can elevate themselves.
To do so, they need to provide a token, that will be printed to the stdout
of the machine running the bot.
"""
await bot.get_me()
bot.administration_token = get_secure_key(length=10)
print(f"To become administrator click "
f"https://t.me/{bot.name}?start="
f"00become_administrator_{bot.administration_token}")
@bot.command(command='become_administrator',
authorization_level='everybody',
aliases=['00become_administrator'])
async def _become_administrator(bot, update, user_record, language):
return await become_administrator(bot=bot, update=update,
user_record=user_record,
language=language)
def init(telegram_bot: Bot, def init(telegram_bot: Bot,
talk_messages: dict = None, talk_messages: dict = None,
admin_messages: dict = None, admin_messages: dict = None,
@@ -2075,3 +2132,6 @@ def init(telegram_bot: Bot,
update=update, update=update,
user_record=user_record, user_record=user_record,
language=language) language=language)
if len(telegram_bot.administrators) == 0:
asyncio.ensure_future(create_promotion_command(bot=telegram_bot))
+151 -1
View File
@@ -425,6 +425,38 @@ class ReactionType(DictToDump):
) )
class InputPaidMedia(DictToDump):
def __init__(self,
type_: str,
media: str):
assert type_ in ('photo', 'video'), f"Invalid paid media type `{type_}`"
super().__init__()
self['type'] = type_
self['media'] = media
class InputPaidMediaPhoto(InputPaidMedia):
def __init__(self,
media: str):
super().__init__('photo', media)
class InputPaidMediaVideo(InputPaidMedia):
def __init__(self,
media: str,
thumbnail: str = None,
width: int = None,
height: int = None,
duration: int = None,
supports_streaming: bool = None):
super().__init__('video', media)
self['thumbnail'] = thumbnail
self['width'] = width
self['height'] = height
self['duration'] = duration
self['supports_streaming'] = supports_streaming
def handle_deprecated_disable_web_page_preview(parameters: dict, def handle_deprecated_disable_web_page_preview(parameters: dict,
kwargs: dict): kwargs: dict):
if 'disable_web_page_preview' in kwargs: if 'disable_web_page_preview' in kwargs:
@@ -882,6 +914,7 @@ class TelegramBot:
link_preview_options: LinkPreviewOptions = None, link_preview_options: LinkPreviewOptions = None,
disable_notification: bool = None, disable_notification: bool = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -922,10 +955,12 @@ class TelegramBot:
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
caption_entities: List[dict] = None, caption_entities: List[dict] = None,
show_caption_above_media: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
has_spoiler: bool = None, has_spoiler: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -954,6 +989,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -985,6 +1021,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1015,10 +1052,12 @@ class TelegramBot:
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
caption_entities: List[dict] = None, caption_entities: List[dict] = None,
show_caption_above_media: bool = None,
supports_streaming: bool = None, supports_streaming: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
has_spoiler: bool = None, has_spoiler: bool = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
@@ -1050,9 +1089,11 @@ class TelegramBot:
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
caption_entities: List[dict] = None, caption_entities: List[dict] = None,
show_caption_above_media: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
has_spoiler: bool = None, has_spoiler: bool = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
@@ -1084,6 +1125,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1109,6 +1151,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1135,6 +1178,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
**kwargs): **kwargs):
"""Send a group of photos or videos as an album. """Send a group of photos or videos as an album.
@@ -1162,6 +1206,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1187,7 +1232,9 @@ class TelegramBot:
) )
async def editMessageLiveLocation(self, latitude: float, longitude: float, async def editMessageLiveLocation(self, latitude: float, longitude: float,
live_period: int = None,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: str = None, inline_message_id: str = None,
horizontal_accuracy: float = None, horizontal_accuracy: float = None,
@@ -1218,6 +1265,7 @@ class TelegramBot:
async def stopMessageLiveLocation(self, async def stopMessageLiveLocation(self,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: int = None, inline_message_id: int = None,
reply_markup=None): reply_markup=None):
@@ -1245,6 +1293,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1271,6 +1320,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1291,6 +1341,8 @@ class TelegramBot:
chat_id: Union[int, str], chat_id: Union[int, str],
question: str, question: str,
options: List[str], options: List[str],
question_parse_mode: str = None,
question_entities: list = None,
business_connection_id: str = None, business_connection_id: str = None,
is_anonymous: bool = True, is_anonymous: bool = True,
type_: str = 'regular', type_: str = 'regular',
@@ -1305,6 +1357,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -1540,6 +1593,7 @@ class TelegramBot:
) )
async def pinChatMessage(self, chat_id: Union[int, str], message_id, async def pinChatMessage(self, chat_id: Union[int, str], message_id,
business_connection_id: str = None,
disable_notification: bool = None): disable_notification: bool = None):
"""Pin a message in a group, a supergroup, or a channel. """Pin a message in a group, a supergroup, or a channel.
@@ -1555,6 +1609,7 @@ class TelegramBot:
) )
async def unpinChatMessage(self, chat_id: Union[int, str], async def unpinChatMessage(self, chat_id: Union[int, str],
business_connection_id: str = None,
message_id: int = None): message_id: int = None):
"""Unpin a message in a group, a supergroup, or a channel. """Unpin a message in a group, a supergroup, or a channel.
@@ -1679,6 +1734,7 @@ class TelegramBot:
async def editMessageText(self, text: str, async def editMessageText(self, text: str,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: str = None, inline_message_id: str = None,
parse_mode: str = None, parse_mode: str = None,
@@ -1703,11 +1759,13 @@ class TelegramBot:
async def editMessageCaption(self, async def editMessageCaption(self,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: str = None, inline_message_id: str = None,
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
caption_entities: List[dict] = None, caption_entities: List[dict] = None,
show_caption_above_media: bool = None,
reply_markup=None): reply_markup=None):
"""Edit captions of messages. """Edit captions of messages.
@@ -1722,6 +1780,7 @@ class TelegramBot:
async def editMessageMedia(self, async def editMessageMedia(self,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: str = None, inline_message_id: str = None,
media=None, media=None,
@@ -1744,6 +1803,7 @@ class TelegramBot:
async def editMessageReplyMarkup(self, async def editMessageReplyMarkup(self,
chat_id: Union[int, str] = None, chat_id: Union[int, str] = None,
business_connection_id: str = None,
message_id: int = None, message_id: int = None,
inline_message_id: str = None, inline_message_id: str = None,
reply_markup=None): reply_markup=None):
@@ -1759,7 +1819,10 @@ class TelegramBot:
parameters=locals() parameters=locals()
) )
async def stopPoll(self, chat_id: Union[int, str], message_id, async def stopPoll(self,
chat_id: Union[int, str],
message_id,
business_connection_id: str = None,
reply_markup=None): reply_markup=None):
"""Stop a poll which was sent by the bot. """Stop a poll which was sent by the bot.
@@ -1815,6 +1878,7 @@ class TelegramBot:
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
emoji: str = None, emoji: str = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -2033,6 +2097,7 @@ class TelegramBot:
send_email_to_provider: bool = None, send_email_to_provider: bool = None,
is_flexible: bool = None, is_flexible: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -2112,6 +2177,7 @@ class TelegramBot:
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -2178,6 +2244,7 @@ class TelegramBot:
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
protect_content: bool = None, protect_content: bool = None,
message_effect_id: str = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
**kwargs): **kwargs):
@@ -2325,6 +2392,7 @@ class TelegramBot:
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
caption_entities: list = None, caption_entities: list = None,
show_caption_above_media: bool = None,
disable_notification: bool = None, disable_notification: bool = None,
reply_parameters: ReplyParameters = None, reply_parameters: ReplyParameters = None,
reply_markup=None, reply_markup=None,
@@ -3038,3 +3106,85 @@ class TelegramBot:
'replaceStickerInSet', 'replaceStickerInSet',
parameters=locals() parameters=locals()
) )
async def sendPaidMedia(self, chat_id: Union[int, str], star_count: int,
media: List[InputPaidMedia],
business_connection_id: str = None,
caption: str = None, parse_mode: str = None,
caption_entities: List[dict] = None,
show_caption_above_media: bool = None,
disable_notification: bool = None,
protect_content: bool = None,
reply_parameters: ReplyParameters = None,
reply_markup = None):
"""Send paid media to channel chats.
On success, the sent Message is returned.
See https://core.telegram.org/bots/api#sendpaidmedia for details.
"""
return await self.api_request(
'sendPaidMedia',
parameters=locals()
)
async def getStarTransactions(self,
offset: int = None,
limit: int = None):
"""Returns the bot's Telegram Star transactions in chronological order.
On success, returns a StarTransactions object.
See https://core.telegram.org/bots/api#getstartransactions for details.
`offset`: number of transactions to skip in the response (defaults to 0)
`limit`: maximum number of transactions to be retrieved.
Values between 1-100 are accepted (defaults to 100).
"""
return await self.api_request(
'getStarTransactions',
parameters=locals()
)
async def refundStarPayment(self,
user_id: int,
telegram_payment_charge_id: str):
"""Refunds a successful payment in Telegram Stars.
Returns True on success.
See https://core.telegram.org/bots/api#refundstarpayment for details.
"""
return await self.api_request(
'refundStarPayment',
parameters=locals()
)
async def createChatSubscriptionInviteLink(self, chat_id: Union[int, str],
name: str,
subscription_period: int,
subscription_price: int):
"""Create a subscription invite link for a channel chat.
The bot must have the can_invite_users administrator rights.
The link can be edited using the method editChatSubscriptionInviteLink
or revoked using the method revokeChatInviteLink.
Returns the new invite link as a ChatInviteLink object.
See https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
for details.
"""
return await self.api_request(
'createChatSubscriptionInviteLink',
parameters=locals()
)
async def editChatSubscriptionInviteLink(self, chat_id: Union[int, str],
invite_link: str, name: str):
"""Edit a subscription invite link created by the bot.
The bot must have the can_invite_users administrator rights.
Returns the edited invite link as a ChatInviteLink object.
See https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
for details.
"""
return await self.api_request(
'editChatSubscriptionInviteLink',
parameters=locals()
)
+10
View File
@@ -22,6 +22,16 @@ davtelepot_messages = {
} }
default_admin_messages = { default_admin_messages = {
'become_admin': {
'success': {
'en': "🎉 You are now administrator! 👑",
'it': "🎉 Ora hai diritti di amministrazione! 👑",
},
'wrong_token': {
'en': "❌ Wrong token 🚷",
'it': "❌ Password errata 🚷",
},
},
'cancel': { 'cancel': {
'button': { 'button': {
'en': "↩️ Cancel", 'en': "↩️ Cancel",