From 81edcd79d91f6322d34912c03640389e7d3d5770 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Wed, 11 Jul 2018 14:45:00 +0200
Subject: [PATCH] Fixed code to tweet once when called, multiple time zones.

---
 bot.js | 88 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 75 insertions(+), 13 deletions(-)

diff --git a/bot.js b/bot.js
index 9e805db..2671c67 100644
--- a/bot.js
+++ b/bot.js
@@ -2,17 +2,79 @@ var Mastodon = require('mastodon');
 var Schedule = require('node-schedule');
 var Moment = require('moment-timezone');
 
-var tootInterface = new Mastodon({ access_token : process.env.ACCESS_TOKEN });
-
-function doTheToot() {
-  var now = Moment();
-  console.log(now);
-  var hours = now.tz(process.env.TIMEZONE).hour();
-  var toots = '';
-  for (var i = 0; i < hours; i++) {
-    toots += "TOOT ";
-  }
-  tootInterface.post('statuses', { status: toots });
-}
+var now = Moment();
+
+var timezone = "UTC"
+var currentdate = now.tz(timezone);
+var hours = currentdate.hour();
+var minutes = currentdate.minute();
+var currentTimeUtc = "Current " + timezone + " time is " 
+                + hours + ":"  
+                + minutes + ":" 
+                + currentdate.second();
+
+timezone = "Europe/Amsterdam"
+currentdate = now.tz(timezone);
+hours = currentdate.hour();
+minutes = currentdate.minute();
+var currentTimeAms = "Current time in " + timezone + " is " 
+                + hours + ":"  
+                + minutes + ":" 
+                + currentdate.second();
+
+timezone = "America/New_York"
+currentdate = now.tz(timezone);
+hours = currentdate.hour();
+minutes = currentdate.minute();
+var currentTimeNyc = "Current time in " + timezone + " is " 
+                + hours + ":"  
+                + minutes + ":" 
+                + currentdate.second();
+
+timezone = "America/Los_Angeles"
+currentdate = now.tz(timezone);
+hours = currentdate.hour();
+minutes = currentdate.minute();
+var currentTimeLa = "Current time in " + timezone + " is " 
+                + hours + ":"  
+                + minutes + ":" 
+                + currentdate.second();
+
+timezone = "Europe/London"
+currentdate = now.tz(timezone);
+hours = currentdate.hour();
+minutes = currentdate.minute();
+var currentTimeUk = "Current time in " + timezone + " is " 
+                + hours + ":"  
+                + minutes + ":" 
+                + currentdate.second();
+
+var tootInterface = new Mastodon({
+  access_token: "",
+  timeout_ms: 60*1000,  // optional HTTP request timeout to apply to all requests.
+  api_url: 'https://qoto.org/api/v1/', });
 
-var tooter = Schedule.scheduleJob('0 * * * *', doTheToot);
+console.log(now);
+
+var toots = '';
+
+toots = currentTimeUtc + "\n\n";
+toots += currentTimeAms + "\n\n";
+toots += currentTimeUk + "\n\n";
+toots += currentTimeNyc + "\n\n";
+toots += currentTimeLa + "\n\n";
+toots += "\n";
+
+for (var i = 0; i < hours; i++) {
+  toots += "TOOT ";
+}
+if(minutes >= 15) {
+  toots += "T"
+}
+if(minutes >= 30) {
+  toots += "O"
+}
+if(minutes >= 45) {
+  toots += "O"
+}
+tootInterface.post('statuses', { status: toots });
-- 
GitLab