python电报机器人”;context.bot.send“消息”;

python电报机器人”;context.bot.send“消息”;,python,bots,telegram,Python,Bots,Telegram,我正在使用“python电报机器人”库,并在互联网上查看了各种示例 我注意到在谈话中有两种回答方式: 第一: ''context.bot.send_message(chat_id=update.effective_chat.id,text=msg)'' 第二点: ''update.message.reply_text(text=msg)' 实际上,它们都能工作。 我应该一个接一个吗? 来说明我的问题。在回波功能中,第3行和第4行给出相同的结果 回复功能 def echo(update, cont

我正在使用“python电报机器人”库,并在互联网上查看了各种示例

我注意到在谈话中有两种回答方式:

第一: ''context.bot.send_message(chat_id=update.effective_chat.id,text=msg)''

第二点: ''update.message.reply_text(text=msg)'

实际上,它们都能工作。 我应该一个接一个吗? 来说明我的问题。在回波功能中,第3行和第4行给出相同的结果

回复功能

def echo(update, context):
msg='Hi, nice to see you!'
context.bot.send_message(chat_id=update.effective_chat.id, text=msg)
update.message.reply_text(text=msg)
    
主要功能:

def main():
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
echo_handler=MessageHandler()
echo_handler = MessageHandler(Filters.text & (~Filters.command), echo)
dispatcher.add_handler(echo_handler)
updater.start_polling()
enter code here
我认为“context.bot.send_message”更适用于来自作业的消息,因为您可以粘贴上下文。 以此为例: