An idea to create social media graphics easily
A Pen by Amir Yousefi on CodePen.
user_input_channel = input("enter entity(telegram URL or entity id):") | |
if user_input_channel.isdigit(): | |
entity = PeerChannel(int(user_input_channel)) | |
else: | |
entity = user_input_channel | |
my_channel = client.get_entity(entity) |
offset = 0 | |
limit = 100 | |
all_participants = [] | |
while True: | |
participants = client(GetParticipantsRequest( | |
my_channel, ChannelParticipantsSearch(''), offset, limit, | |
hash=0 | |
)) |
all_user_details = [] | |
for participant in all_participants: | |
all_user_details.append( | |
{"id": participant.id, "first_name": participant.first_name, "last_name": participant.last_name, | |
"user": participant.username, "phone": participant.phone, "is_bot": participant.bot}) | |
with open('user_data.json', 'w') as outfile: | |
json.dump(all_user_details, outfile) | |
offset_id = 0 | |
limit = 100 | |
all_messages = [] | |
total_messages = 0 | |
total_count_limit = 0 | |
while True: | |
print("Current Offset ID is:", offset_id, "; Total Messages:", total_messages) | |
history = client(GetHistoryRequest( |
import configparser | |
import json | |
from telethon import TelegramClient | |
from telethon.errors import SessionPasswordNeededError | |
# Reading Configs | |
config = configparser.ConfigParser() | |
config.read("config.ini") | |
# Setting configuration values | |
api_id = config['Telegram']['api_id'] | |
api_hash = config['Telegram']['api_hash'] | |
api_hash = str(api_hash) |
[Telegram] | |
# no need for quotes | |
# you can get telegram development credentials in telegram API Development Tools | |
api_id = Telegram-API-ID | |
api_hash = Telegram-API-Hash | |
# use full phone number including + and country code | |
phone = Your-Telegram-Phone-Number | |
username = Your-Telegram-Username |
# Create the client and connect | |
client = TelegramClient(username, api_id, api_hash) | |
client.start() | |
print("Client Created") | |
# Ensure you're authorized | |
if not client.is_user_authorized(): | |
client.send_code_request(phone) | |
try: | |
client.sign_in(phone, input('Enter the code: ')) | |
except SessionPasswordNeededError: |