Created
October 19, 2024 17:37
-
-
Save HeySreelal/89d8ad42599d516f4d9b9677be438234 to your computer and use it in GitHub Desktop.
Pick a random member from group/channel in Telegram
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 pyrogram.client import Client | |
import asyncio | |
import random | |
api_id = 123456 # Your Telegram API ID | |
api_hash = "api-hash" # Telegram API Hash | |
chat_id = -100123456 # Group ID/Username | |
app = Client("my_account", api_id, api_hash, device_model="Random Member Picker", system_version="dev/randommember") | |
async def main(): | |
await app.start() | |
members = [] | |
async for member in app.get_chat_members(chat_id): | |
members.append(member) | |
if members: | |
random_member = random.choice(members) | |
print(f"Randomly picked member: {random_member.user.first_name}") | |
if __name__ == "__main__": | |
print("=== Telegram Random Member Picker ===") | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps:
api_id
andapi_hash
from https://my.telegram.org/, and replace it in respected variableschat_id
python main.py