Questions tagged [telethon]

Telethon is a Python 3 Telegram client library. It uses the normal Telegram API instead of the Bot API, which means it can perform all actions a regular user can perform. Use this tag when asking questions about using the Telethon library.

Python 3 Telegram client library which is used API of Telegram.

Home page: https://pypi.python.org/pypi/Telethon

1211 questions
-1
votes
1 answer

I'm getting trouble with subprocess.Popen and split command in python

Actually I want to edit my python script ( for running tg bot ) such that when i trigger command it actually has some pre defined command before that. Like instead of typing whole command, /run bash test.sh url it should work for /run url. In short,…
-1
votes
2 answers

How do I get the other user's id from a chat in Telegram?

I wonder how I can find the id of a certain user I started a regular or secret chat with. Example: dialogs=client.get_dialogs() for dialog in dialogs: print(dialog.peerUser_id) What can substitute the peerUser_id? Note: I use Telethon Library
-1
votes
1 answer

How to use parse mode in telegram send message bot in Python

I'm pretty new to making bot thing so I have several questions I want to ask regarding this: I'm using a bot to send message by def send_message(chat_id, msg): url =…
Tsukiakari
  • 1
  • 1
  • 1
-1
votes
2 answers

AttributeError in MessageFwdHeader telethon library

I'm getting AttributeError in my code. How can I fix it please from telethon import events @client.on(events.NewMessage(func=lambda e: e.is_private)) async def _(event): x = await event.get_reply_message() if x is None: return …
Lee
  • 17
  • 1
  • 1
  • 3
-1
votes
1 answer

How to solve error on sending game action

Im trying to send gaming action but i got this error : Connot cast event to any kind of peer This is my code : gaming = "on" @client.on(events.NewMessage) def handler(event): global gaming if gaming == "on": async with…
-1
votes
2 answers

How telegram bot knows where to respond?

I am using telethon and I have a question that how telegram knows where to send the request? I have created a bot on telegram. When the user sends a message to the bot then how telegram knows where to redirect that message. I run my program in my…
Swarnim Kumar
  • 335
  • 5
  • 21
-1
votes
1 answer

How to solve telethon UnboundLocalError

I get this error on the last line of my code. If anyone has encountered with the same problem, I'll be glad to share with me on how to solve it. The source code is telethon based and is full. The execution is also successful but when wanna give…
Lee
  • 17
  • 1
  • 1
  • 3
-1
votes
2 answers

Scraping online and last seen recently users from Telegram chats

I want to scrape a Telegram group with Telethon API. But this code scrapes all users in the group. But I want to scrape only online and last seen recently users. How to do it? from telethon.sync import TelegramClient from…
-1
votes
1 answer

How to break conversation when sending another command

I'm using PyTelegramApi library. My bot has 4 buttons that each do a different action. How can I break the conversation when the user click on "back" button or send another command? For exmple: /start -> click on new post button. Bot: Hi, send…
-1
votes
1 answer

How to use InputPhoto in Telethon?

I want to take nicknames and photos of all chat participants in telegram. For this I have code like this: client = TelegramClient(username, api_id, api_hash) async def dump_all_participants(channel) -> list: offset_user = 0 limit_user =…
Dima
  • 107
  • 1
  • 1
  • 7
-1
votes
1 answer

Get Telegram group members (group has no invite link and no name)

How to get list of all members from private Telegram group which I participate, by having just a group id (like s1234567890_12345678901234567890) and using Python Telethon library? Later, I want to send private message from my account to the few of…
wowkin2
  • 5,895
  • 5
  • 23
  • 66
-1
votes
1 answer

Method GetUserPhotosRequest for file_reference

I try get file_file_reference, but can't decode result with TelegramClient('anon', api_id, api_hash) as client: result = client(functions.photos.GetUserPhotosRequest( user_id='******', offset=0, max_id=0, …
Not Found
  • 11
  • 2
-1
votes
1 answer

i want to send an auto reply to a new chat with whom i havent had a conversation earlier on Telegram

I'm new to Python and Telethon. I've gone through the documentation of Telethon module. I would like to send auto reply to a new person if they send me a message on Telegram private message. I've found one (in this gist) which sends an autoreply to…
striker21
  • 3
  • 3
-1
votes
1 answer

How to get URLs from inline-keyboard message? (Telethon)

As title says, I have a message containing Inline-keyboard with command and URL buttons. I need a URL which is in a specific button. PS : I've looked in the documentation and issues several times but there is only click command. I want to print its…
-1
votes
1 answer

Can I read and post in telegram groups without admin priviledges

I am new to telegram bots , figured out how to send messages with bot to my group as admin but is it possible to send and read messages to other groups as a member only ?
itneg
  • 73
  • 1
  • 10