Skip to content

Instantly share code, notes, and snippets.

@buidanhbinh
buidanhbinh / google-sheets-send-email-based-on-date.js
Created July 21, 2021 06:27 — forked from prasanthmj/google-sheets-send-email-based-on-date.js
Send emails from a google sheet when a due date is crossed (overdue invoices for example) article: http://blog.gsmart.in/google-sheets-send-email-based-on-date/
function onOpen()
{
var ui = SpreadsheetApp.getUi();
ui.createMenu('Invoice')
.addItem('mark Overdue', 'doOverdueCheck')
.addItem('show Overdue Info', 'showOverDueInfo')
.addItem('send Emails', 'sendOverdueEmails')
.addToUi();
}
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}]
function addUser(userId) {
remindSheet.appendRow([userId]);
}
function deleteRowAt(index) {
remindSheet.deleteRow(index);
}
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);
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."
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];
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++){
@buidanhbinh
buidanhbinh / tweet.gs
Created July 20, 2021 14:54 — forked from nidhinkumar06/tweet.gs
Automated Tweets
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",
@buidanhbinh
buidanhbinh / 寶寶.js
Created July 14, 2021 15:51 — forked from goodjob1114/寶寶.js
新增line的功能
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 = {
@buidanhbinh
buidanhbinh / google_form_to_calendar_script.gs.js
Created July 14, 2021 07:20 — forked from alexkadis/google_form_to_calendar_script.gs.js
Google Script: Google Form > Google Sheets > Google Calendar
/**
* 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() {