Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

python - 如何使用python-telegram-bot转发消息(How to forward a message using python-telegram-bot)

I'm writing a telegram bot group administrator using python-telegram-api and I want my bot to reply to messages in groups like this but the only similar thing I can get with it is this .

(我使用的是写了一封电报机器人组管理员蟒蛇,电报的API ,我想我的机器人在团体回复邮件是这样 ,但唯一类似的事情,我可以用它得到的是这个 。)

Is there a way to reply to messages like in the first picture?

(有没有办法像第一张图片一样回复邮件?)

from telegram.ext import (Updater, CommandHandler, MessageHandler, 
Filters, ConversationHandler)
import telegram
import logging

telegram_token = "BOT TOKEN"

updater = Updater(token=telegram_token, use_context=True);
dispatcher = updater.dispatcher;
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - % 
(message)s', level=logging.INFO);

def mesgs_hand(update, context): 
    if(update.message.text == "Hi"):
        context.bot.forward_message(chat_id=update.effective_chat.id, 
        from_chat_id=update.effective_chat.id, 
        message_id=update.message.message_id, text="Hey there!"); 
        #this method forwards the message but without adding 'Hey there!' 

    elif(update.message.text == "Hello"):
        context.bot.send_message(chat_id=update.message.chat_id, text="Hello!"); 
        #this method just replies to the message without forwarding 

messages_handler = MessageHandler(Filters.text, mesgs_hand)
dispatcher.add_handler(messages_handler)


def bot():
    updater.start_polling();

if __name__ == "__main__":
    bot();
  ask by Якушев Руслан translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...