1
Fork 0
mirror of https://github.com/RGBCube/TwitterDiscordWebhook synced 2025-07-27 13:07:45 +00:00

fixes to only support tweets, and for uptime

This commit is contained in:
stovven 2022-04-24 23:48:38 -04:00 committed by GitHub
parent a47e8a1f34
commit 5579d41cf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

18
main.js
View file

@ -24,8 +24,24 @@ tClient.get('account/verify_credentials', { skip_status: true })
var stream = tClient.stream('statuses/filter', { follow: `${config.user_id}` })
console.log(`Fetching tweets from id: ${config.user_id}`)
stream.on('connected', function (response) {
console.log(`Connected to twitter`)
})
stream.on('tweet', function (tweet) {
if(tweet.retweeted_status) return
if(tweet.retweeted_status || tweet.in_reply_to_status_id || tweet.is_quote_status) return
let twitterLink = `https://twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}`
wClient.send(`${config.webhook_message} ${twitterLink}`)
})
stream.on('disconnect', function (disconnectMessage) {
console.log(`Disconnected from twitter`)
})
stream.on('reconnect', function (request, response, connectInterval) {
console.log(`reconnecting to twitter`)
})
process.on('uncaughtException', function (err) {
console.log("something happened!", err);
});