Mybot正在保存用户ID等。到Google工作表并进行响应,但是当添加到组中时,会将所有用户ID保存为-1001199520004,并使用未定义的未定义+答案进行响应,并将姓名和姓氏也保存为未定义的未定义。
function doPost(e) {
// this is where telegram works
var data = JSON.parse(e.postData.contents);
var text = data.message.text;
var id = data.message.chat.id;
var name = data.message.chat.id.first_name + " " +
data.message.chatid.last_name;
var answer = name + ", whatever " ;
sendText(id,answer);
SpreadsheetApp.openById(ssId).getSheets()[0].appendRow([new
Date(),id,name,text]);
if(/^@/.test(text)) {
var sheetName = text.slice(1).split(" ")[0];
var sheet = SpreadsheetApp.openById(ssId).getSheetByName(sheetName) ?
SpreadsheetApp.openById(ssId).getSheetByName(sheetName) :
SpreadsheetApp.openById(ssId).insertSheet(sheetName);
var comment = text.split(" ").slice(1).join(" ");
sheet.appendRow([new Date(),id,name,comment,answer]);
}
}