2013-03-06 14:02:02 +01:00
|
|
|
/**
|
|
|
|
* Module Name: Finger
|
|
|
|
* Description: Returns the name of users via the Finger protocol
|
|
|
|
*/
|
|
|
|
var request = require('request'),
|
|
|
|
_ = require('underscore')._,
|
|
|
|
exec = require('child_process').exec;
|
|
|
|
|
|
|
|
var finger = function(dbot) {
|
|
|
|
var commands = {
|
|
|
|
'~finger': function(event) {
|
|
|
|
var username = event.params[1];
|
|
|
|
exec("finger -s " + username + "@central.aber.ac.uk",function(error,stdout,stderr){
|
2013-03-06 14:10:54 +01:00
|
|
|
stdout = stdout.replace(/(\r\n|\n|\r)/gm,"");
|
2013-03-06 14:02:02 +01:00
|
|
|
name = stdout.search("Name:");
|
|
|
|
stdout = stdout.substring(name);
|
|
|
|
ret = stdout.search("Dir");
|
2013-03-06 14:10:54 +01:00
|
|
|
stdout = stdout.substring(6,ret);
|
2013-03-06 14:20:58 +01:00
|
|
|
if (stdout == "Welcom") {
|
|
|
|
event.reply(dbot.t("nonexistent",{user: username}));
|
|
|
|
} else {
|
|
|
|
event.reply(dbot.t("name",{user: username, name: stdout}));
|
|
|
|
}
|
2013-03-06 14:02:02 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.commands = commands;
|
|
|
|
|
|
|
|
this.on = 'PRIVMSG';
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new finger(dbot);
|
|
|
|
};
|