-
Notifications
You must be signed in to change notification settings - Fork 3
/
twit.js
38 lines (33 loc) · 990 Bytes
/
twit.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
36
37
38
// vim: set et ts=4 sw=4
'use strict';
var Twitter = require('twitter');
var client = new Twitter({
consumer_key: 'j5oWVtmbD3MnrGtRk0jMOEI4z',
consumer_secret: 'VfoxZbtrTjeSPVOkuzsmjUB8c6TmIHKsZIZr83MSo0CpN1x72F',
access_token_key: '704876576337477636-9wsUP6ZuWHsbpHhnSyiOQIkoxd5OalJ',
access_token_secret: 'IZ06WkLDpmCzvLXf6tTKVYl893xPIV39PK7wUCHovf8qc'
});
function listen(callback) {
client.stream('user', {replies: 'all', track: 'TwithubB'}, (stream) => {
stream.on('data', callback);
stream.on('error', err => {
console.log(err);
});
});
}
// callback: (error, tweet body, raw response object) => {}
function tweet(status, callback) {
console.log(`Tweeting ${status}`);
client.post('statuses/update', {status}, callback);
}
//NOT CORRECT, USE in_reply_to_status_id
//https://github.com/mirakui/retrobot/pull/7
function reply(status, callback) {
client.post('statuses/update', {status}, callback);
}
module.exports = {
tweet,
reply,
listen,
linkLength: 23
};