-2

This code does not work - I need help. I want to re-send a specific message.

@events.register(events.NewMessage(chats='AAAAA'))
async def me_handler(event):
  client = event.client
if 'AAAAAAAA' in event.raw_text:
 async def main(event):
 await event.forward_to('AAAAA')

Expected an indented block

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

You need an extra indent after async def main(event)::

@events.register(events.NewMessage(chats='AAAAA'))
async def me_handler(event):
    client = event.client

if 'AAAAAAAA' in event.raw_text:
    async def main(event):
        await event.forward_to('AAAAA')

Additionally, is is recommended by PEP8 to use 4 spaces per indent. I found your code harder to read with such little indentation.

Duarte P
  • 154
  • 12
  • I already applied that measure and it does not give me an indentation error but it does not perform the operation, it runs without errors but it does not forward the message – Guillermo Marquez Fuentes Jun 24 '22 at 21:10
  • It is a code that I want it to detect when a specific message enters a bot and that message is forwarded by the code to another bot in telegram – Guillermo Marquez Fuentes Jun 24 '22 at 21:20
  • The original question doesn't mention anything about telegram or bots, just the indentation error. I suggest you create another question with those details, what's your objective and which libraries are you using. – Duarte P Jun 24 '22 at 21:49
  • You seem inexperienced with python - if so, I'd suggest to start with some tutorials before. – Duarte P Jun 24 '22 at 21:51
  • hi thanks the code is fixed: `@events.register(events.NewMessage(chats='AAAAA')) async def me_handler(event): client = event.client if 'AAAAAAAA' in event.raw_text: await event.forward_to('AAAAA')` – Guillermo Marquez Fuentes Jun 25 '22 at 03:42