Advertisement
Guest User

extremesupport.js

a guest
Mar 23rd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. registerPlugin({
  2.     name: 'extremesupport',
  3.     version: '1.0',
  4.     description: 'Dieses Script unterstützt viele Support-Optionen.',
  5.     author: 'Dennis Hoffmann',
  6.     engines: '>= 0.9.16',
  7.     vars: [
  8.         //Supporter Groups (GroupId, GroupName, Permissions, Channels[ChannelId, timeToMessage]
  9.         {
  10.             name: 'groups',
  11.             title: 'Groups',
  12.             type: 'array',
  13.             vars: [
  14.                 {name: 'id', title: 'Group Id', type: 'number'},
  15.                 {name: 'name', title: 'Group Name', type: 'string'},
  16.                 {name: 'permissions', title: 'Group Permissions', type: 'string'},
  17.                 {
  18.                     name: 'channels',
  19.                     title: 'Support Channels',
  20.                     type: 'array',
  21.                     vars: [
  22.                         {name: 'id', title: 'Channel Id', type: 'channel'},
  23.                         {name: 'time', title: 'Time to Info-Message', type: 'number'}
  24.                     ]
  25.                 }
  26.             ]
  27.         },
  28.  
  29.         //Supporter Users (UserUid, UserName, Permissions, Channels[ChannelId, timeToMessage]
  30.         {
  31.             name: 'users',
  32.             title: 'Users',
  33.             type: 'array',
  34.             vars: [
  35.                 {name: 'uid', title: 'Users Uid', type: 'string'},
  36.                 {name: 'name', title: 'User Name', type: 'string'},
  37.                 {name: 'permissions', title: 'User Permissions', type: 'string'},
  38.                 {
  39.                     name: 'channels',
  40.                     title: 'Support Channels',
  41.                     type: 'array',
  42.                     vars: [
  43.                         {name: 'id', title: 'Channel Id', type: 'channel'},
  44.                         {name: 'time', title: 'Time to Info-Message', type: 'number'}
  45.                     ]
  46.                 }
  47.             ]
  48.         },
  49.  
  50.         //Support Log Channels (ChannelId)
  51.         {
  52.             name: 'logs',
  53.             title: 'Log-Channels',
  54.             type: 'array',
  55.             vars: [
  56.                 {name: 'id', title: 'Channel Id', type: 'channel'}
  57.             ]
  58.         },
  59.  
  60.         //Support Info Channels (ChannelId, MessageType, Message)
  61.         {
  62.             name: 'infos',
  63.             title: 'Info-Channels',
  64.             type: 'array',
  65.             vars: [
  66.                 {name: 'id', title: 'Channel Id', type: 'channel'},
  67.                 {name: 'type', title: 'Message Type', type: 'select', options: ['Poke', 'Chat']},
  68.                 {name: 'message', title: 'Message', type: 'multiline'}
  69.             ]
  70.         },
  71.  
  72.         {
  73.             name: 'blockedchannels',
  74.             title: 'Blocked Channels',
  75.             type: 'array',
  76.             vars: [
  77.                 {name: 'id', title: 'Channel Id', type: 'channel'}
  78.             ]
  79.         },
  80.  
  81.         { name: 'supportWarteraum', title: 'Support Warteraum', type: 'channel'},
  82.  
  83.         {
  84.             name: 'autoSupports',
  85.             title: 'Auto Support',
  86.             type: 'array',
  87.             vars: [
  88.                 {name: 'supmenuid', title: 'Support Chat Id', type: 'number'},
  89.                 {name: 'supchatmsg', title: 'Support Chat Message', type: 'multiline'},
  90.                 {name: 'supnewchannel', title: 'Move to Channel', type: 'channel'},
  91.                 {
  92.                     name: 'awnsers',
  93.                     title: 'Antworten',
  94.                     type: 'array',
  95.                     vars: [
  96.                         {name: 'value', title: 'Antwort', type: 'string'},
  97.                         {name: 'newmenuid', title: 'Neue Support Chat Id', type: 'number'}
  98.                     ]
  99.                 }
  100.             ]
  101.         }
  102.     ]
  103. }, function(sinusbot, config) {
  104.     /*
  105.     Store:
  106.     _0 Wartezeit
  107.     _1 toga
  108.     _2 menuid
  109.      */
  110.     var store = require('store');
  111.     var event = require('event');
  112.     var backend = require('backend');
  113.     var db = require('db');
  114.     var engine = require('engine');
  115.     var helpers = require('helpers');
  116.     var dbc = db.connect({ driver: 'mysql', host: '127.0.0.1', username: '******', password: '******', database: '******' }, function(err) {
  117.         if (err) { engine.log(err); }
  118.     });
  119.  
  120.     function getMenu(client){
  121.         var value = store.get(client.uid() + "_2");
  122.         if(value == null)value = -1;
  123.         return value;
  124.     }
  125.  
  126.     function setMenu(client, value){
  127.         store.set(client.uid() + "_2", value);
  128.     }
  129.  
  130.     function resetMenu(client){
  131.         store.unset(client.uid() + "_2");
  132.     }
  133.  
  134.     function getToga(client){
  135.         var value = store.get(client.uid() + "_1");
  136.         if(value == null)value = 1;
  137.         return value;
  138.     }
  139.  
  140.     function setToga(client, value){
  141.         store.set(client.uid() + "_1", value);
  142.     }
  143.  
  144.     function toggleToga(client){
  145.         if(isInAnyGroup(client) == 0){
  146.             return -1;
  147.         }
  148.         if(getToga(client) == 0){
  149.             setToga(client, 1);
  150.             return 1;
  151.         }
  152.         else {
  153.             setToga(client, 0);
  154.             return 0;
  155.         }
  156.     }
  157.    
  158.     function getGamesupport(client){
  159.         var value = store.get(client.uid() + "_3");
  160.         if(value == null)value = 0;
  161.         return value;
  162.     }
  163.  
  164.     function setGamesupport(client, value){
  165.         store.set(client.uid() + "_3", value);
  166.     }
  167.  
  168.     function toggleGamesupport(client){
  169.         if(isInAnyGroup(client) == 0){
  170.             return -1;
  171.         }
  172.         if(getGamesupport(client) == 0){
  173.             setGamesupport(client, 1);
  174.             return 1;
  175.         }
  176.         else {
  177.             setGamesupport(client, 0);
  178.             return 0;
  179.         }
  180.     }
  181.  
  182.     function ticketUnset(key){
  183.         store.unset(key + "_0");
  184.     }
  185.  
  186.     function ticketReset(key){
  187.         store.set(key + "_0", 0);
  188.     }
  189.  
  190.     function ticketGet(key){
  191.         var value = store.get(key + "_0");
  192.         if(value == null)value = -1;
  193.         return value;
  194.     }
  195.  
  196.     function ticketAdd(key){
  197.         var value = ticketGet(key) + 1;
  198.         store.set(key + "_0", value);
  199.         return value;
  200.     }
  201.  
  202.     function isSupportGroupChannel(channel){
  203.         var bool = 0;
  204.         if(channel != null && config.groups != null){
  205.             config.groups.forEach(function(group) {
  206.                 if(group.channels != null && bool == 0){
  207.                     group.channels.forEach(function(ch) {
  208.                         if(channel.id() == ch.id)bool = 1;
  209.                     });
  210.                 }
  211.             });
  212.         }
  213.         return bool;
  214.     }
  215.  
  216.     function isSupportUserChannel(channel){
  217.         var bool = 0;
  218.         if(channel != null && config.users != null){
  219.             config.users.forEach(function(user) {
  220.                 if(user.channels != null && bool == 0){
  221.                     user.channels.forEach(function(ch) {
  222.                         if(channel.id() == ch.id)bool = 1;
  223.                     });
  224.                 }
  225.             });
  226.         }
  227.         return bool;
  228.     }
  229.  
  230.     function isSupportLogChannel(channel){
  231.         var bool = 0;
  232.         if(channel != null && config.logs != null){
  233.             config.logs.forEach(function(ch) {
  234.                 if(channel.id() == ch.id)bool = 1;
  235.             });
  236.         }
  237.         return bool;
  238.     }
  239.  
  240.     function isSupportInfoChannel(channel){
  241.         var bool = 0;
  242.         if(channel != null && config.infos != null){
  243.             config.infos.forEach(function(ch) {
  244.                 if(channel.id() == ch.id)bool = 1;
  245.             });
  246.         }
  247.         return bool;
  248.     }
  249.  
  250.     function getUserConfigGroupName(client){
  251.         var value = "";
  252.         if(client != null && config.groups != null){
  253.             client.getServerGroups().forEach(function(cgroup) {
  254.                 config.groups.forEach(function (group) {
  255.                     if(cgroup.id() == group.id)value = group.name;
  256.                 });
  257.             });
  258.         }
  259.         return value;
  260.     }
  261.  
  262.     function getUserConfigUserName(client){
  263.         var value = "";
  264.         if(client != null && config.users != null){
  265.             config.users.forEach(function (user) {
  266.                 if(client.uid() == user.uid)value = user.name;
  267.             });
  268.         }
  269.         return value;
  270.     }
  271.  
  272.     function isInAnyGroup(client){
  273.         var bool = 0;
  274.         if(getUserConfigGroupName(client) != "")bool = 1;
  275.         else if(getUserConfigUserName(client) != "")bool = 1;
  276.         return bool;
  277.     }
  278.  
  279.     function log(fromChannel,toChannel,client,invoker){
  280.         if (dbc) dbc.exec("INSERT INTO log (supporterName,supporterUid,configGroup,userName,userUid,fromChannelName,fromChannelId,toChannelName,toChannelId) VALUES ('"+invoker.name()+"','"+invoker.uid()+"','"+getUserConfigGroupName(invoker)+"','"+client.name()+"','"+client.uid()+"','"+fromChannel.name()+"','"+fromChannel.id()+"','"+toChannel.name()+"','"+toChannel.id()+"')");
  281.         else invoker.chat("Es ist ein Problem mit dem Bot aufgetreten, bitte leite dies an das Management weiter.");
  282.     }
  283.  
  284.     function getClickableName(client){
  285.         var name = client.name().replace('[', '%5C%5B').replace(']', '%5C%5D').replace(' ', '%20').replace('[', '%5C%5B').replace(']', '%5C%5D').replace(' ', '%20').replace('[', '%5C%5B').replace(']', '%5C%5D').replace(' ', '%20').replace('[', '%5C%5B').replace(']', '%5C%5D').replace(' ', '%20').replace('[', '%5C%5B').replace(']', '%5C%5D').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20').replace(' ', '%20');
  286.         name = "[URL=client://0/" + client.uid() + "~" + name + "]" + client.name() + "[/URL]";
  287.         return name;
  288.     }
  289.  
  290.     function getSupportMessage(client, channel){
  291.         return "[b][color=blue][Support][/color] " + getClickableName(client) + " benötigt Hilfe im [color=green]" + channel.name() + "[/color]![/b]";
  292.     }
  293.  
  294.     function sendGroupMessage(groupid, msg){
  295.         backend.getClients().forEach(function(client) {
  296.             client.getServerGroups().forEach(function(group) {
  297.                 if(group.id() == groupid && getToga(client) == 1 && !client.isDeaf() && (isInBlockedChannel(client) == 0 || getGamesupport(client) == 1))client.chat(msg);
  298.             });
  299.         });
  300.     }
  301.  
  302.     function getPermissions(client){
  303.         var perm = "";
  304.         if(client != null){
  305.             if(config.groups != null){
  306.                 client.getServerGroups().forEach(function(group) {
  307.                     config.groups.forEach(function(cgroup) {
  308.                         if(group.id() == cgroup.id){
  309.                             perm = cgroup.permissions;
  310.                         }
  311.                     });
  312.                 });
  313.             }
  314.  
  315.             if(config.users != null) {
  316.                 config.users.forEach(function (user) {
  317.                     if (user.uid == client.uid()) {
  318.                         if (perm == "") perm = user.permissions;
  319.                         else perm = perm + "," + user.permissions;
  320.                     }
  321.                 });
  322.             }
  323.         }
  324.  
  325.         return perm;
  326.     }
  327.  
  328.     function hasPermission(client, permission){
  329.         value = 0;
  330.         var perm = getPermissions(client);
  331.  
  332.         if(perm != "") {
  333.             permis = perm.split(",");
  334.             if(permis != null) {
  335.                 permis.forEach(function (per) {
  336.                     if (per == permission) value = 1;
  337.                 });
  338.             }
  339.         }
  340.  
  341.         return value;
  342.     }
  343.  
  344.     function isInBlockedChannel(client){
  345.         value = 0;
  346.  
  347.         if(config.blockedchannels != null){
  348.             config.blockedchannels.forEach(function(channel) {
  349.                 client.getChannels().forEach(function(chan) {
  350.                     if (channel.id == chan.id()) value = 1;
  351.                 });
  352.             });
  353.         }
  354.  
  355.         return value;
  356.     }
  357.  
  358.     function isABlockedChannel(channel){
  359.         value = 0;
  360.  
  361.         if(channel != null && config.blockedchannels != null){
  362.             config.blockedchannels.forEach(function(chan) {
  363.                 if (chan.id == channel.id()) value = 1;
  364.             });
  365.         }
  366.  
  367.         return value;
  368.     }
  369.  
  370.     function hasGroup(client, groupid){
  371.         var bool = 0;
  372.  
  373.         if(client != null){
  374.             client.getServerGroups().forEach(function(group) {
  375.                 if(group.id() == groupid)bool = 1;
  376.             });
  377.         }
  378.  
  379.         return bool;
  380.     }
  381.  
  382.     function callMenu(client){
  383.         var menu = getMenu(client);
  384.  
  385.         if(menu == -1){
  386.             resetMenu(client);
  387.         }
  388.         else if(config.autoSupports != null){
  389.             config.autoSupports.forEach(function(autoSup) {
  390.                 if(autoSup.supmenuid != null && autoSup.supmenuid == menu){
  391.                     if(autoSup.supchatmsg != "") client.chat(autoSup.supchatmsg);
  392.                     if(autoSup.supnewchannel != -1) client.moveTo(autoSup.supnewchannel);
  393.                 }
  394.             });
  395.         }
  396.     }
  397.    
  398.     function sendServerMessage(msg, poke){
  399.         backend.getClients().forEach(function(client) {
  400.             if(poke)client.poke(msg);
  401.             else client.chat(msg);
  402.         });
  403.     }
  404.    
  405.     function sendTeamMessage(msg, poke){
  406.         backend.getClients().forEach(function(client) {
  407.             if(isInAnyGroup(client) == 1){
  408.                 if(poke)client.poke(msg);
  409.                 else client.chat(msg);
  410.             }
  411.         });
  412.     }
  413.    
  414.     function sendOnlineInfo(client, username){
  415.         var bool = 0;
  416.         backend.getClients().forEach(function(user) {
  417.             if(user.description() == '('+username+') '){
  418.                 bool = 1;
  419.                 client.chat("[b][color=blue][Information][/color] Der Spieler "+getClickableName(user)+" ("+username+") befindet sich im [color=green]"+user.getChannels()[0].name()+"[/color][/b] ");
  420.             }
  421.         });
  422.         if(bool == 0){
  423.             client.chat("[b][color=blue][Information][/color] [color=red]Es ist kein Spieler mit dem Forumnamen ("+username+") online.[/color][/b] ");
  424.         }
  425.     }
  426.    
  427.  
  428.     function sendSecondChat(clientX){
  429.         backend.getChannels().forEach(function(channel){
  430.             if(isSupportUserChannel(channel) || isSupportGroupChannel(channel)) {
  431.  
  432.                 if (isSupportGroupChannel(channel) == 1) {
  433.                     channel.getClients().forEach(function (client) {
  434.                         value = ticketGet(client.uid());
  435.                         if (config.groups != null) {
  436.                             config.groups.forEach(function (group) {
  437.                                 if (group.channels != null && hasGroup(clientX, group.id) == 1) {
  438.                                     group.channels.forEach(function (cchannel) {
  439.                                         if (cchannel.id == channel.id() && cchannel.time <= value && getToga(clientX) == 1) clientX.chat(getSupportMessage(client, channel));
  440.                                     });
  441.                                 }
  442.                             });
  443.                         }
  444.                     });
  445.                 }
  446.  
  447.                 if (isSupportUserChannel(channel) == 1) {
  448.                     channel.getClients().forEach(function (client) {
  449.                         var value = ticketGet(client.uid());
  450.  
  451.                         if (config.users != null) {
  452.                             config.users.forEach(function (user) {
  453.                                 if (user.channels != null && user.uid == clientC.uid()) {
  454.                                     user.channels.forEach(function (cchannel) {
  455.                                        if (cchannel.id == channel.id() && cchannel.time <= value && getToga(clientX) == 1) clientX.chat(getSupportMessage(client, channel));
  456.                                     });
  457.                                 }
  458.                             });
  459.                         }
  460.                     });
  461.                 }
  462.             }
  463.         });
  464.     }
  465.  
  466.     setInterval(function() {
  467.         backend.getChannels().forEach(function(channel){
  468.             if(isSupportUserChannel(channel) || isSupportGroupChannel(channel)) {
  469.  
  470.                 if (isSupportGroupChannel(channel) == 1) {
  471.                     channel.getClients().forEach(function (client) {
  472.                         value = ticketAdd(client.uid());
  473.                         if (config.groups != null) {
  474.                             config.groups.forEach(function (group) {
  475.                                 if (group.channels != null) {
  476.                                     group.channels.forEach(function (cchannel) {
  477.                                         if (cchannel.id == channel.id() && cchannel.time == value) sendGroupMessage(group.id, getSupportMessage(client, channel));
  478.                                     });
  479.                                 }
  480.                             });
  481.                         }
  482.                     });
  483.                 }
  484.  
  485.                 if (isSupportUserChannel(channel) == 1) {
  486.                     var bool = isSupportGroupChannel(channel);
  487.                     channel.getClients().forEach(function (client) {
  488.                         var value = ticketGet(client.uid());
  489.                         if(bool == 0)value = ticketAdd(client.uid());
  490.  
  491.                         if (config.users != null) {
  492.                             config.users.forEach(function (user) {
  493.                                 if (user.channels != null) {
  494.                                     var sup = backend.getClientByUID(user.uid);
  495.                                     if(sup != null && getToga(sup) == 1 && !sup.isDeaf() && (isInBlockedChannel(sup) == 0 || getGamesupport(sup) == 1)) {
  496.                                         user.channels.forEach(function (cchannel) {
  497.                                             if (cchannel.id == channel.id() && cchannel.time == value) sup.chat(getSupportMessage(client, channel));
  498.                                         });
  499.                                     }
  500.                                 }
  501.                             });
  502.                         }
  503.                     });
  504.                 }
  505.             }
  506.         });
  507.     }, 60000);
  508.  
  509.     event.on('clientUndeaf', function(client) {
  510.         if(isInAnyGroup(client) == 1){
  511.             sendSecondChat(client);
  512.         }
  513.     });
  514.  
  515.     event.on('clientMove', function(ev) {
  516.         if(ev.invoker != null && isSupportLogChannel(ev.toChannel) == 1){
  517.             log(ev.fromChannel, ev.toChannel, ev.client, ev.invoker);
  518.         }
  519.  
  520.         if(isSupportGroupChannel(ev.toChannel) == 1 || isSupportUserChannel(ev.toChannel) == 1){
  521.            ticketReset(ev.client.uid());
  522.         }
  523.         else {
  524.             ticketUnset(ev.client.uid());
  525.         }
  526.  
  527.         if(isSupportInfoChannel(ev.toChannel) == 1){
  528.             if(config.infos != null){
  529.                 config.infos.forEach(function(info) {
  530.                     if(ev.toChannel.id() == info.id){
  531.                         if(info.type == 0)ev.client.poke(info.message);
  532.                         else if(info.type == 1)ev.client.chat(info.message);
  533.                     }
  534.                 });
  535.             }
  536.         }
  537.  
  538.         if(ev.fromChannel == null || isABlockedChannel(ev.fromChannel) == 1){
  539.             if(isInAnyGroup(ev.client)){
  540.                 if(ev.toChannel != null && isABlockedChannel(ev.toChannel) == 0){
  541.                     sendSecondChat(ev.client);
  542.                 }
  543.             }
  544.         }
  545.  
  546.         if(ev.toChannel != null && ev.toChannel.id() == config.supportWarteraum){
  547.             setMenu(ev.client, 1);
  548.             callMenu(ev.client);
  549.         }
  550.         else {
  551.             resetMenu(ev.client);
  552.         }
  553.     });
  554.  
  555.     event.on('chat', function(ev) {
  556.         if (!ev.client.isSelf()) {
  557.             var vars = ev.text.split(" ");
  558.             var cmd = vars[0];
  559.             var cmdmsg = "";
  560.             for(var i = 1; i < vars.length; i++){
  561.                 if(i != 1) cmdmsg += " ";
  562.                 cmdmsg += vars[i];
  563.             }
  564.  
  565.             if(ev.text == '!toga'){
  566.                 if(isInAnyGroup(ev.client) == 1){
  567.                     var value = toggleToga(ev.client);
  568.                     if(value == 0)ev.client.chat("[b][color=blue][Einstellungen][/color] Informationen: [color=red]deaktiviert[/color][/b]");
  569.                     else if(value == 1)ev.client.chat("[b][color=blue][Einstellungen][/color] Informationen: [color=green]aktiviert[/color][/b]");
  570.                 }
  571.             }
  572.             else if(ev.text == '!gamesupport'){
  573.                 if(isInAnyGroup(ev.client) == 1){
  574.                     var value = toggleGamesupport(ev.client);
  575.                     if(value == 0)ev.client.chat("[b][color=blue][Einstellungen][/color] GameSupport: [color=red]deaktiviert[/color][/b]");
  576.                     else if(value == 1)ev.client.chat("[b][color=blue][Einstellungen][/color] GameSupport: [color=green]aktiviert[/color][/b]");
  577.                 }
  578.             }
  579.             else if(ev.text == '!reload'){
  580.                 if(isInAnyGroup(ev.client) == 1){
  581.                     if(hasPermission(ev.client, "Reload")) {
  582.                         engine.reloadScripts();
  583.                         ev.client.chat("[b][color=blue][Info][/color] Du hast das Script [color=red]neugestartet[/color]![/b]");
  584.                     }
  585.                 }
  586.             }
  587.             else if(ev.text == '!getkeys'){
  588.                 if(isInAnyGroup(ev.client) == 1){
  589.                     if(hasPermission(ev.client, "Getkeys")) {
  590.                         var permissi = getPermissions(ev.client);
  591.                         if(permissi != ""){
  592.                             var permissions = permissi.split(",");
  593.                             var groups = "";
  594.                             permissions.forEach(function(permission) {
  595.                                 if(permission != null)groups = groups + ",'" + permission + "' ";
  596.                             });
  597.                             groups = "(" + groups.replace(",","") + ")";
  598.                             var sql = "SELECT * FROM view_infolog WHERE lastGroup IN " + groups + " ORDER BY lastDate DESC";
  599.  
  600.                             var permsk = hasPermission(ev.client, "GetAllKeys");
  601.                             if(permsk == 0)ev.client.chat("[b][color=blue][Info][/color] [color=red]last24h[/color] - [color=red]last7d[/color] - [color=green]Name[/color] - [color=purple]Gruppe[/color] - [color=gray]uid[/color][/b]");
  602.                             else ev.client.chat("[b][color=blue][Info][/color] [color=gray]lastDate[/color] - [color=red]last24h[/color] - [color=red]last7d[/color] - [color=red]lastMonth[/color] - [color=red]total[/color] - [color=green]Name[/color] - [color=purple]Gruppe[/color] - [color=gray]uid[/color][/b]");
  603.                             if (dbc) dbc.query(sql, function(err, res) {
  604.                                 if (!err) {
  605.                                     res.forEach(function(row) {
  606.                                         if(permsk == 0)ev.client.chat("[b][color=blue][Info][/color]  [color=red]" + helpers.toString(row.last24h) + "[/color] - [color=red]" + helpers.toString(row.last7d) + "[/color] - [color=green]" + helpers.toString(row.lastName) + "[/color] - [color=purple]" + helpers.toString(row.lastGroup) + "[/color] - [color=gray]" + helpers.toString(row.supporterUid) + "[/color][/b]");
  607.                                         else ev.client.chat("[b][color=blue][Info][/color]  [color=gray]" + helpers.toString(row.lastDate) + "[/color] - [color=red]" + helpers.toString(row.last24h) + "[/color] - [color=red]" + helpers.toString(row.last7d) + "[/color] - [color=red]" + helpers.toString(row.lastMonth) + "[/color] - [color=red]" + helpers.toString(row.total) + "[/color] - [color=green]" + helpers.toString(row.lastName) + "[/color] - [color=purple]" + helpers.toString(row.lastGroup) + "[/color] - [color=gray]" + helpers.toString(row.supporterUid) + "[/color][/b]");
  608.                                     });
  609.                                 }
  610.                             });
  611.                         }
  612.                     }
  613.                 }
  614.             }
  615.             else if(ev.text == '!resetoptions'){
  616.                 if(isInAnyGroup(ev.client) == 1){
  617.                     if(hasPermission(ev.client, "ResetOptions")) {
  618.                         store.getKeys().forEach(function(key) {
  619.                             store.unset(key);
  620.                         });
  621.                         ev.client.chat("[b][color=blue][Info][/color] Du hast alle Client-Einstellungen [color=red]zurückgesetzt[/color]![/b]");
  622.                     }
  623.                 }
  624.             }
  625.             else if(ev.text == '!help'){
  626.                 if(isInAnyGroup(ev.client) == 1){
  627.                     ev.client.chat("!help - zeigt diese List an");
  628.                     ev.client.chat("!toga - (de)aktiviert die Supportnachrichten");
  629.                     ev.client.chat("!gamesupport - (de)aktiviert die Supportnachrichten wenn man im Spiel ist. (Standartmäßig deaktiviert)");
  630.                     ev.client.chat("!getuser [Forumname] - Gibt den Spieler zurück, wenn er sich auf dem Teamspeak befindet");
  631.                     if(hasPermission(ev.client, "Getkeys")) {
  632.                         ev.client.chat("!getkeys - zeigt eine Liste der letzten Supporttätigkeiten eines Teammitgliedes");
  633.                     }
  634.                     if(hasPermission(ev.client, "Reload")) {
  635.                         ev.client.chat("!reload - lädt das Script neu (Notwendig, falls Beispielsweise keine Verbindung zur Datenbank besteht)");
  636.                     }
  637.                     if(hasPermission(ev.client, "ResetOptions")) {
  638.                         ev.client.chat("!resetoptions - schaltet bei allen Teammitgliedern wieder die Support-Benachrichtigungen an");
  639.                     }
  640.                     if(hasPermission(ev.client, "serverinfochat")) {
  641.                         ev.client.chat("!serverinfochat [Nachricht] - Schreibt alle Spieler auf den Server privat mit der [Nachricht] an");
  642.                     }
  643.                     if(hasPermission(ev.client, "serverinfopoke")) {
  644.                         ev.client.chat("!serverinfopoke [Nachricht] - Stubst alle Spieler auf den Server mit der [Nachricht] an");
  645.                     }
  646.                     if(hasPermission(ev.client, "teaminfochat")) {
  647.                         ev.client.chat("!teaminfochat [Nachricht] - Schreibt alle Teammitglieder auf den Server privat mit der [Nachricht] an");
  648.                     }
  649.                     if(hasPermission(ev.client, "teaminfopoke")) {
  650.                         ev.client.chat("!teaminfopoke [Nachricht] - Stubst alle Teammitglieder auf den Server mit der [Nachricht] an");
  651.                     }
  652.                 }
  653.             }
  654.             else if(cmd == "!serverinfochat"){
  655.                 if(isInAnyGroup(ev.client) == 1){
  656.                     if(hasPermission(ev.client, "serverinfochat")) {
  657.                         sendServerMessage(cmdmsg, false);
  658.                     }
  659.                 }
  660.             }
  661.             else if(cmd == "!serverinfopoke"){
  662.                 if(isInAnyGroup(ev.client) == 1){
  663.                     if(hasPermission(ev.client, "serverinfopoke")) {
  664.                         sendServerMessage(cmdmsg, true);
  665.                     }
  666.                 }
  667.             }
  668.             else if(cmd == "!teaminfochat"){
  669.                 if(isInAnyGroup(ev.client) == 1){
  670.                     if(hasPermission(ev.client, "teaminfochat")) {
  671.                         sendTeamMessage(cmdmsg, false);
  672.                     }
  673.                 }
  674.             }
  675.             else if(cmd == "!teaminfopoke"){
  676.                 if(isInAnyGroup(ev.client) == 1){
  677.                     if(hasPermission(ev.client, "teaminfopoke")) {
  678.                         sendTeamMessage(cmdmsg, true);
  679.                     }
  680.                 }
  681.             }
  682.             else if(cmd == "!getuser"){
  683.                 if(isInAnyGroup(ev.client) == 1){
  684.                     sendOnlineInfo(ev.client, cmdmsg);
  685.                 }
  686.             }
  687.             else {
  688.                 ev.client.getChannels().forEach(function (channel) {
  689.                     if (channel.id() == config.supportWarteraum) {
  690.                         var chatid = getMenu(ev.client);
  691.  
  692.                         if (config.autoSupports != null) {
  693.                             config.autoSupports.forEach(function (autoSup) {
  694.                                 if (chatid == autoSup.supmenuid) {
  695.                                     var bool = 0;
  696.                                     if(autoSup.awnsers != null){
  697.                                         autoSup.awnsers.forEach(function(awnser) {
  698.                                             if(awnser.value == ev.text){
  699.                                                 setMenu(ev.client, awnser.newmenuid);
  700.                                                 callMenu(ev.client);
  701.                                                 bool = 1;
  702.                                             }
  703.                                         });
  704.                                     }
  705.                                     if(bool == 0){
  706.                                         ev.client.chat("[b][color=darkred]Ungültige Eingabe![/color] Als Antwort wird eine Zahl erwartet![/b]");
  707.                                     }
  708.                                 }
  709.                             });
  710.                         }
  711.                     }
  712.                 });
  713.             }
  714.         }
  715.     });
  716. });
  717.  
  718. /*
  719.     ** VIEW INFOLOG **
  720.  
  721.    SELECT
  722.    (SELECT datum FROM log WHERE supporterUid = A1.supporterUid ORDER BY datum DESC LIMIT 1) AS lastDate,
  723.    (SELECT supporterName FROM log WHERE supporterUid = A1.supporterUid ORDER BY datum DESC LIMIT 1) AS lastName,
  724.    (SELECT configGroup FROM log WHERE supporterUid = A1.supporterUid ORDER BY datum DESC LIMIT 1) AS lastGroup,
  725.    (SELECT Count(*) FROM log WHERE supporterUid = A1.supporterUid AND TIMEDIFF(current_timestamp, datum) <= 240000 ORDER BY datum DESC LIMIT 1) AS last24h,
  726.    (SELECT Count(*) FROM log WHERE supporterUid = A1.supporterUid AND DATEDIFF(current_timestamp, datum) <= 7 ORDER BY datum DESC LIMIT 1) AS last7d,
  727.    (SELECT Count(*) FROM log WHERE supporterUid = A1.supporterUid AND DATEDIFF(current_timestamp, datum) <= 30 ORDER BY datum DESC LIMIT 1) AS lastMonth,
  728.    Count(*) AS total,
  729.    supporterUid
  730.    FROM `log` A1 WHERE 1 GROUP BY supporterUid ORDER BY datum DESC
  731.  
  732.  
  733.    ** VIEW GROUPINFO **
  734.  
  735.    SELECT
  736.      configGroup,
  737.      ROUND(100/(SELECT Count(*) FROM log WHERE TIMEDIFF(current_timestamp, datum) <= 240000)*(SELECT Count(*) FROM log WHERE TIMEDIFF(current_timestamp, datum) <= 240000 AND configGroup = A1.configGroup), 1) AS last24hProzent,
  738.      (SELECT Count(*) FROM log WHERE TIMEDIFF(current_timestamp, datum) <= 240000 AND configGroup = A1.configGroup) AS last24hCount,
  739.      (SELECT Count(*) FROM log WHERE TIMEDIFF(current_timestamp, datum) <= 240000) AS last24hCountAll,
  740.      ROUND(100/(SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 7)*(SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 7 AND configGroup = A1.configGroup), 1) AS last7dProzent,
  741.      (SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 7 AND configGroup = A1.configGroup) AS last7dCount,
  742.      (SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 7) AS last7dCountAll,
  743.      ROUND(100/(SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 30)*(SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 30 AND configGroup = A1.configGroup), 1) AS last30dProzent,
  744.      (SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 30 AND configGroup = A1.configGroup) AS last30dCount,
  745.      (SELECT Count(*) FROM log WHERE DATEDIFF(current_timestamp, datum) <= 30) AS last30dCountAll,
  746.      ROUND(100/(SELECT Count(*) FROM log)*Count(*), 1) AS totalProzent,
  747.      Count(*) AS totalCount,
  748.      (SELECT Count(*) FROM log) AS totalCountAll
  749.    FROM log A1 GROUP BY configGroup
  750.  
  751.  
  752.    ** VIEW GROUPCHANNELINFO **
  753.  
  754.    SELECT
  755.      fromChannelName,
  756.      configGroup,
  757.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000),1) AS last24hProzent,
  758.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000) AS last24hCount,
  759.      (SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000) AS last24hCountAll,
  760.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7),1) AS last7dProzent,
  761.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7) AS last7dCount,
  762.      (SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7) AS last7dCountAll,
  763.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30),1) AS last30dProzent,
  764.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30) AS last30dCount,
  765.      (SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30) AS last30dCountAll,
  766.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId)*Count(*),1) AS totalProzent,
  767.      Count(*) AS totalCount,
  768.      (SELECT Count(*) FROM log WHERE fromChannelId = A1.fromChannelId) AS totalCountAll
  769.  
  770.    FROM log A1 WHERE fromChannelId IN ('1387','1389','1386','1390','1991') GROUP BY configGroup,fromChannelId ORDER BY fromChannelName, configGroup
  771.  
  772.  
  773.  
  774.    ** VIEW USERCHANNELINFO **
  775.  
  776.    SELECT
  777.      supporterName,
  778.      configGroup,
  779.      fromChannelName,
  780.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000 AND supporterUid = A1.supporterUid)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000 AND supporterUid = A1.supporterUid),1) AS last24hProzent,
  781.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000 AND supporterUid = A1.supporterUid) AS last24hCount,
  782.      (SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND A1.fromChannelId AND TIMEDIFF(current_timestamp, datum) <= 240000 AND supporterUid = A1.supporterUid) AS last24hCountAll,
  783.  
  784.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND DATEDIFF(current_timestamp, datum) <= 7 AND supporterUid = A1.supporterUid)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7 AND supporterUid = A1.supporterUid),1) AS last7dProzent,
  785.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 7 AND supporterUid = A1.supporterUid) AS last7dCount,
  786.      (SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND DATEDIFF(current_timestamp, datum) <= 7 AND supporterUid = A1.supporterUid) AS last7dCountAll,
  787.  
  788.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND DATEDIFF(current_timestamp, datum) <= 30 AND supporterUid = A1.supporterUid)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30 AND supporterUid = A1.supporterUid),1) AS last30dProzent,
  789.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND DATEDIFF(current_timestamp, datum) <= 30 AND supporterUid = A1.supporterUid) AS last30dCount,
  790.      (SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND DATEDIFF(current_timestamp, datum) <= 30 AND supporterUid = A1.supporterUid) AS last30dCountAll,
  791.  
  792.      ROUND(100/(SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND supporterUid = A1.supporterUid)*(SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND supporterUid = A1.supporterUid),1) AS totalProzent,
  793.      (SELECT Count(*) FROM log WHERE configGroup = A1.configGroup AND fromChannelId = A1.fromChannelId AND supporterUid = A1.supporterUid) AS totalCount,
  794.      (SELECT Count(*) FROM log WHERE fromChannelId IN ('1387','1389','1386','1390','1991') AND supporterUid = A1.supporterUid) AS totalCountAll
  795.  
  796.    FROM log A1 WHERE fromChannelId IN ('1387','1389','1386','1390','1991') GROUP BY supporterUid,fromChannelId ORDER BY supporterUid,last24hProzent DESC
  797.  
  798.  
  799. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement