from telethon import TelegramClient, events, types from telethon.tl.functions.messages import SendReactionRequest from telethon.errors.rpcerrorlist import ReactionInvalidError import random # Config from https://my.telegram.org/auth api_id = 123456 # your api id here api_hash = 'aajwjwjwjwjwiwiwisdjsdjsddsk' # you api hash here chat_to_react = 'My chat' # Chat name or ID if possible # Create a Telegram client with your API ID and API hash client = TelegramClient('session_name', api_id, api_hash) # Define a list of possible reactions reactions = ['โค๏ธ', '๐Ÿ‘', '๐Ÿ˜ข', '๐Ÿฅฐ', '๐Ÿ˜ก', '๐Ÿคฏ', '๐Ÿคฃ', '๐Ÿ˜', '๐Ÿคก', '๐Ÿ™‰', '๐Ÿ˜ฑ', '๐Ÿคฉ', '๐Ÿ˜จ', '๐ŸŒ', '๐Ÿ–•', '๐Ÿคฎ', '๐Ÿ’Š', '๐Ÿ†', '๐Ÿ˜‡', '๐Ÿ‘Œ', '๐Ÿ˜ญ', '๐Ÿ‘Ž', '๐Ÿ”ฅ', '๐Ÿ‘', '๐Ÿค”', '๐Ÿคฌ', '๐ŸŽ‰', '๐Ÿ’ฉ', '๐Ÿ™', '๐Ÿ•Š', '๐Ÿฅฑ', '๐Ÿฅด', '๐Ÿณ', '๐ŸŒš', '๐ŸŒญ', '๐Ÿ’ฏ', 'โšก๏ธ', '๐Ÿ’”', '๐Ÿคจ', '๐Ÿ˜', '๐Ÿ“', '๐Ÿพ', '๐Ÿ’‹', '๐Ÿ˜ˆ', '๐Ÿ˜ด', '๐Ÿค“', '๐Ÿ‘ป', '๐Ÿ‘€', '๐ŸŽƒ', '๐Ÿ™ˆ', '๐Ÿค', 'โœ๏ธ', '๐Ÿค—', '๐Ÿซก', '๐ŸŽ…', '๐Ÿ’…', '๐Ÿคช', '๐Ÿ—ฟ', '๐Ÿ†’', '๐Ÿ’˜', '๐Ÿฆ„', '๐Ÿ˜˜', '๐Ÿ™Š', '๐Ÿ˜Ž', '๐Ÿ‘พ', '๐Ÿคท', 'โ˜ƒ๏ธ', '๐ŸŽ„', '๐Ÿ˜', '\u2764\uFE0F\u200D\U0001f525', # heart on fire '\U0001F937\u200Dโ™‚๏ธ', # blue man doesn't know '\U0001F468\u200D\U0001F4BB', # man on the laptop '\U0001F937\u200Dโ™€๏ธ' # woman doesn't know ] # Handler @client.on(events.NewMessage(chats=[chat_to_react])) async def react(event): async def _react(): reaction = random.choice(reactions) try: await client(SendReactionRequest( peer=await event.get_chat(), msg_id=event.id, reaction=[types.ReactionEmoji( emoticon=reaction )] )) except ReactionInvalidError: print(f'This reaction {reaction} is not possible') await _react() await _react() client.start() client.run_until_disconnected()