Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
check out the translate.js project for more information
http://github.com/marak/translate.js/
requires installing the translate.js module via
sudo npm install translate
*/
var say = require('../lib/say');
var translate = require('translate');
translate.text('Yo quero tacos por favor', function(result){
say.speak('Alex', result);
});
/*
check out the translate.js project for more information
http://github.com/marak/translate.js/
requires installing the translate.js module via
sudo npm install translate
*/
var say = require('../lib/say');
var translate = require('translate');
translate.text('Yo quero tacos por favor', function(result){
say.speak('Alex', result);
});
this.triggers.translate = function(name,to,message,languages,text) {
//figure out who to respond to
//if it was a private message to me, respond to the person
//if it was to a room and not me specificall, reply in the room
var destination = to === this.nick
? name
: to
var client = this
if(text) {
var pair = languages.split(/[:]/)
translate.text({input:pair[0],output:pair[1]},text,function(txt) {
//respond with the translated test, decoding the html entities
client.say(destination,html.decode(txt))
})
}
else {
translate.text(languages,function(txt) {
//respond with the translated test, decoding the html entities
client.say(destination,html.decode(txt))
})
}
}
}
//if it was to a room and not me specificall, reply in the room
var destination = to === this.nick
? name
: to
var client = this
if(text) {
var pair = languages.split(/[:]/)
translate.text({input:pair[0],output:pair[1]},text,function(txt) {
//respond with the translated test, decoding the html entities
client.say(destination,html.decode(txt))
})
}
else {
translate.text(languages,function(txt) {
//respond with the translated test, decoding the html entities
client.say(destination,html.decode(txt))
})
}
}
}
var t = require('translate');
t.text("this is a test", function(err, txt) {
console.log(txt);
});
t.text("this isn't a test", function(err, txt) {
console.log(txt);
});
var t = require('translate');
t.text("this is a test", function(err, txt) {
console.log(txt);
});
t.text("this isn't a test", function(err, txt) {
console.log(txt);
});
listen(regexFactory.startsWith("translate"), function(match, data, replyTo) {
var msgMatch = /^([^ ]+) (.*)$/.exec(match[1]);
if (msgMatch) {
translate.text({input: 'English', output: match[1]}, match[2], function(err, translation) {
irc.privmsg(replyTo, translation);
});
} else {
irc.privmsg(replyTo, "Usage: translate {language} {word or phrase}");
}
});