From 3089669a1ea0602d1645dcffacf4254e04011e27 Mon Sep 17 00:00:00 2001 From: "hikari.ftg" Date: Mon, 28 Mar 2022 10:38:50 +0000 Subject: [PATCH] Add gallery floodwait handler --- hikka/inline/gallery.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hikka/inline/gallery.py b/hikka/inline/gallery.py index 6a18fac..0c07865 100644 --- a/hikka/inline/gallery.py +++ b/hikka/inline/gallery.py @@ -10,7 +10,7 @@ from aiogram.types import ( InlineQuery, ) -from aiogram.utils.exceptions import InvalidHTTPUrlContent, BadRequest +from aiogram.utils.exceptions import InvalidHTTPUrlContent, BadRequest, RetryAfter from typing import Union, List from types import FunctionType @@ -271,6 +271,10 @@ class Gallery(InlineUnit): ), reply_markup=self._gallery_markup(btn_call_data), ) + except RetryAfter as e: + await call.answer( + f"Got FloodWait. Wait for {e.timeout} seconds", show_alert=True + ) except Exception: logger.exception("Exception while trying to edit media") await call.answer("Error occurred", show_alert=True) @@ -344,6 +348,10 @@ class Gallery(InlineUnit): ] self._galleries[gallery_uid]["current_index"] -= 1 await self._gallery_next(call, btn_call_data, func, gallery_uid) + except RetryAfter as e: + await call.answer( + f"Got FloodWait. Wait for {e.timeout} seconds", show_alert=True + ) except Exception: logger.exception("Exception while trying to edit media") await call.answer("Error occurred", show_alert=True)