Advertisement
n128

emotes

Jul 25th, 2018
3,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CHAT.JS
  2.  
  3. añades este const
  4.  
  5. const parseEmoticons = require('./server-plugins/emoticons').parseEmoticons;
  6.  
  7. Buscas output the message y sustituyes esto
  8.  
  9. // Output the message
  10.         if (message && message !== true && typeof message.then !== 'function') {
  11.             if (this.pmTarget) {
  12.                 const parsedMsg = parseEmoticons(message, this.room, this.user, true);
  13.                 if (parsedMsg) message = '/html ' + parsedMsg;
  14.                 let buf = `|pm|${this.user.getIdentity()}|${this.pmTarget.getIdentity()}|${message}`;
  15.                 this.user.send(buf);
  16.                 if (this.pmTarget !== this.user) this.pmTarget.send(buf);
  17.  
  18.                 this.pmTarget.lastPM = this.user.userid;
  19.                 this.user.lastPM = this.pmTarget.userid;
  20.             } else {
  21.                 if (Users.ShadowBan.checkBanned(this.user)) {
  22.                     if (parseEmoticons(message, this.room, this.user)) return;
  23.                     Users.ShadowBan.addMessage(this.user, `To ${this.room.id}`, message);
  24.                     this.user.sendTo(this.room.id, `|c|${this.user.getIdentity(this.room.id)}|${message}`);
  25.                 } else {
  26.                     if (Users.ShadowBan.checkBanned(this.user)) {
  27.                         Users.ShadowBan.addMessage(this.user, "To " + this.room.id, message);
  28.                         this.user.sendTo(this.room, (this.room.type === 'chat' ? '|c:|' + (~~(Date.now() / 1000)) + '|' : '|c|') + this.user.getIdentity(this.room.id) + '|' + message);
  29.                     } else {
  30.                         if (parseEmoticons(message, this.room, this.user)) return;
  31.                         this.room.add(`|c|${this.user.getIdentity(this.room.id)}|${message}`).update();
  32.                     }
  33.                 }
  34.             }
  35.         }
  36.  
  37.  
  38.         this.update();
  39.  
  40.         return message;
  41.     }
  42.  
  43. EMOTICONS.JS
  44.  
  45. 'use strict';
  46.  
  47. let demFeels = function () {};
  48. demFeels.getEmotes = function () {
  49.     return {};
  50. };
  51. try {
  52.     demFeels = require('dem-feels');
  53. } catch (e) {
  54.     console.error(e);
  55. }
  56.  
  57. exports.parseEmoticons = parseEmoticons;
  58.  
  59. // for travis build
  60. if (typeof demFeels.extendEmotes === 'function') {
  61.     // example extending emotes
  62.     demFeels.extendEmotes({
  63.         ':alemania:': 'https://images.emojiterra.com/twitter/v11/svg/1f1e9-1f1ea.svg',
  64.         ':arabiasaudi:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f8-1f1e6.svg',
  65.         ':argentina:': 'https://images.emojiterra.com/twitter/128px/1f1e6-1f1f7.png',
  66.         ':australia:': 'https://images.emojiterra.com/twitter/512px/1f1e6-1f1fa.png',
  67.         ':belgica:': 'https://images.emojiterra.com/twitter/v11/svg/1f1e7-1f1ea.svg',
  68.         ':brasil:': 'https://images.emojiterra.com/twitter/128px/1f1e7-1f1f7.png',
  69.         ':colombia:': 'https://images.emojiterra.com/twitter/128px/1f1e8-1f1f4.png',
  70.         ':costarica:': 'https://images.emojiterra.com/twitter/128px/1f1e8-1f1f7.png',
  71.         ':croacia:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ed-1f1f7.svg',
  72.         ':dinamarca:': 'https://images.emojiterra.com/twitter/v11/svg/1f1e9-1f1f0.svg',
  73.         ':egipto:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ea-1f1ec.svg',
  74.         ':españa:': 'https://images.emojiterra.com/twitter/512px/1f1ea-1f1f8.png',
  75.         ':francia:': 'https://images.emojiterra.com/twitter/512px/1f1eb-1f1f7.png',
  76.         ':inglaterra:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ec-1f1e7.svg',
  77.         ':iran:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ee-1f1f7.svg',
  78.         ':islandia:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ee-1f1f8.svg',
  79.         ':japon:': 'https://images.emojiterra.com/twitter/v11/svg/1f1ef-1f1f5.svg',
  80.         ':marruecos:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f2-1f1e6.svg',
  81.         ':mexico:': 'https://images.emojiterra.com/twitter/128px/1f1f2-1f1fd.png',
  82.         ':nigeria:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f3-1f1ec.svg',
  83.         ':panama:': 'https://images.emojiterra.com/twitter/128px/1f1f5-1f1e6.png',
  84.         ':peru:': 'https://images.emojiterra.com/twitter/128px/1f1f5-1f1ea.png',
  85.         ':polonia:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f5-1f1f1.svg',
  86.         ':portugal:': 'https://images.emojiterra.com/twitter/512px/1f1f5-1f1f9.png',
  87.         ':republicacorea:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f0-1f1f7.svg',
  88.         ':rusia:': 'https://images.emojiterra.com/twitter/512px/1f1f7-1f1fa.png',
  89.         ':senegal:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f8-1f1f3.svg',
  90.         ':serbia:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f7-1f1f8.svg',
  91.         ':suecia:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f8-1f1ea.svg',
  92.         ':suiza:': 'https://images.emojiterra.com/twitter/v11/svg/1f1e8-1f1ed.svg',
  93.         ':tunez:': 'https://images.emojiterra.com/twitter/v11/svg/1f1f9-1f1f3.svg',
  94.         ':uruguay:': 'https://images.emojiterra.com/twitter/128px/1f1fa-1f1fe.png',
  95.         ':feelsllama:': 'http://i.imgur.com/oSLSk2I.gif',
  96.         ':llamacool:': 'http://i.imgur.com/X1x3728.gif',
  97.         ':llamanoodle:': 'http://i.imgur.com/SUZkz5p.gif',
  98.         ':llamarawr:': 'http://i.imgur.com/KWAQbPu.gif',
  99.         ':llamatea:': 'http://i.imgur.com/nJnakEU.gif',
  100.         ':llamayawn:': 'http://i.imgur.com/SVj8kBt.gif',
  101.         ':llamamad:': 'http://i.imgur.com/eT7kdww.gif',
  102.         ':llamanv:': 'http://i.imgur.com/9PgUk4M.gif',
  103.         ':llamacute:': 'http://i.imgur.com/5hi0kjz.gif',
  104.         ':llamacry:': 'http://i.imgur.com/ID6i8rl.gif',
  105.         ':llamapretty:': 'http://i.imgur.com/mBPcOQW.gif',
  106.         ':llamabouncy:': 'http://i.imgur.com/PiMDmNd.gif',
  107.         ':llamahi:': 'http://i.imgur.com/2BeipQ8.gif',
  108.         ':llamasneaky:': 'http://i.imgur.com/8XT3CyT.gif',
  109.         ':llamadance:': 'http://i.imgur.com/Tl8xmiq.gif',
  110.         ':llamawink:': 'http://i.imgur.com/Xtjjjlm.gif',
  111.         ':llamashades:': 'http://i.imgur.com/jBlIicx.gif',
  112.         ':llama:3:': 'http://i.imgur.com/dkV8FSY.gif',
  113.         ':llamashy:': 'http://i.imgur.com/Bj7jSrc.gif',
  114.         ':llamafun:': 'http://i.imgur.com/eJIALUZ.gif',
  115.         ':llamawhat:': 'http://i.imgur.com/KdH5d2T.gif',
  116.         ':mierda:': 'https://images.emojiterra.com/google/android-oreo/128px/1f4a9.png',
  117.         ':ditto:': 'https://cdn.betterttv.net/emote/554da1a289d53f2d12781907/2x',
  118.         ':feelsnc:': 'https://i.imgur.com/BsP6ctd.png',
  119.         ':feelsbn:': 'http://i.imgur.com/wp51rIg.png',
  120.         ':feelsdeal:': 'https://s-media-cache-ak0.pinimg.com/originals/ca/c6/4a/cac64aa3ea9c836b93a00b347c5fcfd1.png',
  121.         ':feelsgay:': 'http://www.stickpng.com/assets/images/5845cad31046ab543d25238c.png',
  122.         ':feelscool:': 'https://risibank.fr/cache/stickers/d34/3498-full.png',
  123.         ':feelsperv:': 'http://www.stickpng.com/assets/images/5859b173711f64423aa5e050.png',
  124.         ':eeveesad:': 'http://123emoji.com/wp-content/uploads/2017/08/sticker-9-150.png',
  125.         ':dance:': 'https://i.imgur.com/eMxPpbf.gif',
  126.         ':tympole:': 'https://play.destinyshowdown.net/resources/custom-emojis/tympole.png',
  127.         ':dude:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/confused-face_1f615.png',
  128.         ':loves:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/smiling-face-with-heart-shaped-eyes_1f60d.png',
  129.         ':angel:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/smiling-face-with-halo_1f607.png',
  130.         ':oh:': 'https://images.emojiterra.com/twitter/128px/1f632.png',
  131.         ':XD:': 'https://images.emojiterra.com/twitter/128px/1f606.png',
  132.         ':lol:': 'https://images.emojiterra.com/twitter/128px/1f610.png',
  133.         ':ehhh:': 'https://images.emojiterra.com/twitter/128px/1f61b.png',
  134.         ':haha:': 'https://images.emojiterra.com/twitter/128px/1f602.png',
  135.         ':ohno:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/astonished-face_1f632.png',
  136.         ':heartsad:': 'https://images.emojiterra.com/twitter/128px/1f494.png',
  137.         ':heart:': 'https://images.emojiterra.com/twitter/128px/2764.png',
  138.         ':guiño:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/winking-face_1f609.png',
  139.         ':omg:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/grinning-face-with-smiling-eyes_1f601.png',
  140.         ':llorando:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/loudly-crying-face_1f62d.png',
  141.         ':mono1:': 'https://images.emojiterra.com/twitter/128px/1f64a.png',
  142.         ':mono2:': 'https://images.emojiterra.com/twitter/128px/1f649.png',
  143.         ':mono3:': 'https://images.emojiterra.com/twitter/128px/1f648.png',
  144.         ':disculpa:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/pensive-face_1f614.png',
  145.         ':ops:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/kissing-face_1f617.png',
  146.         ':feliz:': 'https://images.emojiterra.com/twitter/128px/1f601.png',
  147.         ':furioso:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/pouting-face_1f621.png',
  148.         ':bravo:': 'https://emojipedia-us.s3.amazonaws.com/thumbs/72/whatsapp/116/face-with-look-of-triumph_1f624.png',
  149.         ':eyes:': 'https://images.emojiterra.com/twitter/512px/1f440.png',
  150.         ':kheberga:': 'https://cdn.discordapp.com/emojis/466026815115493377.png',
  151.         ':thism8:': 'https://static1.squarespace.com/static/541fdc96e4b0a6db31386559/t/58e207271b10e31ed463d4dd/1491207980725/',
  152.         ':feelsasty:': 'https://i.kym-cdn.com/photos/images/facebook/000/952/389/ca9.png',
  153.         ':feelsnice:': 'https://i.imgur.com/lAlUwZ4.png',
  154.         ':feelssniper:': 'https://i.kym-cdn.com/photos/images/masonry/001/234/596/4a6.jpeg',
  155.         ':feelstrump:': 'https://i.kym-cdn.com/photos/images/masonry/001/170/288/368.jpg',
  156.         ':feelsgreninja:': 'https://i.kym-cdn.com/photos/images/masonry/001/171/821/1f3.png',
  157.         ':feelssceptile:': 'https://i.kym-cdn.com/photos/images/newsfeed/001/114/910/e40.png',
  158.         ':pikasad:': 'https://cdn.frankerfacez.com/emoticon/200142/4',
  159.         ':feelsweirdknife:': 'https://cdn.frankerfacez.com/emoticon/265224/4',
  160.         ':feelsweirdgun:': 'https://cdn.frankerfacez.com/emoticon/258488/4',
  161.         ':feelsrage:': 'https://cdn.frankerfacez.com/emoticon/251871/4',
  162.     });
  163. }
  164.  
  165. const emotes = demFeels.getEmotes();
  166.  
  167. const emotesKeys = Object.keys(emotes).sort();
  168.  
  169. /**
  170.  * Parse emoticons in message.
  171.  *
  172.  * @param {String} message
  173.  * @param {Object} room
  174.  * @param {Object} user
  175.  * @param {Boolean} pm - returns a string if it is in private messages
  176.  * @returns {Boolean|String}
  177.  */
  178. function parseEmoticons(message, room, user, pm) {
  179.     if (typeof message !== 'string' || (!pm && room.disableEmoticons)) return false;
  180.  
  181.     let match = false;
  182.     let len = emotesKeys.length;
  183.  
  184.     while (len--) {
  185.         if (message && message.indexOf(emotesKeys[len]) >= 0) {
  186.             match = true;
  187.             break;
  188.         }
  189.     }
  190.  
  191.     if (!match) return false;
  192.  
  193.     // escape HTML
  194.     message = Chat.escapeHTML(message);
  195.  
  196.     // add emotes
  197.     message = demFeels(message);
  198.  
  199.     // __italics__
  200.     message = message.replace(/\_\_([^< ](?:[^<]*?[^< ])?)\_\_(?![^<]*?<\/a)/g, '<i>$1</i>');
  201.  
  202.     // **bold**
  203.     message = message.replace(/\*\*([^< ](?:[^<]*?[^< ])?)\*\*/g, '<b>$1</b>');
  204.  
  205.     let group = user.getIdentity().charAt(0);
  206.     if (room && room.auth) group = room.auth[user.userid] || group;
  207.     if (pm && !user.hiding) group = user.group;
  208.  
  209.     if (pm) return "<div class='chat' style='display:inline'>" + "<em class='mine'>" + message + "</em></div>";
  210.  
  211.     let style = "background:none;border:0;padding:0 5px 0 0;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:9pt;cursor:pointer";
  212.     let name = user.getIdentity(room).substr(0, 1) + user.name;
  213.  
  214.     if (Users.ShadowBan.checkBanned(user)) {
  215.         user.sendTo(room, message = (`${(room.type === 'chat' ? '|c:|' + ~~(Date.now() / 1000) + '|' : '|c|') + name}|/html ${message}`));
  216.         Users.ShadowBan.addMessage(user, "To " + room);
  217.         return true;
  218.     } else {
  219.         message = room.add(`${(room.type === 'chat' ? '|c:|' + ~~(Date.now() / 1000) + '|' : '|c|') + name}|/html ${message}`).update();
  220.     }
  221.     for (let u in room.users) {
  222.         let targetUser = Users.get(u);
  223.         // in case the user is offline
  224.         if (!targetUser || !targetUser.connected) continue;
  225.         // if user is ignoring emotes
  226.         if (targetUser.blockEmoticons) {
  227.             targetUser.sendTo(room, "|c|" + group + user.name + "|" + originalMessage);
  228.         }
  229.     }
  230.     return true;
  231. }
  232.  
  233. /**
  234.  * Create a two column table listing emoticons.
  235.  *
  236.  * @return {String} emotes table
  237.  */
  238. function create_table() {
  239.     let emotes_name = Object.keys(emotes);
  240.     let emotes_list = [];
  241.     let emotes_group_list = [];
  242.     let len = emotes_name.length;
  243.  
  244.     for (let i = 0; i < len; i++) {
  245.         emotes_list.push("<td style='padding: 5px; box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5) inset; border-radius: 5px;'>" + "<img src='" + emotes[emotes_name[i]] + "'' title='" + emotes_name[i] + "' height='50' width='50' style='vertical-align: middle;  padding-right: 5px;' />" + emotes_name[i] + "</td>");
  246.     }
  247.  
  248.     for (let i = 0; i < len; i += 4) {
  249.         let emoteOutput = [emotes_list[i], emotes_list[i + 1], emotes_list[i + 2], emotes_list[i + 3]];
  250.         if (i < len) emotes_group_list.push("<tr>" + emoteOutput.join('') + "</tr>");
  251.     }
  252.  
  253.     return (
  254.         "<div class='infobox'><center><font style='font-weight: bold; text-decoration: underline; color: #555;'>Lista delle Emotes</font></center>" +
  255.         "<div style='max-height: 300px; overflow-y: scroll; padding: 5px 0px;'><table style='background: rgba(245, 245, 245, 0.4); border: 1px solid #BBB;' width='100%'>" +
  256.         emotes_group_list.join("") +
  257.         "</table></div></div>"
  258.     );
  259. }
  260.  
  261. let emotes_table = create_table();
  262.  
  263. exports.commands = {
  264.     blockemote: 'blockemoticons',
  265.     blockemotes: 'blockemoticons',
  266.     blockemoticon: 'blockemoticons',
  267.     blockemoticons: function (target, room, user) {
  268.         if (user.blockEmoticons === (target || true)) return this.sendReply("You are already blocking emoticons in private messages! To unblock, use /unblockemoticons");
  269.         user.blockEmoticons = true;
  270.         return this.sendReply("You are now blocking emoticons in private messages.");
  271.     },
  272.     blockemoticonshelp: ["/blockemoticons - Blocks emoticons in private messages. Unblock them with /unblockemoticons."],
  273.  
  274.     unblockemote: 'unblockemoticons',
  275.     unblockemotes: 'unblockemoticons',
  276.     unblockemoticon: 'unblockemoticons',
  277.     unblockemoticons: function (target, room, user) {
  278.         if (!user.blockEmoticons) return this.sendReply("You are not blocking emoticons in private messages! To block, use /blockemoticons");
  279.         user.blockEmoticons = false;
  280.         return this.sendReply("You are no longer blocking emoticons in private messages.");
  281.     },
  282.     unblockemoticonshelp: ["/unblockemoticons - Unblocks emoticons in private messages. Block them with /blockemoticons."],
  283.  
  284.     emotes: 'emoticons',
  285.     emoticons: function (target, room, user) {
  286.         if (!this.runBroadcast()) return;
  287.         this.sendReply("|raw|" + emotes_table);
  288.     },
  289.     emoticonshelp: ["/emoticons - Get a list of emoticons."],
  290.  
  291.     toggleemote: 'toggleemoticons',
  292.     toggleemotes: 'toggleemoticons',
  293.     toggleemoticons: function (target, room, user) {
  294.         if (!this.can('declare', null, room)) return false;
  295.         room.disableEmoticons = !room.disableEmoticons;
  296.         this.sendReply("Disallowing emoticons is set to " + room.disableEmoticons + " in this room.");
  297.         if (room.disableEmoticons) {
  298.             this.add("|raw|<div class=\"broadcast-red\"><b>Emoticons are disabled!</b><br />Emoticons will not work.</div>");
  299.         } else {
  300.             this.add("|raw|<div class=\"broadcast-blue\"><b>Emoticons are enabled!</b><br />Emoticons will work now.</div>");
  301.         }
  302.     },
  303.     toggleemoticonshelp: ["/toggleemoticons - Toggle emoticons on or off."],
  304.  
  305.     rande: 'randemote',
  306.     randemote: function (target, room, user) {
  307.         if (!this.runBroadcast()) return;
  308.         let rng = Math.floor(Math.random() * emotesKeys.length);
  309.         let randomEmote = emotesKeys[rng];
  310.         this.sendReplyBox("<img src='" + emotes[randomEmote] + "' title='" + randomEmote + "' height='50' width='50' />");
  311.     },
  312.     randemotehelp: ["/randemote - Get a random emote."],
  313. };
  314.  
  315. SHADOWBAN.JS
  316.  
  317. 'use strict';
  318.  
  319. const ROOM_NAME = "Shadow Ban Room";
  320. let room = Rooms.get(toId(ROOM_NAME));
  321. if (!room) {
  322.     Rooms.global.addChatRoom(ROOM_NAME);
  323.     room = Rooms.get(toId(ROOM_NAME));
  324.  
  325.     room.isPrivate = true;
  326.     room.staffRoom = true;
  327.     room.staffAutojoin = true;
  328.     room.addedUsers = {};
  329.  
  330.     if (room.chatRoomData) {
  331.         room.chatRoomData.isPrivate = true;
  332.         room.chatRoomData.staffRoom = true;
  333.         room.chatRoomData.staffAutojoin = true;
  334.         room.chatRoomData.addedUsers = room.addedUsers;
  335.  
  336.         Rooms.global.writeChatRoomData();
  337.     }
  338. }
  339. if (Object.keys(room.addedUsers).length > 0) {
  340.     setImmediate(function () {
  341.         room.add("||Loaded user list: " + Object.keys(room.addedUsers).sort().join(", "));
  342.         room.update();
  343.     });
  344. }
  345. exports.room = room;
  346.  
  347. function getAllAlts(user) {
  348.     let targets = {};
  349.     if (typeof user === 'string') {
  350.         targets[toId(user)] = 1;
  351.     } else {
  352.         user.getAltUsers().map(u => u.getLastName()).concat(user.name).forEach(function (altName) {
  353.             let alt = Users.get(altName);
  354.             if (!alt.named) return;
  355.  
  356.             targets[toId(alt)] = 1;
  357.             Object.keys(alt.prevNames).forEach(function (name) {
  358.                 targets[toId(name)] = 1;
  359.             });
  360.         });
  361.     }
  362.     return targets;
  363. }
  364.  
  365. function intersectAndExclude(a, b) {
  366.     let intersection = [];
  367.     let exclusionA = [];
  368.     let exclusionB = [];
  369.  
  370.     let ai = 0;
  371.     let bi = 0;
  372.     while (ai < a.length && bi < b.length) {
  373.         let difference = a[ai].localeCompare(b[bi]);
  374.         if (difference < 0) {
  375.             exclusionA.push(a[ai]);
  376.             ++ai;
  377.         } else if (difference > 0) {
  378.             exclusionB.push(b[bi]);
  379.             ++bi;
  380.         } else {
  381.             intersection.push(a[ai]);
  382.             ++ai;
  383.             ++bi;
  384.         }
  385.     }
  386.  
  387.     Array.prototype.push.apply(exclusionA, a.slice(ai));
  388.     Array.prototype.push.apply(exclusionB, b.slice(bi));
  389.     return {intersection: intersection, exclusionA: exclusionA, exclusionB: exclusionB};
  390. }
  391.  
  392. let checkBannedCache = {};
  393. exports.checkBanned = function (user) {
  394.     let userId = toId(user);
  395.     if (Users(userId).isStaff || Users(userId).isSysop) return false;
  396.     if (userId in checkBannedCache) return checkBannedCache[userId];
  397.     if (Users(userId).shadowbanned) return true;
  398.     //console.log("Shadow ban cache miss:", userId);
  399.  
  400.     let targets = Object.keys(getAllAlts(user)).sort();
  401.     let bannedUsers = Object.keys(room.addedUsers).sort();
  402.  
  403.     let matches = intersectAndExclude(targets, bannedUsers);
  404.     let isBanned = matches.intersection.length !== 0;
  405.     for (let t = 0; t < targets.length; ++t) {
  406.         if (isBanned) room.addedUsers[targets[t]] = 1;
  407.         checkBannedCache[targets[t]] = isBanned;
  408.     }
  409.     if (!isBanned) return false;
  410.  
  411.     if (matches.exclusionA.length > 0) {
  412.         Rooms.global.writeChatRoomData();
  413.         room.add("||Alts of " + matches.intersection[0] + " automatically added: " + matches.exclusionA.join(", "));
  414.     }
  415.  
  416.     return true;
  417. };
  418.  
  419. let addUser = exports.addUser = function (user) {
  420.     let targets = getAllAlts(user);
  421.     for (let u in targets) {
  422.         if (room.addedUsers[u]) {
  423.             delete targets[u];
  424.         } else {
  425.             room.addedUsers[u] = 1;
  426.         }
  427.         checkBannedCache[u] = true;
  428.     }
  429.     targets = Object.keys(targets).sort();
  430.  
  431.     if (targets.length > 0) {
  432.         Rooms.global.writeChatRoomData();
  433.         room.add("||Added users: " + targets.join(", "));
  434.         room.update();
  435.     }
  436.  
  437.     return targets;
  438. };
  439. let removeUser = exports.removeUser = function (user) {
  440.     let targets = getAllAlts(user);
  441.     for (let u in targets) {
  442.         if (!room.addedUsers[u]) {
  443.             delete targets[u];
  444.         } else {
  445.             delete room.addedUsers[u];
  446.         }
  447.         checkBannedCache[u] = false;
  448.     }
  449.     targets = Object.keys(targets).sort();
  450.  
  451.     if (targets.length > 0) {
  452.         Rooms.global.writeChatRoomData();
  453.         room.add("||Removed users: " + targets.join(", "));
  454.         room.update();
  455.     }
  456.  
  457.     return targets;
  458. };
  459.  
  460. exports.addMessage = function (user, tag, message) {
  461.     room.add('|c|' + user.getIdentity() + '|__(' + tag + ')__ ' + message);
  462.     room.update();
  463. };
  464.  
  465. exports.commands = {
  466.     spam: 'shadowban',
  467.     sban: 'shadowban',
  468.     shadowban: function (target, room, user) {
  469.         if (!target) return this.sendReply("/shadowban OR /sban [username], [secondary command], [reason] - Sends all the user's messages to the shadow ban room. Requires &");
  470.  
  471.         let params = this.splitTarget(target).split(',');
  472.         let action = params[0].trim().toLowerCase();
  473.         let reason = params.slice(1).join(',').trim();
  474.         if (!(action in Chat.commands)) {
  475.             action = 'mute';
  476.             reason = params.join(',').trim();
  477.         }
  478.  
  479.         if (!this.targetUser) return this.sendReply("User '" + this.targetUsername + "' not found.");
  480.         if (!this.can("rangeban", this.targetUser)) return;
  481.  
  482.         let targets = addUser(this.targetUser);
  483.         if (targets.length === 0) {
  484.             return this.sendReply('||' + this.targetUsername + " is already shadow banned or isn't named.");
  485.         }
  486.         this.privateModAction("(" + user.name + " has shadow banned: " + targets.join(", ") + (reason ? " (" + reason + ")" : "") + ")");
  487.  
  488.         //return this.parse('/' + action + ' ' + toId(this.targetUser) + ',' + reason);
  489.     },
  490.  
  491.     unspam: 'unshadowban',
  492.     unsban: 'unshadowban',
  493.     unshadowban: function (target, room, user) {
  494.         if (!target) return this.sendReply("/unshadowban OR /unsban [username] - Undoes /shadowban (except the secondary command).");
  495.         this.splitTarget(target);
  496.  
  497.         if (!this.can("rangeban")) return;
  498.  
  499.         let targets = removeUser(this.targetUser || this.targetUsername);
  500.         if (targets.length === 0) {
  501.             return this.sendReply('||' + this.targetUsername + " is not shadow banned.");
  502.         }
  503.         this.privateModAction("(" + user.name + " has shadow unbanned: " + targets.join(", ") + ")");
  504.     },
  505.  
  506.     sbanlist: function (target, room, user) {
  507.         if (!target && !this.can("rangeban")) return this.sendReply("The command '/sbanlist' was unrecognized.  To send a message starting with '/sbanlist', type '//sbanlist'.");
  508.         if (!this.canTalk() && !user.can('bypassall')) return this.sendReply("You cannot do this while unable to talk.");
  509.         if (!this.can("rangeban")) return false;
  510.         let result = [];
  511.         let data = Rooms(toId(ROOM_NAME)).chatRoomData.addedUsers;
  512.         for (let key in data) {
  513.             result.push(key);
  514.         }
  515.         Users.get(toId(user.name)).send('|popup| Here is a list of sbanned users: \n' + result.join(', '));
  516.     },
  517. };
  518.  
  519. Users.ShadowBan = exports;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement