如何在用户单击查询后显示消息؟

2024-07-06 19:03:54 发布

您现在位置:Python中文网/ 问答频道 /正文

当用户单击电报上的查询时,我想显示一条特定的消息

我在pythonanywhere站点上编写了下面的代码,没有找到任何方法显示基于“makro”和“iso”选项选择的消息

'''' 从烧瓶进口烧瓶,请求 导入电传机 导入urllib3 从telepot.namedtuple导入InlineKeyboardMarkup,InlineKeyboardButton 导入openpyxl 导入时间 从telepot.loop导入MessageLoop

proxy_url = "http://proxy.server:3128"
telepot.api._pools = {
    'default': urllib3.ProxyManager(proxy_url=proxy_url, num_pools=3, maxsize=10, retries=False, timeout=30),
}
telepot.api._onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=proxy_url, num_pools=1, maxsize=1, retries=False, timeout=30))

secret = "1234567"
bot = telepot.Bot('my_token_here')
bot.setWebhook("https://envid.pythonanywhere.com/{}".format(secret), max_connections=1)

app = Flask(__name__)


@app.route('/{}'.format(secret), methods=["POST"])
def telegram_webhook():
    update = request.get_json()
    if "message" in update:
            chat_id = update["message"]["chat"]["id"]
            on_chat_message(update["message"])
    return "OK"





def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    keyboard = InlineKeyboardMarkup(inline_keyboard=[
                 [InlineKeyboardButton(text='ISO', callback_data='iso')],
                 [InlineKeyboardButton(text='MAKRO', callback_data='makro')],
               ])
    bot.sendMessage(chat_id, 'please select one', reply_markup=keyboard)

''''


Tags: id消息urlmessagesecretbotchatupdate