Added ability to add reactions

This commit is contained in:
2026-11-13 16:11:42 +03:00
parent 4b4c434bd8
commit 05a286b57a
2 changed files with 33 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ from mab import *
from _environment import check_environment
async def on_specific_reaction(ctx: EventContext, vars: ContextVars) -> None:
"""This callback is called when a reaction is added."""
"""This callback is called when a specific reaction is added."""
sender = vars[CTX_REACTION].sender
reaction = vars[CTX_REACTION].reaction
response = f"(Specific reaction) {sender}: {reaction}"
@@ -33,6 +33,10 @@ async def on_reaction(ctx: EventContext, vars: ContextVars) -> None:
response
)
async def on_message(ctx: EventContext, vars: ContextVars) -> None:
"""This callback is called when a message is received."""
await ctx.bot.send.reaction(ctx.room, vars[CTX_ROOM_EVENT].event_id, "👀")
async def main() -> None:
"""Application entry point"""
logging.basicConfig(level=logging.INFO)
@@ -51,6 +55,9 @@ async def main() -> None:
bot.add_callback(
~SenderIsBotFilter() & MessageReactionFilter(),
on_reaction)
bot.add_callback(
~SenderIsBotFilter() & NewMessageFilter(),
on_message)
# run until Ctrl+C
try: