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
4
votes
2 answers

Download Image Python Telegram API

I followed their brief tutorial on downloading an image but I'm encountering an exception: telegram.photosize.PhotoSize object at ... is not JSON serializable the function for catching the images looks like this: def photo(bot, update): file_id…
marqueewinq
  • 367
  • 2
  • 12
4
votes
2 answers

Updating messages with inline keyboards using callback queries

I want to update message in chat with inline keyboard but can't understand how to receive a inline_message_id or if it only for inline queries how I can determine chat_id and message_id for using it on editMessageText(*args, **kwargs) in class…
Alex
  • 5,728
  • 5
  • 20
  • 20
4
votes
1 answer

Telegram timed response

I am currently working on a Telegram Bot using the python api. I am using this example here https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/conversationbot.py. With that example I want the bot to have a timed…
techyguy90
  • 41
  • 1
  • 2
4
votes
1 answer

How to retrieve photo of a telegram contact?

In an app, we need to import contacts of a user. We found Telegram.Link which implements Telegram API. It has a method that retrieves contacts. A single contact is showed below: { T: api.type.UserContact, id: 148049613, first_name: "M.", last_name:…
omid
  • 63
  • 1
  • 11
4
votes
2 answers

Telegram-bot (telepot api): Is it possible to send an image directly from URL without saving it

Im writing a telegram bot using the python telepot api. I'm now stuck at the point where I want to send a picture which directly comes from an URL without storing it locally. Telepot provides the following instruction to send a photo: >>> f =…
basilius
  • 57
  • 1
  • 4
3
votes
0 answers

python-telegram-bot send_voice works on Android but not on IOS and Mac

I built a Telegram chatbot using python-telegram-bot library. The problem is with send voice message from the bot to the user. The voice message plays fine on Android but it doesn't on IOS and MacOS. Here is the code where I convert the audio file…
3
votes
2 answers

TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'

It occurred when I perform this : updater = Updater('xyaz:testtsttttt-HI', use_context=True) Many Thanks!
3
votes
6 answers

ModuleNotFoundError: No module named 'telegram.ext'; 'telegram' is not a package

I tried: pip install python-telegram-bot pip3 install python-telegram-bot pip install telegram pip3 install telegram But the error keeps showing up telling me there is no such package of 'telegram.ext' offered by python-telegram-bot. However, my…
user19499885
  • 71
  • 1
  • 1
  • 5
3
votes
2 answers

How do I avoid using global variables when writing a Telegram bot

I'm writing a Telegram bot on Python using the python-telegram-bot library. The bot's function is to look up POIs around a given location. I have a ConversationHandler with 8 states, and I need to pass some data between those functions, such as the…
3
votes
2 answers

"telegram.error.BadRequest: Entities_too_long" error when trying to send long markdown message. What is the max string length limit?

This is the error i get when i try to send a long markdown message which has a ton of formatted hyperlinks in it: context.bot.send_message(chat_id=update.effective_chat.id, text=longmsg, parse_mode="MARKDOWN") #Output: telegram.error.BadRequest:…
English Rain
  • 311
  • 5
  • 13
3
votes
1 answer

Unable to pass args to context.job_queue.run_once in Python Telegram bot API

In the following code how can we pass the context.args and context to another function, in this case callback_search_msgs def search_msgs(update, context): print('In TG, args', context.args) context.job_queue.run_once(callback_search_msgs,…
Vivek Singh
  • 346
  • 3
  • 14
3
votes
1 answer

Telegram Payment 2.0 API: How do I work around with this with answerShippingQuery and answerPreCheckoutQuery?

With the 26th April update on Telegram introducing the Payments 2.0 feature along with other minor features, I’ve decided to build a Telegram bot that included these features. However, since this is a recent update with limited example documentation…
3
votes
1 answer

python-telegram-bot - sending message

I'm trying to send a message using Python-Telegram-Bot without waiting for a user response but can't get it to work and I get no errors. Code: def echo(context): context.bot.send_message(chat_id=-516017547, text='test') #chat_id is the…
squidg
  • 451
  • 6
  • 17
3
votes
2 answers

Telegram bot await reply from user after command Python

I'm looking for a way for a bot to wait for a reply from a user after a command. For example, you first type "/ask", then the bot waits for a plain message (not a command) from the user and after the user replies is stores his/her reply in a…
3
votes
1 answer

aiogram message handler not firing for a message containing media

I am using aiogram 2.11.2 as Python interface to the Telegram API, but I am encountering an issue in the simplest callback: it does activate when the message is text only, but fails whenever any media is attached. This includes photos, videos,…
davide m.
  • 452
  • 4
  • 19