Python 一个按钮,使用telebot库
我有一个Python 一个按钮,使用telebot库,python,bots,telegram,Python,Bots,Telegram,我有一个处理程序,用于在电报机器人中上载文档。我想知道,如果用户按下按钮1,处理程序开始工作。但是我无法理解,我应该如何处理parammessage,我需要另一个参数而不是message,在进度步骤中为我上传文档和图片的处理程序查看我的上传文件,但现在我得到了处理程序文本:1。请提供帮助 我的代码: import telebot from telebot import types @bot.message_handler(func=lambda m: True, content_types=[
处理程序
,用于在电报机器人中上载文档。我想知道,如果用户按下按钮1
,处理程序开始工作。但是我无法理解,我应该如何处理parammessage
,我需要另一个参数而不是message
,在进度步骤中为我上传文档和图片的处理程序查看我的上传文件,但现在我得到了处理程序文本:1
。请提供帮助
我的代码:
import telebot
from telebot import types
@bot.message_handler(func=lambda m: True, content_types=['document'])
def handle_docs_photo(message):
try:
chat_id = message.chat.id
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'B:/' + message.document.file_name;
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, "save that")
except Exception as e:
bot.reply_to(message, e)
@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
markup.add('1', '2') #Имена кнопок
msg = bot.reply_to(message, 'Test text', reply_markup=markup)
bot.register_next_step_handler(msg, process_step)
def process_step(message):
chat_id = message.chat.id
if message.text=='1':
#here should be def handle_docs_photo(message):
else:
pass