【发布时间】:2019-01-28 08:06:35
【问题描述】:
我有以下 API 调用点:
iostCall = "https://min-api.cryptocompare.com/data/price?fsym=IOST&tsyms=USD,JPY,EUR"
我想在 (IOST) 连接来自我的电报用户的输入。
这是我目前写的,但我必须对每次调用 api 进行硬编码。
def test (bot, update, args):
params = {
'fsym' : fsym
}
testCall = "https://min-api.cryptocompare.com/data/price"
testJson = requests.get(testCall, params=params)
testOut = testJson
update.message.reply_text(testOut)
这就是将命令发送到电报 api 的内容。基本上,我的脚本一直等到用户调用 /test(输入硬币名称)......例如:/test btc
dp.add_handler(CommandHandler("test", test, pass_args=True))
发送给我的用户。
【问题讨论】:
-
currencies = input('enter your currencies (separated by space)').split()
标签: python python-3.x bots telegram