mirror of https://github.com/coddrago/Heroku
1.0.6: Add `callback`s to inline query answers
parent
74e6bbdad6
commit
d3144fcebd
|
@ -114,7 +114,8 @@ class Events(InlineUnit):
|
|||
thumb_width=128,
|
||||
thumb_height=128,
|
||||
reply_markup=self._generate_markup(
|
||||
res.get("reply_markup", None)
|
||||
res.get("reply_markup", None),
|
||||
prepare_callbacks=True,
|
||||
),
|
||||
)
|
||||
]
|
||||
|
@ -299,7 +300,7 @@ class Events(InlineUnit):
|
|||
return
|
||||
|
||||
await self._custom_map[query.data]["handler"](
|
||||
query,
|
||||
InlineCall(query, self, None),
|
||||
*self._custom_map[query.data].get("args", []),
|
||||
**self._custom_map[query.data].get("kwargs", {}),
|
||||
)
|
||||
|
|
|
@ -30,6 +30,7 @@ class Utils(InlineUnit):
|
|||
self,
|
||||
form_uid: Union[str, list],
|
||||
/,
|
||||
prepare_callbacks: bool = False,
|
||||
) -> Union[None, InlineKeyboardMarkup]:
|
||||
"""Generate markup for form or list of `dict`s"""
|
||||
if not form_uid:
|
||||
|
@ -80,6 +81,35 @@ class Utils(InlineUnit):
|
|||
callback_data=button["_callback_data"],
|
||||
)
|
||||
]
|
||||
if prepare_callbacks:
|
||||
self._custom_map[button["_callback_data"]] = {
|
||||
"handler": button["callback"],
|
||||
**(
|
||||
{"always_allow": button["always_allow"]}
|
||||
if button.get("always_allow", False)
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
{"args": button["args"]}
|
||||
if button.get("args", False)
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
{"kwargs": button["kwargs"]}
|
||||
if button.get("kwargs", False)
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
{"force_me": True}
|
||||
if button.get("force_me", False)
|
||||
else {}
|
||||
),
|
||||
**(
|
||||
{"disable_security": True}
|
||||
if button.get("disable_security", False)
|
||||
else {}
|
||||
),
|
||||
}
|
||||
elif "input" in button:
|
||||
line += [
|
||||
InlineKeyboardButton(
|
||||
|
@ -208,7 +238,9 @@ class Utils(InlineUnit):
|
|||
parse_mode="HTML",
|
||||
disable_web_page_preview=disable_web_page_preview,
|
||||
reply_markup=self._generate_markup(
|
||||
reply_markup if isinstance(reply_markup, list) else unit.get("buttons", [])
|
||||
reply_markup
|
||||
if isinstance(reply_markup, list)
|
||||
else unit.get("buttons", [])
|
||||
),
|
||||
)
|
||||
except MessageNotModified:
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = (1, 1, 5)
|
||||
__version__ = (1, 1, 6)
|
||||
|
|
Loading…
Reference in New Issue