Last active
August 23, 2023 16:53
-
-
Save B1Z0N/ba82dc202da85f7b6c82612ec915ec3b to your computer and use it in GitHub Desktop.
A piece of code that will allow you to spam with reactions on a new message in a chat. Requires telethon installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment