Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.56 KB | None | 0 0
  1. var exports = module.exports = {};
  2. exports.runAlt = async function(emai, pass, glroom, glroom2,database) {
  3.  
  4. var stdin = process.openStdin();
  5. const color = require('chalk');
  6. var htdecode = require('unescape');
  7. const DCB = require('./discord/dc.js');
  8. const miniplug = require('miniplug');
  9. const { MEDIA_SOURCE } = require('miniplug')
  10. const { ROLE } = require('miniplug')
  11. const alt = miniplug({
  12. email: emai,
  13. password: pass
  14. });
  15. const bot = alt;
  16. const mp = alt;
  17. let mentio = true;
  18. alt.join(glroom).then((room) => {
  19. alt.woot().then(() => {});
  20. console.log(color.hex('#DEADED')("Joined " + room.meta.name));
  21. });
  22. // def not mp-api copypaste below
  23. let timeout = 0
  24. function reconnect () {
  25. console.log(color.yellow('Reconnecting...'))
  26. mp.connect({ email: emai, password: pass })
  27. .then(() => {
  28. console.log(color.yellow('Reconnected!'))
  29. })
  30. .catch(() => {
  31. console.log(color.red('Failed to reconnect, trying again in', timeout, 'ms'))
  32. setTimeout(reconnect, timeout)
  33. })
  34. timeout += 1000 // 1 second
  35. }
  36. mp.on('disconnected', () => {
  37. console.log(color.red('Connection lost.'))
  38. reconnect()
  39. })
  40. /* start self-APIs */
  41. alt.sendChat = (msg) => {
  42. return alt.chat(msg).then((mesg) => {});
  43. }
  44. const woot = () => {
  45. alt.woot().then(() =>{});
  46. }
  47. const grab = (MoveBoolean) => {
  48. if(MoveBoolean !== true && MoveBoolean !== false) {
  49. MoveBoolean = true;
  50. }
  51. if(alt.historyEntry()) {
  52. alt.getActivePlaylist().then((pl) => {
  53. pl.insert(alt.historyEntry().media.id, MoveBoolean);
  54. });
  55. }
  56. }
  57. const meh = () => {
  58. alt.meh().then(() =>{});
  59. }
  60. const getHistory = async () => {
  61. const hist = async () => {
  62. return await alt.getRoomHistory();
  63. }
  64. let result = await hist();
  65. return result;
  66. };
  67. /* end self-APIs */
  68. var history;
  69. history = await getHistory();
  70. function hasRank(user) {
  71. let rol = "undefined";
  72. if (user.gRole < 500) {
  73. switch(user.role) {
  74. case 0:
  75. case undefined:
  76. case null:
  77. rol = "USER";
  78. break;
  79. case 1000:
  80. rol = "RESIDENT DJ";
  81. break;
  82. case 2000:
  83. rol = "BOUNCER";
  84. break;
  85. case 3000:
  86. rol = "MANAGER";
  87. break;
  88. case 4000:
  89. rol = "CO-HOST";
  90. break;
  91. case 5000:
  92. rol = "HOST";
  93. }
  94. }else{
  95. if (user.gRole >= 500) {
  96. switch(user.gRole) {
  97. case 500:
  98. case undefined:
  99. case null:
  100. rol = "PROMOTER";
  101. break;
  102. case 750:
  103. rol = "PLOT MEMBER";
  104. break;
  105. case 2500:
  106. rol = "SITE MODERATOR";
  107. break;
  108. case 3000:
  109. case 4000:
  110. rol = "BRAND AMBASSADOR";
  111. break;
  112. case 5000:
  113. rol = "ADMIN";
  114. }
  115. }}
  116. return rol;
  117. }
  118. alt.on('chat', altCmd);
  119.  
  120. function altCmd(data) {
  121. data.getUser(data.uid).then((user) => {
  122. if (user !== null) {
  123. var id = user.id;
  124. var msg = data.message;
  125. if (msg.indexOf('!alteval') === 0 && id === 35957827 && msg.split(' ').length > 0) {
  126. try {
  127. //split space [1]
  128. eval(msg.substr("!alteval ".length, msg.length));
  129. } catch (error) {
  130. console.log(error);
  131. alt.sendChat('!wellrip because... Error: ' + error.message);
  132. }
  133. }
  134.  
  135. if (msg.toLowerCase().indexOf('@' + alt.me().username + ' tell me a joke') > -1) {
  136. var ar = ["Today at the bank, an old lady asked me to help check her balance. So I pushed her over.", "I bought some shoes from a drug dealer. I don't know what he laced them with, but I've been tripping all day.", "I told my girlfriend she drew her eyebrows too high. She seemed surprised.", "My dog used to chase people on a bike a lot. It got so bad, finally I had to take his bike away.", "I'm so good at sleeping. I can do it with my eyes closed.", "My boss told me to have a good day.. so I went home.", "Why is Peter Pan always flying? He neverlands.", `A woman walks into a library and asked if they had any books about paranoia. The librarian says "They're right behind you!"`, "The other day, my wife asked me to pass her lipstick but I accidentally passed her a glue stick. She still isn't talking to me.", "Why do blind people hate skydiving? It scares the hell out of their dogs.", "When you look really closely, all mirrors look like eyeballs.", `My friend says to me: "What rhymes with ora nge" I said: "No it doesn't`, "What do you call a guy with a rubber toe? Roberto.", "What did the pirate say when he turned 80 years old? Aye matey.", "My wife told me I had to stop acting like a flamingo. So I had to put my foot down.", "I couldn't figure out why the baseball kept getting larger. Then it hit me.", "Why did the old man fall in the well? Because he couldn't see that well.", "I ate a clock yesterday, it was very time consuming.", "Whatdya call a frenchman wearing sandals? Phillipe Phillope.", "A blind man walks into a bar. And a table. And a chair.", "I know a lot of jokes about unemployed people but none of them work.", "What's orange and sounds like a parrot? A carrot.", "Did you hear about the italian chef that died? He pasta way.", "Why couldn't the bicycle stand up? Because it was two tired!", "Parallel lines have so much in common. It’s a shame they’ll never meet.", "My wife accused me of being immature. I told her to get out of my fort.", "Where do you find a cow with no legs? Right w here you left it.", "When a deaf person sees someone yawn do they think it’s a scream?", "As I suspected, someone has been adding soil to my garden. The plot thickens.", "How do crazy people go through the forest? They take the physco path.", `And the lord said unto John, "Come forth and you will receive eternal life". John came fifth and won a toaster.`, "What did the traffic light say to the car? Don’t look! I’m about to change.", "I just wrote a book on reverse psychology. Do *not* read it!", "What did one hat say to the other? You stay here. I’ll go on ahead.", "Why wouldn’t the shrimp share his treasure? Because he was a little shellfish."];
  137. alt.sendChat(ar[Math.floor(Math.random() * ar.length)]);
  138. }
  139.  
  140. if (msg.indexOf('!shuffle') > -1 && id === 35957827) {
  141. playlist.shuffle()
  142. }
  143.  
  144. if (msg.indexOf('!dab') > -1) {
  145. alt.chat(':hyperdab:')
  146.  
  147. }
  148.  
  149. if (msg.indexOf('!leavewl') > -1 && id === 35957827) {
  150. mp.leaveWaitlist()
  151.  
  152. }
  153.  
  154. if (msg.indexOf('!joinwl') > -1 && id === 35957827) {
  155. mp.joinWaitlist()
  156.  
  157. }
  158.  
  159. if (msg.indexOf('!grab') > -1 && id === 35957827) {
  160. grab()
  161. }
  162. }
  163. })
  164. }
  165. //split space [1]
  166. eval(msg.substr("!alteval ".length,msg.length));
  167. } catch (error) {
  168. console.log(error);
  169. alt.sendChat('!wellrip because... Error: ' + error.message);
  170. }}}})}
  171. alt.on('chat', chatLogger);
  172. function chatLogger(data) {
  173. data.getUser(data.uid).then((user) => {
  174. if(user !== null) {
  175. var id = user.id;
  176. var username = user.username;
  177. var msg = data.message;
  178. var role = user.role;
  179. var gRole = user.gRole;
  180. var cid = data.cid;
  181.  
  182. //console.log('Chat event data:\n\n'+JSON.stringify(data)+'\n\n\n\ngetUser data:\n\n\n\n'+JSON.stringify(user))
  183.  
  184. if (msg.indexOf('') > -1) {
  185. console.log(color.cyan('['+new Date(new Date().getTime()).toLocaleString()+'] ') +color.red('['+cid+'] ') +color.grey('['+htdecode(username)+'] ')+ color.yellow('['+id+'] ')+ color.magentaBright('['+hasRank(user)+'] ') + color.whiteBright('['+htdecode(msg)+']'));
  186. }}})}
  187. alt.on('chat', mentionHandler);
  188. function mentionHandler(data) {
  189. data.getUser(data.uid).then((user) => {
  190. if(user !== null) {
  191. var id = user.id;
  192. var username = user.username;
  193. var msg = data.message;
  194. var role = user.role;
  195. var gRole = user.gRole;
  196. var cid = data.cid;
  197.  
  198. if (msg.indexOf('@'+alt.me().username) > -1 && id !== 3609549 && mentio === true) {
  199. DCB.DiscordClient.channels.get(DCB.DcConf.channelID).send('<@'+DCB.DiscordUser+'> **'+username+'** just mentioned your alt, **'+alt.me().username+'**, with the following message:\n'+htdecode(msg));
  200. console.log(color.hex('#FFD244')(username +' mentioned. Message below.'));
  201. console.log(color.cyan('['+new Date(new Date().getTime()).toLocaleString()+'] ') +color.red('['+cid+'] ') +color.grey('['+htdecode(username)+'] ')+ color.yellow('['+id+'] ')+ color.magentaBright('['+hasRank(user)+'] ') + color.whiteBright('['+htdecode(msg)+']'));
  202. mentio = false;
  203. setTimeout(() => {
  204. mentio = true;
  205. DCB.DcConf.cooldown * 1000});
  206. }}})}
  207. alt.on('chatDelete', (data) => {
  208. if (data.user !== null) {
  209. console.log(color.blueBright('['+htdecode(data.user.username)+'] deleted message with id ['+data.cid+']'));
  210. }});
  211. alt.on('gifted', (data) => {
  212. console.log(color.yellow('['+data.recipient+'] just got some PP, gifted by ['+htdecode(data.sender)+']'));
  213. });
  214. alt.on('grab', (data) => {
  215. if (data.username !== null)
  216. console.log(color.blueBright('['+htdecode(data.username)+'] just grabbed current song, which is ')+ color.whiteBright(alt.historyEntry().media.author+' - '+ alt.historyEntry().media.title));
  217. });
  218. alt.on('userJoin', (data) => {
  219. //console.log('\n\n\n UserJoin data: \n'+JSON.stringify(data));
  220. switch(hasRank(data)) {
  221. case "PROMOTER":
  222. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Promoter ['+htdecode(data.username)+'] joined.'));
  223. break;
  224. case "PLOT MEMBER":
  225. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] pLot member ['+htdecode(data.username)+'] joined.'));
  226. break;
  227. case "SITE MODERATOR":
  228. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Site moderator ['+htdecode(data.username)+'] joined.'));
  229. break;
  230. case "BRAND AMBASSADOR":
  231. console.log(color.green('['+new Date(new Date().getTime()).toLocaleString()+'] Brand Ambassador ['+htdecode(data.username)+'] joined.'));
  232. break;
  233. case "ADMIN":
  234. console.log(color.blue('['+new Date(new Date().getTime()).toLocaleString()+'] Admin ['+htdecode(data.username)+'] joined.'));
  235. break;
  236. case "USER":
  237. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] User ['+htdecode(data.username)+'] joined.'));
  238. break;
  239. case "RESIDENT DJ":
  240. case "BOUNCER":
  241. case "MANAGER":
  242. case "CO-HOST":
  243. case "HOST":
  244. console.log(color.magentaBright('['+new Date(new Date().getTime()).toLocaleString()+'] Staff ['+htdecode(data.username)+'] joined.'));
  245. }});
  246. alt.on('guestJoin', () => {
  247. // no data provided to log
  248. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Guest joined.'));
  249. });
  250. alt.on('userLeave', (data) => {
  251. //console.log('\n\n\n UserLeave data: \n'+JSON.stringify(data));
  252. switch(hasRank(data)) {
  253. case "PROMOTER":
  254. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Promoter ['+htdecode(data.username)+'] left.'));
  255. break;
  256. case "PLOT MEMBER":
  257. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] pLot member ['+htdecode(data.username)+'] left.'));
  258. break;
  259. case "SITE MODERATOR":
  260. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Site moderator ['+htdecode(data.username)+'] left.'));
  261. break;
  262. case "BRAND AMBASSADOR":
  263. console.log(color.green('['+new Date(new Date().getTime()).toLocaleString()+'] Brand Ambassador ['+htdecode(data.username)+'] left.'));
  264. break;
  265. case "ADMIN":
  266. console.log(color.blue('['+new Date(new Date().getTime()).toLocaleString()+'] Admin ['+htdecode(data.username)+'] left.'));
  267. break;
  268. case "USER":
  269. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] User ['+htdecode(data.username)+'] left.'));
  270. break;
  271. case "RESIDENT DJ":
  272. case "BOUNCER":
  273. case "MANAGER":
  274. case "CO-HOST":
  275. case "HOST":
  276. console.log(color.magentaBright('['+new Date(new Date().getTime()).toLocaleString()+'] Staff ['+htdecode(data.username)+'] left.'));
  277. }});
  278. alt.on('guestLeave', () => {
  279. // no data provided to log
  280. console.log(color.gray('['+new Date(new Date().getTime()).toLocaleString()+'] Guest left.'));
  281. });
  282. var crS;
  283. alt.on('advance', async (next, previous) => {
  284. history = await getHistory();
  285.  
  286. //console.log('Next:\n\n'+JSON.stringify(next)+'\n\nPrevious:\n\n'+JSON.stringify(previous));
  287. if (previous !== null && history[0].score !== null && alt.historyEntry() !== null && next.user !== null && previous !== undefined && history[0].score !== undefined && alt.historyEntry() !== undefined && next.user !== undefined) {
  288. woot();
  289. crS = alt.historyEntry().media.author + ' - ' + alt.historyEntry().media.title;
  290. //ytplay.destroyYT(crS);
  291. console.log(color.cyan('Now playing: '+crS));
  292. console.log(color.whiteBright('DJ: '+htdecode(next.user.username)));
  293. console.log(color.cyan(crS) + color.whiteBright(' got ') + color.green(history[0].score.positive + ' woots, ') + color.magentaBright(history[0].score.grabs + ' grabs, ') + color.red(history[0].score.negative + ' mehs ') + color.whiteBright('with ') + color.gray(history[0].score.listeners+1) + color.whiteBright(' users listening'));
  294. }});
  295. alt.on('vote', (data) => {
  296. if (data.vote === -1 && data.user !== null && data.user !== undefined)
  297. console.log(color.red("User "+htdecode(data.user.username)+" meh'd current song."));
  298. });
  299. //console.log(JSON.stringify(data));
  300. alt.on('modAddDj', (data) => {
  301. // data.cycle is boolean(true or false), telling you whether or not the waitlist should cycle. Here we dont need this information but it's available.
  302. console.log(color.magentaBright('['+htdecode(data.moderator.username)+'] added user '+htdecode(data.username)+' to the waitlist.'));
  303. });
  304. alt.on('modRemoveDj', (data) => {
  305. // data.inBooth is boolean(true or false), telling you wheter or not the user removed was in the booth/djing.
  306. console.log(color.magentaBright(`[`+htdecode(data.moderator.username)+`] removed user `+htdecode(data.username)+` from the ${data.inBooth ? 'booth' : 'waitlist'}.`));
  307. });
  308. alt.on('modBan', (data) => {
  309. var duration = '';
  310. switch (data.duration) {
  311. case 'h': duration = 'for one hour'; break;
  312. case 'd': duration = 'for one day'; break;
  313. case 'f': duration = 'permanently'; break;
  314. }
  315. console.log(color.magentaBright('['+htdecode(data.moderator.username)+'] banned user '+htdecode(data.username)+' from the community '+duration+'.'));
  316. });
  317. alt.on('modMute', (data) => {
  318. // def not copypaste from miniplug docs :eyes:
  319. var length = '', reason = '';
  320. switch (data.duration) {
  321. case 'o': length = 'unmuted'; break;
  322. case 's': length = '15'; break;
  323. case 'm': length = '30'; break;
  324. case 'l': length = '45'; break;
  325. }
  326. switch (data.reason) {
  327. case 1: reason = 'violating community rules'; break;
  328. case 2: reason = 'verbal abuse or harassment'; break;
  329. case 3: reason = 'spamming or trolling'; break;
  330. case 4: reason = 'offensive language'; break;
  331. case 5: reason = 'negative attitude'; break;
  332. }
  333. if (length === 'o') {
  334. console.log(color.magentaBright('['+htdecode(data.moderator.username)+'] unmuted user '+htdecode(data.user.username)));
  335. }else{
  336. console.log(color.magentaBright(`[`+htdecode(data.moderator.username)+`] muted user `+htdecode(data.user.username)+` for ${length} minutes with the following reason: ${reason}`));
  337. }});
  338. alt.on('modMoveDj', (data) => {
  339. console.log(color.magentaBright('['+htdecode(data.moderator.username)+'] moved user '+htdecode(data.username)+' from position '+Number(data.movedFrom+1)+' to '+Number(data.movedTo+1)+' in the wait list.'));
  340. });
  341. alt.on('modSkip', (data) => {
  342. console.log(color.magentaBright('['+htdecode(data.username)+'] skipped the current song.'));
  343. });
  344. stdin.addListener("data", function(d) {
  345. var msg = d.toString().trim();
  346. if (msg.indexOf('$!') === 0) {
  347. try {
  348. eval(msg.substr(2));
  349. }catch(error) {
  350. console.log("Something didn't really work out... "+error);
  351. }
  352. }else{
  353. alt.sendChat(msg);
  354. }});
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement