Advertisement
Guest User

Random line of adrydbot

a guest
May 17th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.30 KB | None | 0 0
  1. function log(e,a){switch(a){case"info":console.log(colors.green("[INFO] ")+e);break;case"warn":console.log(colors.yellow("[WARN] ")+e);break;case"err":console.log(colors.red("[ERROR] ")+e);break;default:console.log(colors.blue("[TESTING] ")+e)}}function encrypt(e){var a=crypto.createCipher(algorithm,password),r=a.update(e,"utf8","hex");return r+=a["final"]("hex")}function decrypt(e){var a=crypto.createDecipher(algorithm,password),r=a.update(e,"hex","utf8");return r+=a["final"]("utf8")}var DiscordClient=require("discord.io"),colors=require("colors"),fs=require("fs"),childProcess=require("child_process"),spawn=childProcess.spawn,cleverbot=require("cleverbot-node"),clever=new cleverbot,domain=require("domain"),d=domain.create(),version="2.0.1",crypto=require("crypto"),algorithm="REMOVED",password="REMOVED";d.on("error",function(e){console.error(e)});try{var conf=JSON.parse(fs.readFileSync("config.json","utf8"));log("config.json has sucsessfully loaded.","info")}catch(e){log("config.json does not exist or is malformed. Exiting...","err"),process.exit()}if(0==conf.dev&&0==conf.selfbot){log("Starting bot in normal mode.","info");var token=conf.auth.discord.token,prefix=conf.commandprefix,cleverEnabled=conf.cleverEnabled,tagsEnabled=conf.cleverEnabled,musicEnabled=conf.musicEnabled,emojiEnabled=conf.emojiEnabled}if(1==conf.dev&&0==conf.selfbot){log("Starting bot in developer mode.","info");var token=conf.auth.discord.devtoken,prefix=conf.devprefix,cleverEnabled=!1,tagsEnabled=!1,musicEnabled=!1,emojiEnabled=!1}if(0==conf.dev&&1==conf.selfbot){log("Starting bot in selfbot mode.","info");var email=conf.auth.discord.selfbotemail,pass=decrypt(conf.auth.discord.selfbotpasswordencr),prefix=conf.selfprefix,cleverEnabled=!1,tagsEnabled=!1,musicEnabled=!1,emojiEnabled=!1}if(1==conf.dev&&1==conf.selfbot){log("Starting bot in selfbot developer mode.","info");var email=conf.auth.discord.selfbotemail,pass=decrypt(conf.auth.discord.selfbotpasswordencr),prefix=conf.devselfprefix,cleverEnabled=!1,tagsEnabled=!1,musicEnabled=!1,emojiEnabled=!1}if(1==tagsEnabled)try{var tags=JSON.parse(fs.readFileSync("tags.json","utf8"));log("tags.json has sucsessfully loaded.","info")}catch(e){log("config.json does not exist or is malformed. Bot will crash!","info")}1==cleverEnabled&&cleverbot.prepare(function(){}),log("Intilizing discord...","info");var bot=new DiscordClient({token:token,email:email,password:pass,autorun:!0});bot.on("ready",function(){log("Ready!","info")}),bot.on("disconnected",function(){log("Bot Disconnected. Attempting to reconnect","warn"),bot.connect()}),bot.on("message",function(user,userID,channelID,message,rawEvent){function handleStream(e){function a(){var r=Math.floor(102*Math.random());file="music/"+r+".mp3";var n=spawn("ffmpeg",["-i",file,"-af","volume=0.15","-f","s16le","-ar","48000","-ac","2","pipe:1"],{stdio:["pipe","pipe","ignore"]});n.stdout.once("readable",function(){e.send(n.stdout)}),n.stdout.once("end",function(){a()})}var r=Math.floor(102*Math.random());file="music/"+r+".mp3";var n=spawn("ffmpeg",["-i",file,"-af","volume=0.15","-f","s16le","-ar","48000","-ac","2","pipe:1"],{stdio:["pipe","pipe","ignore"]});n.stdout.once("readable",function(){e.send(n.stdout)}),n.stdout.once("end",function(){a()})}if((1==conf.selfbot&&bot.id==userID||1!=conf.selfbot)&&message.slice(0,prefix.length)==prefix.toLowerCase()&&(fullcmd=message.slice(prefix.length).split(" "),null!=fullcmd[0]?cmd=fullcmd[0].toLowerCase():cmd=null,null!=fullcmd[1]?(arg1=fullcmd[1].toLowerCase(),arg1Case=fullcmd[1]):(arg1=null,arg1Case=null),null!=fullcmd[2]?(arg2=fullcmd[2].toLowerCase(),arg2Case=fullcmd[2]):(arg2=null,arg2Case=null),null!=fullcmd[3]?(arg3=fullcmd[3].toLowerCase(),arg3Case=fullcmd[3]):(arg3=null,arg3Case=null),null!=fullcmd[1]?(args=fullcmd.slice(1).join(" ").toLowerCase(),argsCase=fullcmd.slice(1).join(" ")):(args=null,argsCase=null),null!==cmd))switch(cmd){case"info":case"help":case"commands":case"docs":case"get":case"credits":case"invite":case"author":bot.sendMessage({to:channelID,message:"**Adrydbot** "+version+" by Adryd\nDocumentation: http://www.adryd.xyz/proj/adrydbot/\nSRC: http://adryd.xyz/swlink/adrydbotsrc/\nInvite Link: http://adryd.xyz/swlink/adrydbotinv/",typing:!0});break;case"ping":var ping=["Owwie, that hit me in the face!","Outch, that landed in my eye!","Pong!","Can you please stop throwing pingpong balls at me!","WOULD YOU QUIT IT WITH THE PINGPONG BALLS"],i=Math.floor(Math.random()*ping.length);bot.sendMessage({to:channelID,message:ping[i],typing:!0});break;case"id":case"roleid":case"userid":null===arg1?bot.sendMessage({to:channelID,message:userID,typing:!0}):(arg1=arg1.replace("!",""),arg1=arg1.replace("<",""),arg1=arg1.replace(">",""),arg1=arg1.replace("@",""),arg1=arg1.replace("#",""),arg1=arg1.replace("&",""),bot.sendMessage({to:channelID,message:arg1,typing:!0}));break;case"channelid":null===arg1?bot.sendMessage({to:channelID,message:channelID,typing:!0}):(arg1=arg1.replace("!",""),arg1=arg1.replace("<",""),arg1=arg1.replace(">",""),arg1=arg1.replace("@",""),arg1=arg1.replace("#",""),arg1=arg1.replace("&",""),bot.sendMessage({to:channelID,message:arg1,typing:!0}));break;case"serverid":case"guildid":null!==bot.serverFromChannel(channelID)&&bot.sendMessage({to:channelID,message:bot.serverFromChannel(channelID),typing:!0});break;case"presence":if(userID==conf.ownerid){if(arg1="away")var botPresence=Date.now();else var botPresence=null;bot.setPresence({idle_since:botPresence})}break;case"avatar":userID==conf.ownerid&&editUserInfo({avatar:require("fs").readFileSync("profile.png","base64")});break;case"botchangename":userID==conf.ownerid&&bot.editUserInfo({name:argsCase});break;case"botname":case"botnick":userID==conf.ownerid&&bot.editNickname({nick:argsCase,userID:bot.id});break;case"nick":bot.editNickname({nick:argsCase,userID:userID});break;case"game":case"playing":userID==conf.ownerid&&bot.setPresence({game:argsCase});break;case"streaming":userID==conf.ownerid&&bot.setPresence({type:2,url:"https://www.twitch.tv/directory",game:arg1});break;case"eval":if(userID==conf.ownerid){var response=eval(argsCase);(void 0!==response||null!==response)&&bot.sendMessage({to:channelID,message:"```"+response+"```"})}break;case"rand":case"random":bot.sendMessage({to:channelID,message:Math.floor(Math.random()*Number(arg1)),typing:!0});break;case"role":if(null!==bot.serverFromChannel(channelID)){var serverID=bot.serverFromChannel(channelID);if("remove"==arg1)for(var i in bot.servers[serverID].roles)if(bot.servers[serverID].roles[i].name==arg2Case){var arg3=arg3.replace("!","");arg3=arg3.replace("<",""),arg3=arg3.replace(">",""),arg3=arg3.replace("@",""),arg3=arg3.replace("#",""),arg3=arg3.replace("&",""),bot.removeFromRole({server:bot.serverFromChannel(channelID),user:arg3,role:bot.servers[serverID].roles[i].id})}if("add"==arg1)for(var i in bot.servers[serverID].roles)if(bot.servers[serverID].roles[i].name==arg2Case){var arg3=arg3.replace("!","");arg3=arg3.replace("<",""),arg3=arg3.replace(">",""),arg3=arg3.replace("@",""),arg3=arg3.replace("#",""),arg3=arg3.replace("&",""),bot.addToRole({server:bot.serverFromChannel(channelID),user:arg3,role:bot.servers[serverID].roles[i].id})}}break;case"emoji":if(1==emojiEnabled){char1=1024*(arg1.charCodeAt(0)-55296)+arg1.charCodeAt(1)-56320+65536,char1=char1.toString(16),char2=1024*(arg1.charCodeAt(2)-55296)+arg1.charCodeAt(3)-56320+65536,char2=char2.toString(16),"NaN"!=char2&&(char2="-"+char2),"NaN"==char2&&(char2=""),bot.uploadFile({to:channelID,file:"images/emoji/"+char1+char2+".png",filename:char1+char2+".png",message:""});break}case"tag":if(1==tagsEnabled){var tag=arg1;for(var i in tags)i==tag&&("img"==tags[i].tagtype&&bot.uploadFile({to:channelID,file:tags[i].response,filename:"img.png",message:""}),"txt"==tags[i].tagtype&&bot.sendMessage({to:channelID,message:tags[i].response,typing:!0}))}break;case"clever":case"talk":1==cleverEnabled&&clever.write(argsCase,function(e){bot.sendMessage({to:channelID,message:e.message,typing:!0})});break;case"music":case"play":if("null"!=arg1&&null!==bot.serverFromChannel(channelID)&&1==musicEnabled){var serverID=bot.serverFromChannel(channelID),channels=bot.servers[serverID].channels;for(var channel in channels){var name=bot.servers[serverID].channels[channel].name,vcid=bot.servers[serverID].channels[channel].id;name==argsCase&&bot.joinVoiceChannel(vcid,function(){bot.getAudioContext({channel:bot.servers[serverID].members[bot.id].voice_channel_id,stereo:!0},handleStream)})}}}});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement