我想在用户单击电报上的查询时显示特定消息。
我在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)
''''