mirror of
https://github.com/thewesker/bug-em.git
synced 2025-12-20 12:11:05 -05:00
Fixed the logging when tweets go out
This commit is contained in:
28
app.js
28
app.js
@@ -14,7 +14,7 @@ var T = new Twit({
|
||||
|
||||
// filter the public stream by english tweets containing `#apple`
|
||||
//
|
||||
var stream = T.stream('statuses/filter', { follow: '25073877, 1339835893, 216776631, 179932936' })
|
||||
var stream = T.stream('statuses/filter', { follow: '25073877, 1339835893, 216776631, 179932936, 1214598626' })
|
||||
stream.on('tweet', function (tweet) {
|
||||
if (tweet.user.screen_name === 'realDonaldTrump') {
|
||||
var b64content = fs.readFileSync('./pics/trump.gif', { encoding: 'base64' })
|
||||
@@ -109,6 +109,32 @@ T.post('media/upload', { media_data: b64content }, function (err, data, response
|
||||
var nameID = tweet.id_str;
|
||||
var name = tweet.user.screen_name;
|
||||
|
||||
T.post('media/metadata/create', meta_params, function (err, data, response) {
|
||||
if (!err) {
|
||||
// now we can reference the media and post a tweet (media will attach to the tweet)
|
||||
var params = {in_reply_to_status_id: nameID, status: '@' + name + " " + randomhulkmessage, media_ids: [mediaIdStr] }
|
||||
|
||||
T.post('statuses/update', params, function (err, data, response) {
|
||||
console.log("Replied to Hulk's Tweet with " + randomhulkmessage)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
if (tweet.user.screen_name === 'AwfulJack') {
|
||||
var b64content = fs.readFileSync('./pics/hulk.gif', { encoding: 'base64' })
|
||||
var hulkmessages = session.object.hulkmessages;
|
||||
var randomhulkmessage = hulkmessages[Math.floor(Math.random() * hulkmessages.length)];
|
||||
// first we must post the media to Twitter
|
||||
T.post('media/upload', { media_data: b64content }, function (err, data, response) {
|
||||
// now we can assign alt text to the media, for use by screen readers and
|
||||
// other text-based presentations and interpreters
|
||||
var mediaIdStr = data.media_id_string
|
||||
var altText = "There isn't actually much point to this but whatever"
|
||||
var meta_params = { media_id: mediaIdStr, alt_text: { text: altText } }
|
||||
var nameID = tweet.id_str;
|
||||
var name = tweet.user.screen_name;
|
||||
|
||||
T.post('media/metadata/create', meta_params, function (err, data, response) {
|
||||
if (!err) {
|
||||
// now we can reference the media and post a tweet (media will attach to the tweet)
|
||||
|
||||
Reference in New Issue
Block a user