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
| function onOpen() | |
| { | |
| var ui = SpreadsheetApp.getUi(); | |
| ui.createMenu('Invoice') | |
| .addItem('mark Overdue', 'doOverdueCheck') | |
| .addItem('show Overdue Info', 'showOverDueInfo') | |
| .addItem('send Emails', 'sendOverdueEmails') | |
| .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
| function pushMsg(message, usrId) { | |
| var opt = { | |
| 'headers': { | |
| 'Content-Type': 'application/json; charset=UTF-8', | |
| 'Authorization': 'Bearer ' + channelToken, | |
| }, | |
| 'method': 'post', | |
| 'payload': JSON.stringify({ | |
| 'to': usrId, | |
| 'messages': [{'type': 'text', 'text': message}] |
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
| function addUser(userId) { | |
| remindSheet.appendRow([userId]); | |
| } | |
| function deleteRowAt(index) { | |
| remindSheet.deleteRow(index); | |
| } |
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
| var app = SpreadsheetApp.openById("your-sheet-id"); | |
| var remindSheet = app.getSheets()[0]; // Get's the fisrt table in the sheet | |
| function checkUser(userId) { | |
| var lastRow = remindSheet.getLastRow(); // the index of the last row | |
| var inDB = -1; | |
| if (lastRow > 0) { | |
| var ids = remindSheet.getSheetValues(1,1,lastRow,1); | |
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
| function replyMsg(userId, replyToken, userMsg) { | |
| var msg = ""; | |
| if (userMsg == "打卡提醒") { // "Remind me to punch." | |
| if (checkUser(userId) == -1) { | |
| addUser(userId); | |
| msg = "那我以後9:00和18:00會提醒你喔~"; // "I'll remind you at 9:00 and 18:00 in the future." | |
| } else { | |
| msg = "你已經在提醒名單中了:)"; // "You're already on the remind list." | |
| } | |
| } else if (userMsg == "取消提醒") { // "Stop reminding me." |
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 channelToken = 'your_messaging_api_channel_token'; | |
| // `e` is the data provided by Line | |
| function doPost(e) { | |
| var value = JSON.parse(e.postData.contents); | |
| try { | |
| var events = value.events; | |
| if (events != null) { | |
| for (var i in events) { | |
| var event = events[i]; |
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
| function sendReminder() { | |
| console.log(checkDay()); | |
| if (checkDay() == false) { // weekend | |
| return; | |
| } | |
| var lastRow = remindSheet.getLastRow(); | |
| if (lastRow > 0) { | |
| var ids = remindSheet.getSheetValues(1,1,lastRow,1); | |
| for(var i = 0; i < lastRow; i++){ |
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
| function sendTweets() { | |
| var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| var startRowNumber = 1; | |
| var endRowNumber = sheet.getLastRow(); | |
| var twitterKeys = { | |
| TWITTER_CONSUMER_KEY: "//add your API key", | |
| TWITTER_CONSUMER_SECRET: "//add your API secret key", | |
| TWITTER_ACCESS_TOKEN: "//add your access token key", | |
| TWITTER_ACCESS_SECRET: "//add your access token secret key", |
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
| var fs = require('fs'), | |
| http = require('http'), | |
| https = require('https'), | |
| express = require('express'), | |
| bodyParser = require('body-parser'), | |
| request = require('request'), | |
| crypto = require('crypto'), | |
| FBToken = '', | |
| port = 443, | |
| options = { |
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
| /** | |
| * Adds a custom menu to the active spreadsheet, containing a single menu item | |
| * for invoking the exportEvents() function. | |
| * The onOpen() function, when defined, is automatically invoked whenever the | |
| * spreadsheet is opened. | |
| * For more information on using the Spreadsheet API, see | |
| * https://developers.google.com/apps-script/service_spreadsheet | |
| * FROM: https://stackoverflow.com/questions/15788897/create-google-calendar-events-from-spreadsheet-but-prevent-duplicates | |
| */ | |
| function onOpen() { |
NewerOlder