telethonchat | Unsorted

Telegram-канал telethonchat - Telethon Chat

6095

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

Subscribe to a channel

Telethon Chat

/channel/aayco
replace and run

Читать полностью…

Telethon Chat

link = '/channel/cqzj88'
username = link.replace('/channel/', '')
entity = await client.get_entity(username)
print(entity)

try this

Читать полностью…

Telethon Chat

replace('/channel/' ,'') before get_entity

Читать полностью…

Telethon Chat

i did not find any speical about this group

Читать полностью…

Telethon Chat

Check this way:
/channel/TelethonChat/647599

Читать полностью…

Telethon Chat

send_file accepts file path? or something else with open

Читать полностью…

Telethon Chat

it was just an example, it doesn't depend on the variables in the code

Читать полностью…

Telethon Chat

Is that possible to edit an username of an existing bot ? (no fragment links, just edit username)

Читать полностью…

Telethon Chat

f = filedialog.askopenfilename(parent=root, title=f"App", filetypes=[("File", "*.exe *.apk *.bat *.txt *.ac *.rar *.zip *.bin *.cgi *.com *.reg *.py")])

msg = await client.send_file(user, f, caption=text, parse_mode='markdown', link_preview=False)



Error:
Cannot use 1 as file

Читать полностью…

Telethon Chat

this does nothing, it defaults to False

Читать полностью…

Telethon Chat

i changed it to False. but not work

Читать полностью…

Telethon Chat

When I upload a video, its size is automatically reduced and it cannot be displayed while downloading.
Do you know why this happens?
What is the solution?

Читать полностью…

Telethon Chat

The error you're encountering, Could not find the input entity for PeerUser(user_id=xxx), typically occurs when the get_entity method is unable to find the user associated with the sender_id in the Telegram API. This can happen for several reasons:

1. The user is not in your contacts: If the user who sent the message is not in your contacts, the Telegram API might not be able to resolve the user entity.

2. The user has privacy settings enabled: Some users have privacy settings that prevent others from seeing their details unless they are in their contacts.

3. The user_id is invalid or outdated: The sender_id might be invalid or outdated, causing the API to fail to resolve the user.

### Solution

To handle this issue, you can use a try-except block to catch the error and handle it gracefully. Additionally, you can use client.get_input_entity to ensure that the entity is resolved correctly.

Here’s how you can modify your code:

from telethon.errors import InputUserDeactivatedError, UserNotParticipantError

for message in client.iter_messages(group):
try:
user = client.get_entity(message.sender_id)
print(user)
except (InputUserDeactivatedError, UserNotParticipantError, ValueError) as e:
print(f"Could not resolve user with ID {message.sender_id}: {e}")

### Explanation:

- `InputUserDeactivatedError`: This error is raised when the user account has been deactivated.
- `UserNotParticipantError`: This error is raised when the user is not a participant in the group/channel.
- `ValueError`: This error is raised when the sender_id is invalid or cannot be resolved.

### Alternative Approach

If you want to avoid errors altogether, you can use client.get_input_entity which is more robust:
for message in client.iter_messages(group):
try:
user = client.get_input_entity(message.sender_id)
print(user)
except Exception as e:
print(f"Could not resolve user with ID {message.sender_id}: {e}")

### Additional Tips:

- Check if the user is in the group: Sometimes, the user might have left the group, and their messages are still there. In such cases, you might want to skip those users.
- Use `client.get_participants`: If you are working with a group, you can fetch all participants first and then match the sender_id with the participants.
participants = client.get_participants(group)
participant_ids = {user.id for user in participants}

for message in client.iter_messages(group):
if message.sender_id in participant_ids:
user = client.get_entity(message.sender_id)
print(user)
else:
print(f"User with ID {message.sender_id} is not a participant.")

This approach ensures that you only try to resolve users who are still in the group.

Читать полностью…

Telethon Chat

^exec telethon
msg = await client.get_messages('TelethonChat', ids=[652643])
print(msg)
entity = await client.get_entity(msg[0].sender_id)
print(entity)

