code: async def wait_event(self, event, *, timeout=None):
          
          start_time = time.time()
          if isinstance(event, type):
              event = event()
  
          await event.resolve(self._client)
  
          counter = Conversation._custom_counter
          Conversation._custom_counter += 1
  
          future = asyncio.Future(loop=self._client.loop)
  
          # We need the `async def` here because we want to block on the future
          # from `_get_result` by using `await` on it. If we returned the future
          # immediately we would `del` from `_custom` too early.
  
          async def result():
              try:
                  return await self._get_result(future, start_time, timeout)
              finally:
                  del self._custom[counter]
  
          self._custom[counter] = (event, future)
          return await result()
docs: Waits for a custom event to occur. Timeouts still apply.
  
          Unless you're certain that your code will run fast enough,
          generally you should get a "handle" of this special coroutine
          before acting. Generally, you should do this:
  
          >>> from telethon import TelegramClient, events
          >>>
          >>> client = TelegramClient(...)
          >>>
          >>> async def main():
          >>>     async with client.conversation(...) as conv:
          >>>         response = conv.wait_event(events.NewMessage(incoming=True))
          >>>         await conv.send_message('Hi')
          >>>         response = await response
  
          This way your event can be registered before acting,
          since the response may arrive before your event was
          registered. It depends on your use case since this
          also means the event can arrive before you send
          a previous action.