如何获得Telepot用户字符串输入?

问题描述 投票:1回答:1

我在Python是新和电报僵尸,我希望你能帮助我理解这一个简单的例子。我需要的是定义我返回一个字符串,来完成一个网址的方法。在Python我需要的是:

user = input("Insert a username to see the graph:")
graphUrl = "https://www.graphsss123.com/ser/graph/" + user + "-123.jpg"
print(graphUrl)

我怎么能使用Telepot得到同样的结果?

谢谢

python heroku telegram telegram-bot python-telegram-bot
1个回答
1
投票

有在telepot接收消息(我猜!)没有专属的功能,所以你必须保持状态(在这里,我已经做到了使用步骤)。该片段以下是通过添加电报由用户给定的2号为例REF:https://github.com/nickoala/telepot/issues/209

global step, no1
        if step == 1:
            if msg['text'] == 'add':
                bot.sendMessage(chat_id, "input no1")
                step = 2
            else:
                bot.sendMessage(chat_id, "please provide no")
        elif step == 2:
            no1 = msg['text']
            bot.sendMessage(chat_id, "input no2")

            step = 3
        elif step == 3:
            no2 = msg['text']
            no3=no1+no2
            bot.sendMessage(chat_id,no3)
            step = 1
© www.soinside.com 2019 - 2024. All rights reserved.