from_user = await event.client.get_entity(event.from_id) if from_user.phone == phone: print(time.asctime(), '-', event.message) # tested on a real girl, she figured it out at the second reply # so randomly choose to reply within 5 - 59 seconds await asyncio.sleep(random.randrange(5, 59)) if random.choice([True, False]): i, s = random.randrange(2, 5), random.choice(greetings) # typing 2 - 5 seconds asyncwith client.action(phone, 'typing'): await asyncio.sleep(i) await client.send_message(phone, s)
client = TelegramClient('session', api_id, api_hash) greetings = ['Yo!', 'Hi', 'Hello', 'How have you been?', 'How are you?', 'What\'s up today?', 'How are you doing?', 'How\’s it going?']