Questions tagged [python-telegram-bot]

This is a Python library that wraps around the Telegram Bot API. Note that this is not a general tag for "Telegram bots written with Python", but only for question about this particular library.

This is a library that wraps around the bot HTTP API. It is compatible with only (please check the PyPi/GitHub page for detailed info).

Telegram Bot API

The Telegram Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.

1454 questions
47
votes
7 answers

How can I send a message to someone with my telegram bot using their Username

I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number). I wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one…
30
votes
4 answers

Proper way to build menus with python-telegram-bot

I work with python-telegram-bot and try to build a system of nested menus as BotFather bot does. For instance, you have a general bot menu where you can choose "Edit Bot" and get the new corresponding menu with an option to get back to the…
DemX86
  • 422
  • 1
  • 5
  • 10
29
votes
7 answers

How To Limit Access To A Telegram Bot

When I send a message to my Telegram Bot, it responses with no problems. I wanna limit the access such that me and only me can send message to it. How can I do that?
E.B
  • 517
  • 1
  • 9
  • 17
25
votes
3 answers

Automate posting messages to a Telegram channel via API

I am new to the Telegram API. I would like to automate posting messages to my public telegram channel. I read a few posts that with bots I can achieve this, but I am not sure if that's the best way and whether the API has an option to directly…
apadana
  • 13,456
  • 15
  • 82
  • 98
24
votes
1 answer

How can I send a message to someone with telegram API using my own account

It's awesome how google something can be annoying when you can't find the right words. I found a million answers on how about to create a Telegram Bot to send and receive messages, and it's easy as write maybe five code lines. But how about managing…
Leonardo Rick
  • 680
  • 1
  • 7
  • 14
23
votes
3 answers

How to send a colored text message?

I am trying to send a colored text message to a user as reply, using sendMessage with HTML parsing. bot.sendMessage(update.message.chat_id, "foo", telegram.ParseMode.HTML) Sending
Rakete1111
  • 47,013
  • 16
  • 123
  • 162
21
votes
3 answers

In python-telegram-bot how to get all participants of the group?

In Python-telegram-bot how to get, if possible, the complete list of all participants of the group at which the bot was added?
Thomas8
  • 1,117
  • 1
  • 11
  • 22
20
votes
4 answers

How to join my Telegram Bot to PUBLIC channel

My question is: how to join my telegram bot to a telegram public channel that I am not an administrator of it, and without asking the channel's admin to add my bot to the channel? Maybe, the chatId of channel or thru link of channel? I have heard…
Nima
  • 969
  • 3
  • 10
  • 14
18
votes
3 answers

How to send telegram mediaGroup with caption/text

I'm currently using python-telegram-bot and basically what I want to achieve with it is to send telegram messages like this: So the message consists of 2+ photos/videos with text message underneath. What I've already tried: sending message with…
marzique
  • 635
  • 1
  • 7
  • 17
16
votes
4 answers

How should I use parse_mode='HTML' in telegram python bot?

I'm trying to send a message in a channel with a bot, using Telegram API's send_photo() method. It takes a caption parameter (type String) but I can't format it through parse_mode='HTML' parameter... If I use something like this: send_photo(chat_id,…
Federico
  • 415
  • 1
  • 3
  • 15
13
votes
3 answers

How to get the user's name in Telegram Bot?

I'm working in Telegram bot with a handler. where I need to get the user's name or users id once they use the command. MY CODE import telebot #Telegram Bot API bot = telebot.TeleBot() @bot.message_handler(commands=['info']) def…
11
votes
2 answers

How to send an PIL Image via telegram bot without saving it to a file

For my telegram bot (python-telegram-bot) i generated a PIL.Image.Image and i want to send it directly to a user. What works is to send an image as bufferedReader from a file, but i don't want to safe the image. I don't need it again afterwards and…
11
votes
5 answers

how save photo in telegram python bot?

i want to write a telegram bot that save photos . this is my code , but its not working. and i don't know what is my problem? def image_handler(bot, update): file = bot.getFile(update.message.photo.file_id) print ("file_id: " +…
Ali Akhtari
  • 1,211
  • 2
  • 21
  • 42
11
votes
3 answers

How to download all shared media files from a telegram group?

There is a telegram group with more than 40,000 shared files in it. Is there any bot to download all of them all at once? If not is there any telegram api script method using python to download shared media files?
Mohsen Haddadi
  • 1,296
  • 2
  • 16
  • 20
11
votes
4 answers

How To Obtain Username, First Name Or Last Name Of A Telegram User With Python-Telegram-Bot?

I'm Creating A Telegram Bot Using Python-Telegram-Bot I Know That update.message.chat_id Returns The User's Chat ID, But I Need To Know How To Get User's Username Or First Name And/Or Last Name. I've Found This On Telegram's Documentation But I…
Sadegh Alirezaie
  • 343
  • 1
  • 3
  • 17
1
2 3
96 97