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