mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Readd legacy keyboard registration
This commit is contained in:
parent
81cc77dd66
commit
1ff3d6edd4
2 changed files with 18 additions and 2 deletions
|
@ -80,3 +80,11 @@ class CommandData:
|
||||||
async def keyboard(self, text, keys: List["KeyboardKey"]):
|
async def keyboard(self, text, keys: List["KeyboardKey"]):
|
||||||
yield
|
yield
|
||||||
raise UnsupportedError(f"{self.keyboard.__name__} is not supported")
|
raise UnsupportedError(f"{self.keyboard.__name__} is not supported")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_keyboard_key(cls, identifier: str, key: "KeyboardKey"):
|
||||||
|
raise UnsupportedError(f"{cls.register_keyboard_key.__name__} is not supported")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def unregister_keyboard_key(cls, identifier: str):
|
||||||
|
raise UnsupportedError(f"{cls.unregister_keyboard_key.__name__} is not supported")
|
||||||
|
|
|
@ -147,7 +147,7 @@ class TelegramSerf(Serf):
|
||||||
for key in keys:
|
for key in keys:
|
||||||
uid: str = str(uuid.uuid4())
|
uid: str = str(uuid.uuid4())
|
||||||
key_uids.append(uid)
|
key_uids.append(uid)
|
||||||
self.key_callbacks[uid] = key
|
data.register_keyboard_key(uid, key)
|
||||||
tg_button: telegram.InlineKeyboardButton = telegram.InlineKeyboardButton(key.text,
|
tg_button: telegram.InlineKeyboardButton = telegram.InlineKeyboardButton(key.text,
|
||||||
callback_data=uid)
|
callback_data=uid)
|
||||||
tg_row: List[telegram.InlineKeyboardButton] = [tg_button]
|
tg_row: List[telegram.InlineKeyboardButton] = [tg_button]
|
||||||
|
@ -161,7 +161,15 @@ class TelegramSerf(Serf):
|
||||||
yield message
|
yield message
|
||||||
await self.api_call(message.edit_reply_markup, reply_markup=None)
|
await self.api_call(message.edit_reply_markup, reply_markup=None)
|
||||||
for uid in key_uids:
|
for uid in key_uids:
|
||||||
del self.key_callbacks[uid]
|
data.unregister_keyboard_key(uid)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_keyboard_key(cls, identifier: str, key: rc.KeyboardKey):
|
||||||
|
self.key_callbacks[identifier] = key
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def unregister_keyboard_key(cls, identifier: str):
|
||||||
|
del self.key_callbacks[identifier]
|
||||||
|
|
||||||
return TelegramMessageData
|
return TelegramMessageData
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue