boris93
2022-11-22 12:56:52 +08:00
比如一个 Google Script 写的 telegram 机器人后段是这样的
```
const COMMAND_START = "/start";
function doGet(event) {
return HtmlService.createHtmlOutput("It's working!");
}
function doPost(event) {
var contents = JSON.parse(event.postData.contents);
var command = String(contents['message']['text']);
switch (command) {
case COMMAND_START:
sendChatId(contents);
break;
default:
console.warn("command=%s message=Unknown command", command);
break;
}
}
```