@bot.message_handler(content_types=['voice'])
def voice_download(message):
file_name = message.voice.file_id
file_id_info = bot.get_file(file_name)
print(file_id_info)
downloaded_file = bot.download_file(file_id_info.file_path)
src = file_name
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('<текст кнопки>', callback_data='sample'))
bot.send_message(message.chat.id, 'текст над кнопками', reply_markup=marckup)
@bot.callback_query_handler(func=lambda call: True)
def test(call):
print(call.data)
def callback_inline(call):
try:
if call.message:
if call.data == 'good':
bot.send_message(call.message.chat.id, 'Вот и отличненько ')
text = 'Как дела?'
elif call.data == 'bad':
bot.send_message(call.message.chat.id, 'Бывает ')
text = 'Как дела?'
elif call.data == 'good1':
bot.send_message(call.message.chat.id, 'Славненько...')
text="Не пиши такое больше"
elif call.data == 'bad1':
bot.send_message(call.message.chat.id, 'Сорян, платки кончились...')
text="Не пиши такое больше"
# удаление встроенных кнопок
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=text)
# показать оповещение
bot.answer_callback_query(callback_query_id=call.id, show_alert=False,
text="Преобразовано...")
except Exception as e:
print(repr(e))