
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
This README is still under construction.
This library provides the microframework to implement a twitter bot program.
You need to get OAuth configuration before implementing your bot.
At first, use twbot:config command to generate oauth_token.
$ twbot:config YOUR_CONSUMER_KEY YOUR_CONSUMER_SECRET
The 'sys' module is now called 'util'. It should have a similar interface.
please visit http://twitter.com/oauth/authorize?oauth_token=ZZZZZZZZZZZZZZZZZZZZ to get verification code.
input verification code: XXXXXX
Then open your browser, go to authorize url, and input verification code.
*********************************************************************
Access key/secret have been successfully retrieved from Twitter
You can use Bot application by following constructions.
*********************************************************************
var TwBot = require("twbot").TwBot;
var bot = new TwBot({"consumerKey":"YOUR_CONSUMER_KEY","consumerSecret":"YOUR_CONSUMER_SECRET","accessKey":"YOUR_ACCESS_KEY","accessSecret":"YOUR_ACCESS_SECRET"})
You can use the above statement to initialize bot object.
a bot instance is an EventEmitter instance. You can addListener/on function to define your event handers.
bot.on('tweet', function(data){
console.log(data.text);
});
bot.on('mentioned', function(data){
console.log(data.text);
});
Focusing on tweet stream, you can use match function to trigger functions only when conditions are matched.
bot.match(
'#node-twbot',
function(tweet){ // only executed when the tweet include #node-twbot hashtag.
console.log(tweet.text);
}
);
The first argument accepts String or RegExp, which are compared with the tweet text. It also accept an function, which returns true to execute the handler.
A bot instance currently uses only UserStream API. To start streaming event loop, execute as follows:
bot.startUserStream();
To stop the bot, kill the process. If connection reset by Twitter server, it try to reconnect in several seconds.
See more examples on the examples directory.
The plugins directory contains several useful implementations.
To use plugins, just call the load method with plugin file path (require.paths is used to load).
bot.loadPlugin('twbot/auto-follow');
You can implement your own plugin in your application.
MIT License
FAQs
Twitter bot microframework using node.js
The npm package twbot receives a total of 1 weekly downloads. As such, twbot popularity was classified as not popular.
We found that twbot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.