【问题标题】:How to pass arguments from a message to a telebot如何将参数从消息传递到远程机器人
【发布时间】:2022-01-19 10:16:44
【问题描述】:

我的电报机器人接收以下形式的一行消息:323 432 875-1

如何使用 Telebot 将此字符串发送到三个变量?

idr = 323
numb = 432 
prid = 875-1

UPD#

text = "323 432 875-1"
idr, numb, prid, *_ = l = text.split()

这可行,但我不知道如何从 Telegram 本身获取数据并将其传输到 text = ""

【问题讨论】:

  • 你试过什么?请提供minimal reproducible example.
  • text = "323 432 875-1" idr, numb, prid, *_ = l = text.split() 这行得通,但我不知道如何从 Telegram 本身获取数据并将其传输到 text = ""

标签: python telegram-bot py-telegram-bot-api


【解决方案1】:

当您收到消息时,文本会保存在message.text

所以:

text = message.text
idr, numb, prid, *_ = l = text.split()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 2020-08-25
    • 2019-08-19
    相关资源
    最近更新 更多