Last active
March 21, 2016 02:21
-
-
Save x13machine/0db25a2d7cb04465d7d5 to your computer and use it in GitHub Desktop.
Contrans - A bot the translates things using bing translate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
put it behind a znc proxy. something will fuck up if you don't | |
commands: | |
.com: evals stuff(only if you are an admin) | |
.trans translates stuff | |
*/ | |
var config= require('./config.js') | |
var irc = require('irc'); | |
var Entities = require('html-entities').XmlEntities; | |
entities = new Entities(); | |
var bt = require('bing-translate').init(config.bingcerts); | |
var client = new irc.Client(config.irc.host, config.irc.name, config.irc); | |
client.addListener('message', function (from, to, message) { | |
var sendTo=from | |
if(to[0]=='#')sendTo=to | |
console.log(from, to,sendTo, message) | |
var messParts=message.split(' '); | |
if(messParts[0]=='.trans'){ | |
var lang=messParts[1] | |
messParts.splice(0,2); | |
var text=messParts.join(' ') | |
console.log(lang,text) | |
//client.say(sendTo, "testing"); | |
bt.translate(text, '', lang, function(err, res){ | |
console.log(err, res); | |
client.say(sendTo, entities.decode(res['translated_text'])) | |
}) | |
}else if(messParts[0]=='.com' && config.eval){ | |
client.whois(from,function(data){ | |
console.log(config.admins.indexOf(data.account),data) | |
if(config.admins.indexOf(data.account)==-1)return ;//check if user is admin | |
messParts.splice(0,1); | |
var text=messParts.join(' ') | |
client.say(sendTo,from+': '+eval(text)) | |
}) | |
} | |
}); | |
process.on('uncaughtException', function (err) { | |
console.error(err); | |
console.log("Node NOT Exiting..."); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name='cotrans' | |
module.exports={ | |
'bingcerts':{ | |
client_id: 'bing-translate-client-id', | |
client_secret: 'bing-translate-api-key' | |
}, | |
'irc':{ //https://github.com/martynsmith/node-irc | |
channels: ['##LFKchat','##Sonik','#discoteca','##Citydead'], | |
userName: name, | |
realName: name, | |
name: name, | |
port: 7000, | |
secure: true, | |
host: 'irc.freenode.net' | |
}, | |
admins:['somefucktard'], | |
eval:true, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment