mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Merge ced6a99361 into e4d3692ac2
This commit is contained in:
commit
34cf8e765a
3 changed files with 9 additions and 2 deletions
|
|
@ -21,7 +21,7 @@ def check_signature(token: str, hash: str, **kwargs: Any) -> bool:
|
||||||
check_string.encode("utf-8"),
|
check_string.encode("utf-8"),
|
||||||
digestmod=hashlib.sha256,
|
digestmod=hashlib.sha256,
|
||||||
).hexdigest()
|
).hexdigest()
|
||||||
return hmac_string == hash
|
return hmac.compare_digest(hmac_string, hash)
|
||||||
|
|
||||||
|
|
||||||
def check_integrity(token: str, data: dict[str, Any]) -> bool:
|
def check_integrity(token: str, data: dict[str, Any]) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,10 @@ class Backoff:
|
||||||
await asyncio.sleep(next(self))
|
await asyncio.sleep(next(self))
|
||||||
|
|
||||||
def _calculate_next(self, value: float) -> float:
|
def _calculate_next(self, value: float) -> float:
|
||||||
return normalvariate(min(value * self.factor, self.max_delay), self.jitter)
|
return max(
|
||||||
|
self.min_delay,
|
||||||
|
normalvariate(min(value * self.factor, self.max_delay), self.jitter),
|
||||||
|
)
|
||||||
|
|
||||||
def __next__(self) -> float:
|
def __next__(self) -> float:
|
||||||
self._current_delay = self._next_delay
|
self._current_delay = self._next_delay
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,10 @@ class MediaGroupBuilder:
|
||||||
|
|
||||||
:return: List of media objects.
|
:return: List of media objects.
|
||||||
"""
|
"""
|
||||||
|
if not self._media:
|
||||||
|
msg = "Media group must contain at least one media element"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
update_first_media: dict[str, Any] = {"caption": self.caption}
|
update_first_media: dict[str, Any] = {"caption": self.caption}
|
||||||
if self.caption_entities is not None:
|
if self.caption_entities is not None:
|
||||||
update_first_media["caption_entities"] = self.caption_entities
|
update_first_media["caption_entities"] = self.caption_entities
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue