Похожие чаты

From telethon.sync import TelegramClient, events # Replace these with your actual

API ID, hash, and phone number
api_id = YOUR_API_ID
api_hash = 'YOUR_API_HASH'
phone_number = 'YOUR_PHONE_NUMBER'

# Create a TelegramClient instance
client = TelegramClient('session_name', api_id, api_hash)

@client.on(events.NewMessage)
async def my_event_handler(event):
# This function will be called whenever a new message arrives
sender = await event.get_sender()
print(f"New message from: {sender.username} - Message: {event.text}")

# Start the client and begin listening for events
with client:
client.run_until_disconnected()

This code ask me to enter phone number, so the session file not works. Right?

7 ответов

4 просмотра

from telethon import TelegramClient from telethon.sessions import StringSession STRING_SESSION = " " client = TelegramClient(StringSession(STRING_SESSION), API_ID, API_HASH)

Monsoon Malabar- Автор вопроса
{🇮🇳} 𝗕ooo™  ‌ [ᴀꜰᴋ] ᴏꜰꜰʟɪɴᴇ
from telethon import TelegramClient from telethon....

client = TelegramClient(StringSession(STRING_SESSION), api_id, api_hash) File "/home/admin/.local/lib/python3.9/site-packages/telethon/sessions/string.py", line 33, in init raise ValueError('Not a valid string') ValueError: Not a valid string

Monsoon Malabar- Автор вопроса

from telethon import TelegramClient from telethon.sessions import StringSession STRING_SESSION = "+918xxxxx55.session" # Replace these with your actual API ID, hash, and phone number api_id = xxxxxx api_hash = 'xxxxxxxxx' phone_number = '+9183xxxxxx55' client = TelegramClient(StringSession(STRING_SESSION), api_id, api_hash) # Create a TelegramClient instance @client.on(events.NewMessage) async def my_event_handler(event): # This function will be called whenever a new message arrives sender = await event.get_sender() print(f"New message from: {sender.username} - Message: {event.text}") # Start the client and begin listening for even with client: client.run_until_disconnected() ls command gives .... ... +91833xxxxx.session ....... .....

Monsoon Malabar
from telethon import TelegramClient from telethon....

from telethon.sessions import StringSession from telethon.sync import TelegramClient APP_ID = int(input("Enter APP ID here: \n")) API_HASH = input("Enter API HASH here: \n") with TelegramClient(StringSession(), APP_ID, API_HASH) as client: try: session = client.session.save() client.send_message("me", f"String Session \nTap To Copy. \n{session}") print(f"{session} & a Copy String Generated Sucessfully Check Your Saved Message.") except Exception as sed: print(f"Something Went Wrong While Generating String \nError : {sed}") Run this to generate string session first

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта