-
Notifications
You must be signed in to change notification settings - Fork 9
/
twitter.js
35 lines (24 loc) · 891 Bytes
/
twitter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var Twit = require('twit');
var moment = require("moment");
function tweet(message, config) {
var T = new Twit({
consumer_key: config.twitter.api_key,
consumer_secret: config.twitter.api_key_secret,
access_token: config.twitter.access_token,
access_token_secret: config.twitter.access_token_secret
})
// update the status
var usetwitter = config.twitter.use;
// check, if ews useage is defined, if not, skip and log
if ( typeof usetwitter !== 'undefined' && usetwitter == "yes") {
T.post('statuses/update', { status: message }, function (err, data, response) {
// dont log data, it is too long
//console.log(data)
})
}
else
{
console.log(moment().format('MMMM Do YYYY, h:mm:ss a') + ": No twitter reporting activated / configured");
}
}
exports.tweet=tweet;