improve hook filters

This commit is contained in:
adbenitez
2022-12-10 19:22:57 -05:00
parent 1f7ad78f40
commit be63e18ebf
6 changed files with 87 additions and 25 deletions

View File

@@ -25,14 +25,15 @@ async def log_error(event):
logging.error(event.msg)
@hooks.on(events.NewMessage(r".+", func=lambda msg: not msg.text.startswith("/")))
async def echo(msg):
await msg.chat.send_text(msg.text)
@hooks.on(events.NewMessage(func=lambda e: not e.command))
async def echo(event):
if event.text or event.file:
await event.chat.send_message(text=event.text, file=event.file)
@hooks.on(events.NewMessage(r"/help"))
async def help_command(msg):
await msg.chat.send_text("Send me any text message and I will echo it back")
@hooks.on(events.NewMessage(command="/help"))
async def help_command(event):
await event.chat.send_text("Send me any message and I will echo it back")
async def main():