I want to make a keyboard in telegram-bot, but I can't find chat_id
. How can fix it?
Code:
from telegram.ext import Updater, CommandHandler
from telegram import ReplyKeyboardMarkup
updater = Updater(Token)
def start(update, _) :
update.message.reply_text('Hi {}!'.format(update.message.chat.first_name))
def service_keyboards(bot,update) :
chat_id = update.effective_chat.id
keyboard = [['Send Video'], ['Send Music']]
bot.sendMessage(chat_id, 'Plese choose an item.', reply_markup = ReplyKeyboardMarkup(keyboard))
start_command = CommandHandler('start' , start)
service_command = CommandHandler('service' , service_keyboards)
updater.dispatcher.add_handler(start_command)
updater.dispatcher.add_handler(service_command)
updater.start_polling()
updater.idle()
I get these Eror:
No error handlers are registered, logging exception. Traceback (most recent call last): File "c:\users\Ghazal\appdata\local\programs\python\python38\lib\site-packages\telegram\ext\dispatcher.py", line 442, in process_update handler.handle_update(update, self, check, context) File "c:\users\Ghazal\appdata\local\programs\python\python38\lib\site-packages\telegram\ext\handler.py", line 160, in handle_update return self.callback(update, context) File "", line 9, in start chat_id = update.message.chat_id AttributeError: 'CallbackContext' object has no attribute 'message'