mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-18 04:20:57 +03:00
Manually set random_id in requests
Getting the response message relies on this ID. Because requests are now immutable, and resolve sets the random_id, the method to obtain the response message would lack the random_id, as the original request is not touched by resolve.
This commit is contained in:
parent
bd7675581d
commit
1f3ce07594
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user