Created
April 4, 2021 09:06
-
-
Save moenk/b709dc445d1df9e8b56374f18e6adbc5 to your computer and use it in GitHub Desktop.
Python telegram send bulk messages to all contacts
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.sync import TelegramClient | |
from telethon.tl.types import InputPeerUser | |
from telethon import functions | |
from time import sleep | |
api_id = 359*** | |
api_hash = 'fe0b***' | |
with TelegramClient("moenk", api_id, api_hash) as client: | |
contacts = client(functions.contacts.GetContactsRequest(hash=0)) | |
for u in contacts.users: | |
sleep(2) | |
print(u.username) | |
client.send_message(InputPeerUser(u.id, u.access_hash), "Frohe Ostern! Urbi et orbi.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment