我正在开发一个谷歌网络应用程序 JavaScript 应用程序来与电报机器人通信。
Telegram 用户通过使用 InlineKeyboardMarkup (InlineKeyboardButton) 键入某些单词或单击 Telegram 组上出现的按钮;
我已经实现了一个 Telegram Bot 状态机来检测输入了哪些命令,以确定要执行的相应操作;
问题:是否有更有效的方法来满足上述要求?
我正在使用的 Google 网络应用 JavaScript 源代码示例:
function menu( chat_id ) {
let url = vUrlTelegram + "/sendMessage";
var keyboard = {
'inline_keyboard' :
[
[{'text' : 'admin', 'callback_data' : 'admin'}], // Row 1
[{'text' : 'squad', 'callback_data' : 'squad'}], // Row 2
[{'text' : 'carioca', 'callback_data' : 'carioca'}], // Row 3
[{'text' : 'brasileiro', 'callback_data' : 'brasileiro'}], // Row 4
[{'text' : 'sponsors', 'callback_data' : 'sponsors'}], // Row 5
[{'text' : 'test', 'callback_data' : 'test'}] // Row 6
]
};
var data = {
'chat_id': chat_id,
'text': "main menu",
'reply_markup': keyboard
};
var options = {
'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
function telegramBotMachine( chat_id, text, name, data ) {
var sUpperData = data.toUpperCase();
var sResponse = " ";
// var sContent = "chat_id: " + chat_id + " \ntext: " + text + " \nname: " + name + " \ndata: " + data + " \nsUpperData: " + sUpperData;
// sendFormattedMessage( chat_id, sContent, "HTML", "false", "false" );
慕村9548890
温温酱
相关分类