这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main.gs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function onOpen() {
function showChangesDialog() {
const html = HtmlService.createTemplateFromFile('changesInput')
.evaluate()
.setWidth(400)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(html, '変更内容を記述');
.setTitle('変更内容を記述')
.setWidth(400); // 必要に応じて幅を調整
SpreadsheetApp.getUi().showSidebar(html);
}

// メニュー: Google Chat に送信 (変更内容の処理を含む)
Expand Down
83 changes: 77 additions & 6 deletions notice.gs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,93 @@
* Google Chat にメッセージを送信
*
* @param {string} messageContents - メッセージの内容
* @param {string} spreadsheetId - webhook の URL。
* @param {string} webhookUrl - Webhook の URL。
*/
function sendGooglechat(messageContents, webhookUrl) {
// 変更内容
let changesOutput = ""
for (let i = 0; i < messageContents.changes.length; i++) {
changesOutput += " - " + messageContents.changes[i] + "\n"
changesOutput += " - " + messageContents.changes[i] + "<br>"
}

const googlechatMessage = "「" + messageContents.sheetName + "」が更新されました\n変更内容:\n" + changesOutput + "カラー版: " + messageContents.download.color + "\nモノクローム版: " + messageContents.download.mono;
// 送信するテキストメッセージ
const textMessage = "「" + messageContents.sheetName + "」が更新されました。";

// 送信するカードのJSON
const cardMessage =
{
"header": {
"title": messageContents.sheetName,
},
"sections": [
{
"header": "変更内容",
"collapsible": true,
"uncollapsibleWidgetsCount": 2,
"widgets": [
{
"textParagraph": {
"text": changesOutput
}
}
]
},
{
"header": "入手",
"collapsible": false,
"uncollapsibleWidgetsCount": 1,
"widgets": [
{
"buttonList": {
"buttons": [
{
"text": "カラー版",
"icon": {
"materialIcon": {
"name": "file_open"
}
},
"type": "FILLED",
"onClick": {
"openLink": {
"url": messageContents.download.color
}
}
},
{
"text": "モノクロ版",
"icon": {
"materialIcon": {
"name": "file_open"
}
},
"type": "OUTLINED",
"onClick": {
"openLink": {
"url": messageContents.download.mono
}
}
}
]
}
}
]
}
]
};

const options = {
"method": "post",
"headers": {"Content-Type": "application/json; charset=UTF-8"},
"payload": JSON.stringify({"text": googlechatMessage})
"payload": JSON.stringify({
"text": textMessage,
"cardsV2": [{
"cardId": Utilities.getUuid(), // Todo: 各カードに一意のIDを設定する
"card": cardMessage
}]
})
};

const response = UrlFetchApp.fetch(webhookUrl, options);
console.log(response);
}
console.log(response.getContentText());
}