Python Bot电报从InlineKeyButton获取URL

时间:2019-12-13 12:04:58

标签: python bots telegram telepot

实际上,我有一个用python 3.6语言编写的电报机器人,该机器人从我编写的特定模块中获取了一些URL。 僵尸程序针对特定用户的消息执行的操作是使用InlineKeyboardButton将URL列表返回到按钮中。

代码下方:

import sys
import time
import telepot
from telepot.namedtuple import InlineKeyboardMarkup, InlineKeyboardButton
import emoji
import myModule

def on_chat_message(msg):
  content_type, chat_type, chat_id = telepot.glance(msg)
  txt = msg['text']
  if txt == "/mycommand":
    count = 1
    lista=[]
    dict={}
    for elem in myModule.getURL():
        lista.append([InlineKeyboardButton(text="URL %d" % count, url='elem' callback_data='update')])
        count += 1
    keyboard = InlineKeyboardMarkup(inline_keyboard=lista)
    bot.sendMessage(chat_id, "Loading URLs list..", reply_markup=keyboard)

此代码正确运行,因为当我向机器人发送/ mycommand时,它会向我返回正确数量的按钮,并且如果单击其中一个按钮,则可以看到与之对应的URL。

我要做的是获取所按下按钮的URL并将其解析为一个函数,如下所示:

myModule.putURL(url_of_button)

你能帮我吗?

0 个答案:

没有答案
相关问题