Delete last update notification when new one is upstrea

pull/1/head
hikari.ftg 2022-04-06 06:03:19 +00:00
parent 1cd3302c9c
commit 29784d2e0d
2 changed files with 11 additions and 2 deletions

View File

@ -219,6 +219,7 @@ class List(InlineUnit):
parse_mode="HTML", parse_mode="HTML",
reply_markup=self._list_markup(list_uid), reply_markup=self._list_markup(list_uid),
) )
await call.answer()
except RetryAfter as e: except RetryAfter as e:
await call.answer( await call.answer(
f"Got FloodWait. Wait for {e.timeout} seconds", f"Got FloodWait. Wait for {e.timeout} seconds",
@ -275,6 +276,7 @@ class List(InlineUnit):
parse_mode="HTML", parse_mode="HTML",
reply_markup=self._list_markup(list_uid), reply_markup=self._list_markup(list_uid),
) )
await call.answer()
except RetryAfter as e: except RetryAfter as e:
await call.answer( await call.answer(
f"Got FloodWait. Wait for {e.timeout} seconds", f"Got FloodWait. Wait for {e.timeout} seconds",

View File

@ -126,7 +126,7 @@ class UpdateNotifierMod(loader.Module):
self._pending != self.get_commit() self._pending != self.get_commit()
and self._pending != self._notified and self._pending != self._notified
): ):
await self.inline.bot.send_message( m = await self.inline.bot.send_message(
self._me, self._me,
self.strings("update_required").format( self.strings("update_required").format(
self.get_commit()[:6], self.get_commit()[:6],
@ -138,9 +138,16 @@ class UpdateNotifierMod(loader.Module):
reply_markup=self._markup, reply_markup=self._markup,
) )
self._notified = self._pending
self.set("ignore_permanent", False) self.set("ignore_permanent", False)
self._notified = self._pending if self.get("upd_msg"):
try:
await self.inline.bot.delete_message(self._me, self.get("upd_msg"))
except Exception:
pass
self.set("upd_msg", m.message_id)
except Exception: except Exception:
# We need to catch error manually because of # We need to catch error manually because of
# `ensure_future` # `ensure_future`