diff --git a/telethon/_client/messages.py b/telethon/_client/messages.py index e2065c7b..1949ee89 100644 --- a/telethon/_client/messages.py +++ b/telethon/_client/messages.py @@ -4,6 +4,7 @@ import time import typing import warnings import dataclasses +import os from .._misc import helpers, utils, requestiter, hints from ..types import _custom @@ -486,7 +487,8 @@ async def send_message( entity, message._file._media, reply_to_msg_id=reply_to, message=message._text, entities=message._fmt_entities, reply_markup=message._reply_markup, silent=message._silent, schedule_date=schedule, clear_draft=clear_draft, - background=background, noforwards=noforwards, send_as=send_as + background=background, noforwards=noforwards, send_as=send_as, + random_id=int.from_bytes(os.urandom(8), 'big', signed=True), ) else: request = _tl.fn.messages.SendMessage( @@ -501,7 +503,8 @@ async def send_message( reply_markup=_custom.button.build_reply_markup(buttons), schedule_date=schedule, noforwards=noforwards, - send_as=send_as + send_as=send_as, + random_id=int.from_bytes(os.urandom(8), 'big', signed=True), ) result = await self(request) @@ -574,7 +577,8 @@ async def forward_messages( with_my_score=with_my_score, schedule_date=schedule, noforwards=noforwards, - send_as=send_as + send_as=send_as, + random_id=[int.from_bytes(os.urandom(8), 'big', signed=True) for _ in chunk], ) result = await self(req) sent.extend(self._get_response_message(req, result, entity)) diff --git a/telethon/types/_custom/inlineresult.py b/telethon/types/_custom/inlineresult.py index 45867edb..84d8f64d 100644 --- a/telethon/types/_custom/inlineresult.py +++ b/telethon/types/_custom/inlineresult.py @@ -1,5 +1,6 @@ from ... import _tl from ..._misc import utils +import os class InlineResult: @@ -162,7 +163,8 @@ class InlineResult: clear_draft=clear_draft, hide_via=hide_via, reply_to_msg_id=reply_id, - send_as=send_as + send_as=send_as, + random_id=int.from_bytes(os.urandom(8), 'big', signed=True), ) return self._client._get_response_message( req, await self._client(req), entity) diff --git a/telethon/types/_custom/messagebutton.py b/telethon/types/_custom/messagebutton.py index eee4486e..ce5f7ed1 100644 --- a/telethon/types/_custom/messagebutton.py +++ b/telethon/types/_custom/messagebutton.py @@ -115,7 +115,8 @@ class MessageButton: return await self._client.get_entity(self.button.user_id) elif isinstance(self.button, _tl.KeyboardButtonSwitchInline): return await self._client(_tl.fn.messages.StartBot( - bot=self._bot, peer=self._chat, start_param=self.button.query + bot=self._bot, peer=self._chat, start_param=self.button.query, + random_id=int.from_bytes(os.urandom(8), 'big', signed=True), )) elif isinstance(self.button, _tl.KeyboardButtonUrl): return self.button.url