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
5
votes
1 answer

How to have telegram bot post messages to my channel and not its own channel

I have a telegram bot which publishes messages to somebot using this code. import telegram from telegram import ParseMode def send_msg(text): token = '1*****:AAF*************esns' chat_id = "34*****4" bot = telegram.Bot(token=token) …
Slartibartfast
  • 1,058
  • 4
  • 26
  • 60
5
votes
2 answers

ImportError: cannot import name 'ParseMode' from 'telegram'

I am trying to create a telegram bot. The code i am trying to execute is : from telegram import ParseMode But it is throwing up this error: ImportError: cannot import name 'ParseMode' from…
5
votes
1 answer

How to solve this error : AttributeError: 'NoneType' object has no attribute 'reply_text'?

I've a button , it's supposed to return the ask_wikipedia function , so I used CallbackQueryHandler but when i want to call ask_wikipedia function i recive an attribute error ! Why? How can i fix it ? def Click_Button(update, context) : query =…
5
votes
5 answers

ModuleNotFoundError: No module named 'telegram' after pip install

After running pip install python-telegram-bot, I'm getting this error that the 'telegram' module is not found. Under pip list I see that my python-telegram-bot package is installed version 13.2 Is anyone else getting this error?
James C.
  • 71
  • 1
  • 5
5
votes
2 answers

How to send pdf file back to user using python telegram bot?

I tried to use update.sendDocument(chat_id = update.message.chat_id, document = open(something.pdf, 'b')) but it did not return me a pdf file. Any help?
codingsospls
  • 51
  • 1
  • 1
  • 2
5
votes
1 answer

Custom Persistence class for python-telegram-bot

I am developing a simple Telegram chat bot using python-telegram-bot library. My bot is currently using the ConversationHandler to keep track of the state of the conversation. I want to make the conversation persistent by storing the conversation…
Marco Gelli
  • 319
  • 2
  • 15
5
votes
1 answer

How to change inline button text when it is clicked in telegram bot?

I am pretty new in telegram bot creating. I am using python-telegram-bot module to build a telegram bot. I got stuck on implementing an inline button that changes its text when it is clicked. Can you share some source or way? Thanks in advance. In…
Madiyor
  • 761
  • 9
  • 23
5
votes
2 answers

How to format bot 'send_message' output so it aligns like a table?

I'm trying to create a simple Telegram Bot using the python-telegram-bot library, but i can't align a dictionary with the default "{0:<20} {1}".format(key, value) idea. Let me give u an example: Mapy = { "one": "1", "two": "2", "three":…
Lyux
  • 453
  • 1
  • 10
  • 22
5
votes
1 answer

Telegram bot API edit InlineKeyboard with python-telegram-bot not working

I'm trying to create a menu where the user can navigate on it. This is my code: MENU, HELP = range(2) def start(bot, update): keyboard = [ [InlineKeyboardButton('Help', callback_data='help')] ] # Create…
Kleyson Rios
  • 2,597
  • 5
  • 40
  • 65
5
votes
1 answer

add contact with telethon in python

Recently I tried to add contact in telegram with telethon, according to this tutorial: 1) Add new contact in api telegram python telethon ,I used this codes: contact = InputPhoneContact(client_id=0, phone='+989122725691', first_name="user", …
Ali Akhtari
  • 1,211
  • 2
  • 21
  • 42
5
votes
2 answers

how to send a photo via python-telegram-bot

I want the code to send a photo once the user hits the /start command and it doesn't work can anyone help me. thank you import emoji, telegram from telegram.ext import Updater from telegram.ext import CommandHandler, CallbackQueryHandler from…
roy
  • 53
  • 1
  • 1
  • 4
5
votes
2 answers

Telegram bot: how to ask for user input on button click

I've been trying to create a telegram bot. I coded in Python, following is what I did so far. import logging from telegram import InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler,…
Joe
  • 291
  • 1
  • 3
  • 18
5
votes
1 answer

Callbackquery handler issue in python telegram bot

In my code I'm facing an issue with callbackquery handler, when I'm hit /start command Next button appear and when I'm hitting on that button it gives me reply as hi, till this output is correct. Then when I'm hitting another command /help then help…
VISHAL LIMGIRE
  • 529
  • 1
  • 5
  • 21
5
votes
3 answers

How can I get Live Location in telegram bot via python?

I'm using the python-telegram-bot library. I want to track a user's Live Location, but I don't know how to do it. I try to use Job Queue: def notification(bot, job): updates = bot.get_updates() print([u.message.location for u in updates]) # Add…
Pavlo Zub
  • 51
  • 1
  • 1
  • 3
5
votes
2 answers

CallbackQueryHandler() not working

I'm trying to use CallbackQueryHandler() with my bot, but i can't make it work for my case . The code of the bot that i tried is the same as this sample : def start(bot, update): keyboard = [[InlineKeyboardButton("Option 1",…
atareao
  • 151
  • 3