This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prerequisites: | |
// * You must have a Business or Enterprise Google Workspace account with access to Google Chat. | |
// * Your Google Workspace organization must let users add and use incoming webhooks. | |
// See: https://developers.google.com/workspace/chat/quickstart/webhooks | |
// | |
// Steps: | |
// 1. Create a standalone Google Apps Script Project. | |
// 2. Create a webhook URL in the Google Chat Space by following Google's official documentation above. | |
// 3. Save the webhook URL to as a Script Property and name it `chatWebHookUrl` | |
// 4. Copy & Paste the following script to your Apps Script project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DRY_RUN = false; | |
function getEventsForTomorrow() { | |
const timeZone = Session.getScriptTimeZone(); | |
let tomorrow = new Date(); | |
tomorrow.setDate(tomorrow.getDate() + 1); // get date for tomorrow | |
const tomorrowStr = Utilities.formatDate(tomorrow, timeZone, 'yyyy-MM-dd'); | |
// Get the events | |
const calendars = CalendarApp.getAllCalendars(); // get all calendars that the user owns or is subscribed to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SHEET_NAME_CONFIG = 'config'; | |
/** | |
* スプレッドシートが開いたときのメニュー追加 | |
*/ | |
function onOpen() { | |
SpreadsheetApp.getUi() | |
.createMenu('カレンダーから転記') | |
.addItem('カレンダーからイベント取得', 'getFilteredCalendarEvents') | |
.addToUi(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SHEET_NAME_CONFIG = '01_設定'; // 設定シート名 | |
/** | |
* onFormSubmitを手動でも実行できるように、スプレッドシートにメニューとして設定 | |
*/ | |
function onOpen() { | |
SpreadsheetApp.getUi() | |
.createMenu('定員付き選択肢') | |
.addItem('選択肢設定(手動)', 'onFormSubmit') | |
.addToUi(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const YEARS_AFTER = 5; // 5年後 | |
function onOpen() { | |
DocumentApp.getUi() | |
.createMenu('期限入力') | |
.addItem('年挿入', 'enterYear') | |
.addToUi(); | |
} | |
function enterYear() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2022 Taro TSUKAGOSHI | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gmailの受信トレイにある未読メールの件数をGoogleチャットで通知する、Spreadsheet-boundのGoogle Apps Script。 | |
* 前提: | |
* スプレッドシートに以下のように2列が設定されていること: | |
* | ACCOUNT | WEBHOOK_URL | | |
* | -------------------- | --------------------------- | | |
* | [email protected] | (Googleチャットのwebhook URL) | | |
* スクリプトは、実行しているアカウントと[email protected]が一致すれば、 | |
* その受信トレイにある未読メールの件数をWebhookを設定したチャットに投稿する。 | |
* [email protected]は当該チャットに参加している必要がある。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parse the string of recipients returned by Gmail into raw email addresses. | |
* For example, if Gmail provides a recipient string in form of | |
* "George Washington <[email protected]>" | |
* this function will return | |
* "[email protected]" | |
* @param {string} gmailRecipients String of comma-separated recipients returned by GmailMessages.getTo(), .getCc(), or .getBcc() | |
* @returns The raw email addresses of gmailRecipients, without recipient name and angle brackets | |
*/ | |
function getRawEmail_(gmailRecipients) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 実行するGoogleアカウントのカレンダーに登録されている「日本の祝日」カレンダーのIDを参照する↓ | |
const CAL_ID_HOLIDAY_JA = 'en.japanese#[email protected]'; | |
// オフィスアワーの開始・終了時刻をHHmmss形式のstringで設定↓ | |
const OFFICE_HOURS = { start: '090000', end: '170000' }; | |
// エラーとなったときの再実行までの時間(ミリ秒)↓ | |
const RETRY_MILLISEC = 5 * 60 * 1000; | |
// officeHourCheckがエラーとなったときの再実行までの時間(ミリ秒)↓ | |
const RETRY_MILLISEC_OFFICE_HOUR_CHECK = 5 * 1000; | |
const TIMEZONE = Session.getScriptTimeZone(); | |
const UP_KEY_DATE = 'upDate'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global SpreadsheetApp, UrlFetchApp */ | |
/* exported fetchAkitaDeps */ | |
const TARGET_URL = 'https://www.pref.akita.lg.jp/pages/genre/organization'; // クロールするサイトのURL | |
const SHEET_NAME = 'List'; // データを挿入するシート名 | |
const INSERT_DATA_POS = { row: 4, col: 1 }; // データの挿入開始位置 | |
const INSERT_EDIT_TIME_POS = { row: 1, col: 4 }; // 最終更新日時の挿入位置 | |
const REGEXP_DEPT = RegExp('<h3 class\=\"c-category-panel-item__heading\"><a href\=\"(?<deptUrl>[^\"]+)\">(?<deptName>[^の]+)の関連ジャンル<\/a><\/h3>[ ]*?<ul class\=\"c-category-panel-item__body c-gallery-list c-gallery-list--2\">(?<sectSource>.*?)<\/ul>', 'g'); // 部局名、URLを検出 | |
const REGEXP_SECT = RegExp('<li class\=\"c-gallery-list__item\"><a href=\"(?<sectUrl>[^\"]+)\">(?<sectName>.*?)<\/a><\/li>', 'g'); // 課名、URLを検出 |
NewerOlder