Compare commits
127
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53802728a1
|
||
|
|
2cdb4e743f
|
||
|
|
98fbbf0127
|
||
|
|
856d53de1c
|
||
|
|
5e8a2b65f5
|
||
|
|
3b0bfb4880
|
||
|
|
a49e727e31
|
||
|
|
c78522d46b
|
||
|
|
c4964105b4
|
||
|
|
3396bc6f18
|
||
|
|
c1f4abc541
|
||
|
|
c4a822e45d
|
||
|
|
6b4a95be36
|
||
|
|
beaf3f8516
|
||
|
|
fc1f087d4a
|
||
|
|
aeac4aea52
|
||
|
|
5ab22909cf
|
||
|
|
9094955812
|
||
|
|
173783e154
|
||
|
|
92a986d090
|
||
|
|
3e6e364336
|
||
|
|
f0a4c914e4
|
||
|
|
80a1440e75
|
||
|
|
b978022658
|
||
|
|
50f561e7f9
|
||
|
|
a9b785f49d
|
||
|
|
b7d08ab2ba
|
||
|
|
d362ec496b
|
||
|
|
0bfc1e157b
|
||
|
|
bc40957b27
|
||
|
|
45117610f9
|
||
|
|
f91661927e
|
||
|
|
12f3a2cc73
|
||
|
|
25abb80343
|
||
|
|
76ea65a660
|
||
|
|
e254dbf42a
|
||
|
|
b7b91a65ea
|
||
|
|
abebff43d9
|
||
|
|
a460f71b69
|
||
|
|
6ad5ec2865
|
||
|
|
cfae729270
|
||
|
|
dc9c2a7b14
|
||
|
|
a3cc676432
|
||
|
|
15a7a58537
|
||
|
|
ea30fd39cf
|
||
|
|
a5cabdd102
|
||
|
|
89fa73d1a5
|
||
|
|
4b22658bf5
|
||
|
|
bce8cff3cf
|
||
|
|
ea07aa47cf
|
||
|
|
d49bab54ca
|
||
|
|
83d01e4da9
|
||
|
|
59dde0d25e
|
||
|
|
713f4ffd0e
|
||
|
|
51bc95332f
|
||
|
|
92758d923c
|
||
|
|
946e2a881f
|
||
|
|
0f4d31892f
|
||
|
|
c4eaa0b9db | ||
|
|
21214feb0a | ||
|
|
f7ee5b71a1 | ||
|
|
fb58c0239d | ||
|
|
c848bfc228 | ||
|
|
f823057cbe | ||
|
|
d7a1acd23b | ||
|
|
70053c9279 | ||
|
|
1c76c7d797 | ||
|
|
dfffbff7c6 | ||
|
|
a4b1ed09a2 | ||
|
|
a1bd681cbf | ||
|
|
9c57677320 | ||
|
|
956e982157 | ||
|
|
4bd10894a8 | ||
|
|
89a9863510 | ||
|
|
ed36e53a28 | ||
|
|
8977e0fbc3 | ||
|
|
cf7e0c740b | ||
|
|
12b18cff58 | ||
|
|
3160723aa7 | ||
|
|
8e2feb5ac2 | ||
|
|
cbc7424a97 | ||
|
|
1e7c384b6d | ||
|
|
7cc2e02f47 | ||
|
|
6315c0dcc2 | ||
|
|
f06c525f5b | ||
|
|
ea5c63c1f8 | ||
|
|
ea549b63c8 | ||
|
|
e63b0f9265 | ||
|
|
cb9310437f | ||
|
|
5bc58dd7d5 | ||
|
|
5d35579e10 | ||
|
|
b0132e0b30 | ||
|
|
49ecee63d0 | ||
|
|
273eda2b67 | ||
|
|
b12f653096 | ||
|
|
05878f3fbd | ||
|
|
c583c3c3b0 | ||
|
|
2d40903069 | ||
|
|
217a445a65 | ||
|
|
b68dbe7a07 | ||
|
|
258ca9f6ef | ||
|
|
3648a36636 | ||
|
|
ef99493c7f | ||
|
|
841f7f0c8d | ||
|
|
23882e5b3b | ||
|
|
6ba21f0115 | ||
|
|
ca6dca3cb7 | ||
|
|
9072c3abe5 | ||
|
|
e74e38c6ae | ||
|
|
7a23045479 | ||
|
|
5ef449a542 | ||
|
|
a2c83f8d9c | ||
|
|
dddaf20ea2 | ||
|
|
a828bb5d3c | ||
|
|
25f5514dff | ||
|
|
34f802732b | ||
|
|
f6466b0540 | ||
|
|
7565df17ba | ||
|
|
4be33370b9 | ||
|
|
cf3f7a88fb | ||
|
|
a4d464da58 | ||
|
|
83c0a91919 | ||
|
|
85a5ce3882 | ||
|
|
77405d2dd3 | ||
|
|
1e2316e748 | ||
|
|
16014c5a42 | ||
|
|
f0be5b5ff2 |
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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()
|
||||||
|
)
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user