Event filters
Filters needs to filtrate events with sender or another parameters.
bot.py structure
from mxbt import Bot, Context, Creds, Fitler, Listener
import asyncio
bot = Bot(
prefix="!", # Standart command prefix, commands can setup it own prefix
creds=Creds.from_json_file(
"credits.json" # You can also make Credits object via providing Dict with same structure
)
)
lr = Listener(bot)
@lr.on_command(aliases=["echo", "e"]) # Usage of prefix is optional
@Filter.from_users(['@username:matrix.org']) # Event received only from this senders
async def ctx_echo(ctx: Context) -> None: # Context object contains main info about event
await ctx.reply(ctx.body) # Reply message to event room
if __name__ == "__main__":
asyncio.run(lr.start_polling()) # Run bot event loop