【问题标题】:How can I get information from the user telegram bot?如何从用户电报机器人获取信息?
【发布时间】:2018-01-12 14:31:39
【问题描述】:

例如,机器人发送“发给我你的名字”,“发给我你的姓氏”并将这些数据保存在两个变量中。我的语言是 python,我使用 Telepot 包来制作机器人

【问题讨论】:

  • 谢谢。你在这个模块中有一个简单的例子吗?我没有使用这个模块
  • 如果您在链接中向下滚动,会有示例
  • 我看到了例子。这些例子使用了日志模块,因为我的python版本是3.4,我不能使用日志模块。
  • 谢谢你,我搜索了谷歌,我找到了另一个不使用日志模块的例子。我使用电报.ext,我得到了回复。请回答,我投票给你

标签: python bots telegram telepot


【解决方案1】:

查看this 链接。向下滚动查看示例。希望这会有所帮助!

【讨论】:

    【解决方案2】:

    在 Telepot 包中:

    import telepot
    from telepot.loop import MessageLoop
    import time
    bot = telepot.Bot('my_token')
    def handle(msg):
        content_type, chat_type, chat_id = telepot.glance(msg)
        send1 = bot.sendMessage(chat_id,'whats your name?')
        if send1:
            text1 = msg['text']
            print(text1)
    
    
    MessageLoop(bot,handle).run_as_thread()
    while 1:
        time.sleep(1)
    

    text1 变量是问题“你叫什么名字?”的回复关联

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-20
      • 2019-07-12
      • 2022-06-10
      • 2021-10-25
      • 1970-01-01
      • 2021-08-28
      • 1970-01-01
      • 2023-02-02
      相关资源
      最近更新 更多