By : aromanio Published On Tuesday, June 05, 2012, 22:51 In JavaScript
Having no particulary best use, the BOT can fullfill a great variety of tasks, such as:
It can easily adopt a practical use, according to your need.
In the package is the main file, YBot.js, and three sample files:
Good question. First, you have to include the main file, YBot.js.
var bot = require('./YBot.js');
Then, make an instance of YBot class, passing to the constructor the ID and Password of the account the BOT will log into.
Bot = new bot.YBot('yahoo_id','password');
To run the BOT process, simply call Start method
Bot.Start();
But that will just start the bot. Because of node.js the BOT will run asyncroniously. Of course, if you want to handle incoming messages, files and so on, you have to register a callback, like so:
Bot.on('message', OnIncomingMessage);
function OnIncomingMessage(from, message) {
// handle the message
Bot.SendMessage(from, "I don't know what to say...");
}
Documentation about events, methods and their parameters can be found in the begining of YBot.js.
So, a basic BOT file should look like this:
// include the bot class
var bot = require('./YBot.js');
// instantiate the bot
Bot = new bot.YBot('yahoo_id', 'password');
// register our callbacks
Bot.on('message', OnIncomingMessage);
// declare the callbacks
function OnIncomingMessage($from, $message) {
Bot.SendMessage($from, "I don't know what to say..");
}
// start the bot process
Bot.Start();
[05/31/2012] Version 1.0 released