Official Telethon's chat! Rules: • Speak English • Stay on topic (questions about Telethon) • Be respectful • Don't ask to ask • Spam-related uses lead to ban • Read https://docs.telethon.dev before asking things here Read more about us @TelethonUpdates
from telethon import TelegramClient, errors
api_id = '1234'
api_hash = 'abcdefgh'
client = TelegramClient('ankit', api_id, api_hash)
async def check():
try:
await client.connect()
if await client.is_user_authorized():
try:
await client.get_messages('me')
print("Session is authorized and active")
return
except errors.AuthKeyUnregisteredError:
print("Session terminated")
return
except errors.UserDeactivatedBanError:
print("Session banned")
return
except Exception as e:
print(f"Unexpected error while checking session: {e}")
return
print("Session not authorized. Let me log in again to check the cause.")
await client.start()
print("Logged in successfully.")
except errors.AuthKeyUnregisteredError:
print("Session terminated")
except errors.UserDeactivatedBanError:
print("Session banned")
except Exception as e:
print(f"Unexpected error: {e}")
finally:
await client.disconnect()
import asyncio
asyncio.run(check())
Error: The used phone number has been banned from Telegram and cannot be used anymore. Maybe check https://www.telegram.org/faq_spam (caused by SendCodeRequest).
await client.start()Читать полностью…
print("Logged in successfully.")
Did you find a solution?
/channel/TelethonChat/659141
Does anyone have an idea about hunting old accounts in Telegram?
Читать полностью…from telethon import TelegramClient, errors
api_id = 1234
api_hash = abcdefgh
client = TelegramClient('session', api_id, api_hash)
async def check():
try:
await client.connect()
print("Active")
except errors.AuthKeyUnregisteredError:
print("Session terminated")
except errors.UserDeactivatedBanError:
print("Session banned")
finally:
await client.disconnect()
with client:
client.loop.run_until_complete(check())
Not working even the account is banned but it will goes in .is_user_authorized
Читать полностью…Hi. How can I check that the created group created ? I add username to supergroup no error happens but then realise the group can not be found via the username.
Читать полностью…yo, what's the event when user joins? because
if update.chat_member.new_chat_member.status == ChatMemberStatus.MEMBER:
because it makes broken code if you want to use it check code before send
Читать полностью…why
button = message.buttons[0][0]
button.url
return only web url
i want with query id and all other things
how we can achieve this
Don't use the bound method, it doesn't support user profile buttons, use client.edit_message() directly, if you must retain the buttons, reconstruct the Input version from the Keyboard one
Читать полностью…client.connect() never raises errors. so excepts won't be reached, you must do any high-level request
Читать полностью…Please advise why this is happening and how to bypass it so that the program runs stably
Читать полностью…On a callbackquery
msg = await event.get_message()
await msg.edit(msg.text + "12")
I get ButtonTypeInvalidError, I'm assuming it's because one of my button is InputKeyboardButtonUserProfile. Is there any way to edit the messages without interacting with buttons
Hello, why this does not detects if message is in group with topics?if hasattr(message, "forum_topic") and message.forum_topic
As I understand, it won't help much in my case. I am also getting an entity to check if it's a private chat or not, and with input_entity it's impossible (?)
Читать полностью…how is caching entities work? for example I use get_input_entity
and then get_entity
for the same entity a few times and it still tries to resolve username. I use /channel/{group} as argument
chatgpt don't know the simple docs so if you want to use it you will need to check docs to fix his issues or send him docs links and tell him to make code using it
Читать полностью…Yeah but if you know coding chat gpt can be pretty useful
Читать полностью…i found it
from telethon.tl.functions.messages import RequestWebViewRequestЧитать полностью…
final_url = await client(RequestWebViewRequest(bot, bot, platform='android', url=url))