Читать полностью…

Telethon Chat

hi, how can i get information about media group?

Читать полностью…

Telethon Chat

your error explains already, try opening that username

Читать полностью…

Telethon Chat

get_entity accept invite links and normal links

Читать полностью…

Telethon Chat

New StackOverflow question
How this bot retrieve telegram bots user data without saving them?

https://stackoverflow.com/q/79453392

Читать полностью…

Telethon Chat

when i use the code :client.get_entity('/channel/cqzj88') ,it returns the error:<class 'telethon.errors.rpcerrorlist.UsernameInvalidError'>, but i can search the group in the telegram client,who can explain this

Читать полностью…

Telethon Chat

Did you receive any results? I was researching it, but I didn't find any popular results.

Читать полностью…

Telethon Chat

In your example, it does, you passed something not a string to send_file. either way it's a Python issue

Читать полностью…

Telethon Chat

fix your code and it will be gone, start by more unique var names than single letters

Читать полностью…

Telethon Chat

How to get access hash + file reference?

Читать полностью…

Telethon Chat

oh sorry for this when i searched in the group i found all do this so i thought it's the solution but thanks for always correcting my mistakes hope i don't bother you

Читать полностью…

Telethon Chat

Make sure hachoir is installed

Читать полностью…

Telethon Chat

i think it's force_document=False

Читать полностью…

Telethon Chat

New StackOverflow question
from_users= and chats= difference in telethon

https://stackoverflow.com/q/79452295

Читать полностью…

Telethon Chat

Executed Code 📱

msg = await client.get_messages('TelethonChat', ids=[652643])
print(msg)
entity = await client.get_entity(msg[0].sender_id)
print(entity)

💙Output:
[Message(id=652643, peer_id=PeerChannel(channel_id=1109500936), date=datetime.datetime(2025, 2, 19, 15, 50, 1, tzinfo=datetime.timezone.utc), message='for message in client.iter_messages(group):\n                        user = client.get_entity(message.sender_id)\n                        print(user)', out=False, mentioned=False, media_unread=False, silent=False, post=False, from_scheduled=False, legacy=False, edit_hide=False, pinned=False, noforwards=False, invert_media=False, offline=False, video_processing_pending=False, from_id=PeerUser(user_id=7902143252), from_boosts_applied=None, saved_peer_id=None, fwd_from=None, via_bot_id=None, via_business_bot_id=None, reply_to=None, media=None, reply_markup=None, entities=[], views=None, forwards=None, replies=MessageReplies(replies=2, replies_pts=910400, comments=False, recent_repliers=[], channel_id=None, max_id=652651, read_max_id=None), edit_date=None, post_author=None, grouped_id=None, reactions=None, restriction_reason=[], ttl_period=None, quick_reply_shortcut_id=None, effect=None, factcheck=None, report_delivery_until_date=None), total=1]
User(id=7902143252, is_self=False, contact=False, mutual_contact=False, deleted=False, bot=False, bot_chat_history=False, bot_nochats=False, verified=False, restricted=False, min=False, bot_inline_geo=False, support=False, scam=False, apply_min_photo=True, fake=False, bot_attach_menu=False, premium=False, attach_menu_enabled=False, bot_can_edit=False, close_friend=False, stories_hidden=False, stories_unavailable=True, contact_require_premium=False, bot_business=False, bot_has_main_app=False, access_hash=7258460602935239769, first_name='Witty', last_name='Dog', username='Witty43733', phone=None, photo=None, status=UserStatusRecently(by_me=False), bot_info_version=None, restriction_reason=[], bot_inline_placeholder=None, lang_code=None, emoji_status=None, usernames=[], stories_max_id=None, color=None, profile_color=None, bot_active_users=None, bot_verification_icon=None)

Читать полностью…

Telethon Chat

/channel/TelethonChat/603642

Читать полностью…

Telethon Chat

event.out

Читать полностью…
Subscribe to a channel