1.1.2 • Published 8 years ago

twitter-poller v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

twitter-poller

It does exactly what you think.

Features

  • Does not require Twitter account (or app)
  • Notifies about new tweets from specified profiles
  • Easy and intuitive structure and implementation
  • Fully customizable

Navigation

Installation

npm install twitter-poller --save

Code sample

const twitterPoller = require('twitter-poller');
const tp = new twitterPoller({ profiles: ['Hasel_Loyance'] });

let handleTweet = async (tweetObject) => {
    console.log('New tweet');
    console.log(JSON.stringify(tweetObject));
}

tp.poll(handleTweet);

Tweet object structure

{
    // Information about profile from which tweet was received from
    profile:  { 
    
        // Unique user name
        user: 'Hasel_Loyance',
        
        // Display user name
        name: 'Hasel Loyance',
        
        // User id
        id: 2967579722,
        
        // Avatar image url
        avatarUrl: 'https://pbs.twimg.com/profile_images/770460179586424832/ZLGwf3E8.jpg' 
    },
    
    // Information about profile that posted the tweet
    from: { 
    
        // Unique user name
        user: 'Hasel_Loyance',
        
        // Display user name
        name: 'Hasel Loyance',
        
        // User id
        id: 2967579722,
        
        // Avatar image urls
        avatar: { 
            small:'https://pbs.twimg.com/profile_images/770460179586424832/ZLGwf3E8_bigger.jpg',
            normal: 'https://pbs.twimg.com/profile_images/770460179586424832/ZLGwf3E8_normal.jpg',
            big: 'https://pbs.twimg.com/profile_images/770460179586424832/ZLGwf3E8.jpg' 
        } 
    },
    
    // Tweet content
    tweet: { 
        
        // Tweet id
        id: '802731445110370304',
        
        // Tweet timestamp
        timestamp: 1480221065,
        
        // Flag if tweet is pinned
        isPinned: 0,
        
        // Flag if tweet is marked as NSFW
        isNSFW: 0,
        
        // Array of attachments
        // See attachment structure for details
        attachments: [],
        
        // Tweet message
        text: 'No, I\'m not dead. I\'ve been working on something. And it require(\'s-lots-of-node-js\')',
        
        // Tweet stats
        replyCount: 0,
        retweetCount: 0,
        favoriteCount: 0 
   } 
}

Tweet attachment structure

There are five attachment types:

  • image
  • gif
  • video
  • externalLink
  • poll

Attachment structure is:

{
    type: '<type>',
    url: 'url',
}

Please note:

gif and video types urls lead to the Twitter embedding player with video/gif source
poll type contains id of the poll card instead of the link, since Twitter does not share any data about polls publically

Example:

{
    type: 'video',
    url: 'https://twitter.com/i/videos/tweet/858455030382419968',
}

{
    type: 'poll',
    url: 'card://858547291761893378',
}

Options

ParameterTypeDescriptionDefaults to
redis.twitterCacheNamestringOrdered set where new tweet ids are storedTwitterCache
redis.hoststringIP for redis caching server127.0.0.1
redis.portnumberPort for redis caching server6379
redis.options.passwordstringPassword for redis caching server
profilesarrayTwitter profile names for polling
pollIntervalMsnumberInterval between polling requests (ms)10000
profileLoadTimeoutnumberTimeout if can't get profile (ms)2000
userAgentstringUser-Agent header value in requestsTwitter-Poller
1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago