-
Notifications
You must be signed in to change notification settings - Fork 109
/
scripts.js
2566 lines (2362 loc) · 107 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This is the official Pokemon Online Scripts
// These scripts will only work on 2.0.00 or newer.
/*jshint laxbreak:true,shadow:true,undef:true,evil:true,trailing:true,proto:true,withstmt:true*/
// You may change these variables as long as you keep the same type
var Config = {
base_url: "https://raw.githubusercontent.com/po-devs/po-server-goodies/master/",
dataDir: "scriptdata/",
bot: "Dratini",
kickbot: "Blaziken",
capsbot: "Exploud",
channelbot: "Chatot",
checkbot: "Snorlax",
coinbot: "Meowth",
countbot: "CountBot",
tourneybot: "Typhlosion",
rankingbot: "Porygon",
battlebot: "Blastoise",
commandbot: "CommandBot",
querybot: "QueryBot",
hangbot: "Unown",
bfbot: "Goomy",
safaribot: "Tauros",
teamsbot: "Minun",
// suspectvoting.js available, but not in use
Plugins: ["mafia.js", "amoebagame.js", "tourstats.js", "trivia.js", "tours.js", "newtourstats.js", "auto_smute.js", "battlefactory.js", "hangman.js", "blackjack.js", "mafiastats.js", "mafiachecker.js", "safari.js", "youtube.js", "autoteams.js"],
Mafia: {
bot: "Murkrow",
norepeat: 5,
stats_file: "scriptdata/mafia_stats.json",
max_name_length: 16,
notPlayingMsg: "±Game: A game is in progress. Please type /join to join the next mafia game."
},
DreamWorldTiers: ["All Gen Hackmons", "ORAS Hackmons", "ORAS Balanced Hackmons", "No Preview OU", "No Preview Ubers", "DW LC", "DW UU", "DW LU", "Gen 5 1v1 Ubers", "Gen 5 1v1", "Challenge Cup", "CC 1v1", "DW Uber Triples", "No Preview OU Triples", "No Preview Uber Doubles", "No Preview OU Doubles", "Shanai Cup", "Shanai Cup 1.5", "Shanai Cup STAT", "Original Shanai Cup TEST", "Monocolour", "Clear Skies DW"],
canJoinStaffChannel: [],
disallowStaffChannel: [],
topic_delimiter: " | ",
registeredLimit: 30
};
// Don't touch anything here if you don't know what you do.
/*global print, script, sys, SESSION*/
var require_cache = typeof require != 'undefined' ? require.cache : {};
require = function require(module_name, retry) {
if (require.cache[module_name])
return require.cache[module_name];
var module = {};
module.module = module;
module.exports = {};
module.source = module_name;
with (module) {
var content = sys.getFileContent("scripts/"+module_name);
if (content) {
try {
eval(sys.getFileContent("scripts/"+module_name));
sys.writeToFile("scripts/" + module_name + "-b", sys.getFileContent("scripts/" + module_name));
} catch(e) {
if (staffchannel)
sys.sendAll("Error loading module " + module_name + ": " + e + (e.lineNumber ? " on line: " + e.lineNumber : ""), staffchannel);
else
sys.sendAll("Error loading module " + module_name + ": " + e);
sys.writeToFile("scripts/"+module_name, sys.getFileContent("scripts/" + module_name + "-b"));
if (!retry) {
require(module_name, true); //prevent loops
}
}
}
}
require.cache[module_name] = module.exports;
return module.exports;
};
require.cache = require_cache;
var updateModule = function updateModule(module_name, callback) {
var base_url = Config.base_url;
var url;
if (/^https?:\/\//.test(module_name))
url = module_name;
else
url = base_url + "scripts/"+ module_name;
url += "?" + new Date().getTime();
var fname = module_name.split(/\//).pop();
if (!callback) {
var resp = sys.synchronousWebCall(url);
if (resp === "") return {};
sys.writeToFile("scripts/"+fname, resp);
delete require.cache[fname];
var module = require(fname);
return module;
} else {
sys.webCall(url, function updateModule_callback(resp) {
if (resp === "") return;
sys.writeToFile("scripts/"+fname, resp);
delete require.cache[fname];
var module = require(fname);
callback(module);
});
}
};
var channel, contributors, mutes, mbans, safbans, smutes, detained, hmutes, mafiaSuperAdmins, hangmanAdmins, hangmanSuperAdmins, staffchannel, channelbot, normalbot, bot, mafiabot, kickbot, capsbot, checkbot, coinbot, countbot, tourneybot, battlebot, commandbot, querybot, rankingbot, hangbot, bfbot, scriptChecks, lastMemUpdate, bannedUrls, mafiachan, sachannel, tourchannel, rangebans, proxy_ips, mafiaAdmins, authStats, nameBans, chanNameBans, isSuperAdmin, cmp, key, battlesStopped, lineCount, maxPlayersOnline, pastebin_api_key, pastebin_user_key, getSeconds, getTimeString, sendChanMessage, sendChanAll, sendMainTour, VarsCreated, authChangingTeam, usingBannedWords, repeatingOneself, capsName, CAPSLOCKDAYALLOW, nameWarns, poScript, revchan, triviachan, watchchannel, lcmoves, hangmanchan, ipbans, battlesFought, lastCleared, blackjackchan, namesToWatch, allowedRangeNames, reverseTohjo, safaribot, safarichan, tourconfig, teamsbot, autoteamsAuth;
var pokeDir = "db/pokes/";
var moveDir = "db/moves/7G/";
var abilityDir = "db/abilities/";
var itemDir = "db/items/";
sys.makeDir("scripts");
/* we need to make sure the scripts exist */
var commandfiles = ['commands.js', 'channelcommands.js','ownercommands.js', 'modcommands.js', 'usercommands.js', "admincommands.js"];
var deps = ['crc32.js', 'utilities.js', 'bot.js', 'memoryhash.js', 'tierchecks.js', "globalfunctions.js", "userfunctions.js", "channelfunctions.js", "channelmanager.js", "pokedex.js"].concat(commandfiles).concat(Config.Plugins);
var missing = 0;
for (var i = 0; i < deps.length; ++i) {
if (!sys.getFileContent("scripts/"+deps[i])) {
if (missing++ === 0) sys.sendAll('Server is updating its script modules, it might take a while...');
var module = updateModule(deps[i]);
module.source = deps[i];
}
}
if (missing) sys.sendAll('Done. Updated ' + missing + ' modules.');
/* To avoid a load of warning for new users of the script,
create all the files that will be read further on*/
var cleanFile = function(filename) {
if (typeof sys != 'undefined')
sys.appendToFile(filename, "");
};
[Config.dataDir+"mafia_stats.json", Config.dataDir+"suspectvoting.json", Config.dataDir+"mafiathemes/metadata.json", Config.dataDir+"channelData.json", Config.dataDir+"mutes.txt", Config.dataDir+"mbans.txt", Config.dataDir+"mwarns.json", Config.dataDir+"safbans.txt", Config.dataDir+"hmutes.txt", Config.dataDir+"smutes.txt", Config.dataDir+"rangebans.txt", Config.dataDir+"contributors.txt", Config.dataDir+"ipbans.txt", Config.dataDir+"namesToWatch.txt", Config.dataDir+"watchNamesLog.txt", Config.dataDir+"hangmanadmins.txt", Config.dataDir+"hangmansuperadmins.txt", Config.dataDir+"pastebin_user_key", Config.dataDir+"secretsmute.txt", Config.dataDir+"ipApi.txt", Config.dataDir + "notice.html", Config.dataDir + "rangewhitelist.txt", Config.dataDir + "idbans.txt", Config.dataDir+"league.json", Config.dataDir + "autoteamsauth.txt"].forEach(cleanFile);
var autosmute = sys.getFileContent(Config.dataDir+"secretsmute.txt").split(':::');
var crc32 = require('crc32.js').crc32;
var MemoryHash = require('memoryhash.js').MemoryHash;
var POChannelManager = require('channelmanager.js').POChannelManager;
var POChannel = require('channelfunctions.js').POChannel;
var POUser = require('userfunctions.js').POUser;
var POGlobal = require('globalfunctions.js').POGlobal;
delete require.cache['tierchecks.js'];
var tier_checker = require('tierchecks.js');
delete require.cache['pokedex.js'];
var pokedex = require('pokedex.js');
// declare prototypes
Object.defineProperty(Array.prototype, "contains", {
configurable: true,
enumerable: false,
value: function (value) {
return this.indexOf(value) > -1;
}
});
Object.defineProperty(Array.prototype, "random", {
configurable: true,
enumerable: false,
value: function () {
return this[sys.rand(0, this.length)];
}
});
Object.defineProperty(Array.prototype, "shuffle", {
configurable: true,
enumerable: false,
value: function () {
for (var i = this.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = this[i];
this[i] = this[j];
this[j] = temp;
}
return this;
}
});
/* stolen from here: http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format */
String.prototype.format = function() {
var formatted = this;
for (var i = 0; i < arguments.length; i++) {
var regexp = new RegExp('\\{'+i+'\\}', 'gi');
formatted = formatted.replace(regexp, arguments[i]);
}
return formatted;
};
String.prototype.htmlEscape = function () {
return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
};
String.prototype.htmlStrip = function () {
return this.replace(/(<([^>]+)>)/gi, "");
};
String.prototype.toCorrectCase = function() {
if (isNaN(this) && sys.id(this) !== undefined) {
return sys.name(sys.id(this));
} else {
return this;
}
};
var utilities = require('utilities.js');
var isNonNegative = utilities.is_non_negative;
var Lazy = utilities.Lazy;
var nonFlashing = utilities.non_flashing;
var getSeconds = utilities.getSeconds;
var getTimeString = utilities.getTimeString;
var is_command = utilities.is_command;
var commands = require('commands.js');
/* Useful for evalp purposes */
function printObject(o) {
var out = '';
for (var p in o) {
if (o.hasOwnProperty(p)) {
out += p + ': ' + o[p] + '\n';
}
}
sys.sendAll(out);
}
/* Functions using the implicit variable 'channel' set on various events */
// TODO: remove the possibility for implictit channel
// TODO: REMOVE THESE FUNCTIONS THAT LIKE BREAKING AT RANDOM TIMES
function sendChanMessage(id, message, channel) {
sys.sendMessage(id, message, channel);
}
function sendChanAll(message, chan_id, channel) {
if((chan_id === undefined && channel === undefined) || chan_id == -1)
{
sys.sendAll(message);
} else if(chan_id === undefined && channel !== undefined)
{
sys.sendAll(message, channel);
} else if(chan_id !== undefined)
{
sys.sendAll(message, chan_id);
}
}
function sendChanHtmlMessage(id, message) {
sys.sendHtmlMessage(id, message, channel);
}
function sendChanHtmlAll(message, chan_id) {
if((chan_id === undefined && channel === undefined) || chan_id == -1)
{
sys.sendHtmlAll(message);
} else if(chan_id === undefined && channel !== undefined)
{
sys.sendHtmlAll(message, channel);
} else if(chan_id !== undefined)
{
sys.sendHtmlAll(message, chan_id);
}
}
/*function updateNotice(silent) {
var url = Config.base_url + "notice.html";
sys.webCall(url, function (resp){
sys.writeToFile(Config.dataDir + "notice.html", resp);
});
sendNotice(silent);
}*/
function sendNotice(silent) {
var notice = sys.getFileContent(Config.dataDir + "notice.html");
if (notice && !silent) {
["Tohjo Falls", "Trivia", "Tournaments", "Indigo Plateau", "Victory Road", "Mafia", "Hangman", "Safari"].forEach(function(c) {
sys.sendHtmlAll(notice, sys.channelId(c));
});
}
}
function isAndroid(id) {
if (sys.os) {
return sys.os(id) === "android";
} else {
return sys.info(id) === "Android player." && sys.avatar(id) === 72;
}
}
function clearTeamFiles() {
var files = sys.filesForDirectory("usage_stats/formatted/team");
for (var x = 0; x < files.length; x++) {
var time = files[x].split("-")[0];
if (sys.time() - time > 86400) {
sys.deleteFile("usage_stats/formatted/team/" + files[x]);
}
}
}
var POKEMON_CLEFFA = typeof sys != 'undefined' ? sys.pokeNum("Cleffa") : 173;
function callplugins() {
return SESSION.global().callplugins.apply(SESSION.global(), arguments);
}
function getplugins() {
return SESSION.global().getplugins.apply(SESSION.global(), arguments);
}
SESSION.identifyScriptAs("PO Scripts v0.991");
SESSION.registerChannelFactory(POChannel);
SESSION.registerUserFactory(POUser);
SESSION.registerGlobalFactory(POGlobal);
if (typeof SESSION.global() != 'undefined') {
SESSION.global().channelManager = new POChannelManager('scriptdata/channelHash.txt');
SESSION.global().__proto__ = POGlobal.prototype;
var plugin_files = Config.Plugins;
var plugins = [];
for (var i = 0; i < plugin_files.length; ++i) {
var plugin = require(plugin_files[i]);
plugin.source = plugin_files[i];
plugins.push(plugin);
}
SESSION.global().plugins = plugins;
// uncomment to update either Channel or User
sys.channelIds().forEach(function(id) {
if (!SESSION.channels(id))
sys.sendAll("ScriptUpdate: SESSION storage broken for channel: " + sys.channel(id), staffchannel);
else
SESSION.channels(id).__proto__ = POChannel.prototype;
});
sys.playerIds().forEach(function(id) {
if (sys.loggedIn(id)) {
var user = SESSION.users(id);
if (!user) {
sys.sendAll("ScriptUpdate: SESSION storage broken for user: " + sys.name(id), staffchannel);
} else {
user.__proto__ = POUser.prototype;
user.battles = user.battles || {};
}
}
});
}
// Bot.js binds the global variable 'channel' so we cannot re-use it
// since the binding will to the old variable.
delete require.cache['bot.js'];
var Bot = require('bot.js').Bot;
normalbot = bot = new Bot(Config.bot);
mafiabot = new Bot(Config.Mafia.bot);
channelbot = new Bot(Config.channelbot);
kickbot = new Bot(Config.kickbot);
capsbot = new Bot(Config.capsbot);
checkbot = new Bot(Config.checkbot);
coinbot = new Bot(Config.coinbot);
countbot = new Bot(Config.countbot);
tourneybot = new Bot(Config.tourneybot);
rankingbot = new Bot(Config.rankingbot);
battlebot = new Bot(Config.battlebot);
commandbot = new Bot(Config.commandbot);
querybot = new Bot(Config.querybot);
hangbot = new Bot(Config.hangbot);
bfbot = new Bot(Config.bfbot);
safaribot = new Bot(Config.safaribot);
teamsbot = new Bot(Config.teamsbot);
/* Start script-object
*
* All the events are defined here
*/
var lastStatUpdate = new Date();
poScript=({
/* Executed every second */
step: function() {
if (typeof callplugins == "function") callplugins("stepEvent");
var date = new Date();
if (date.getUTCMinutes() === 10 && date.getUTCSeconds() === 0 && sys.os() !== "windows") {
/*sys.get_output("nc -z server.pokemon-online.eu 10508", function callback(exit_code) {
if (exit_code !== 0) {
sys.sendAll("±NetCat: Cannot reach Webclient Proxy - it may be down.", sys.channelId("Indigo Plateau"));
}
}, function errback(error) {
sys.sendAll("±NetCat: Cannot reach Webclient Proxy - it may be down: " + error, sys.channelId("Indigo Plateau"));
});*/
clearTeamFiles();
}
if (date.getUTCHours() % 3 === 0 && date.getUTCMinutes() === 0 && date.getUTCSeconds() === 0) {
//sendNotice();
}
if (date.getUTCHours() % 1 === 0 && date.getUTCMinutes() === 0 && date.getUTCSeconds() === 0) {
print("CURRENT SERVER TIME: " + date.toUTCString()); //helps when looking through logs
}
// Reset stats monthly
var JSONP_FILE = "usage_stats/formatted/stats.jsonp";
if (lastCleared != date.getUTCMonth()) {
lastCleared = date.getUTCMonth();
battlesFought = 0;
sys.saveVal("Stats/BattlesFought", 0);
sys.saveVal("Stats/LastCleared", lastCleared);
sys.saveVal("Stats/MafiaGamesPlayed", 0);
sys.saveVal("Stats/TriviaGamesPlayed", 0);
sys.saveVal("Stats/HangmanGamesPlayed", 0);
}
if (date - lastStatUpdate > 60) {
lastStatUpdate = date;
// QtScript is able to JSON.stringify dates
var stats = {
lastUpdate: date,
usercount: sys.playerIds().filter(sys.loggedIn).length,
battlesFought: battlesFought,
mafiaPlayed: +sys.getVal("Stats/MafiaGamesPlayed"),
triviaPlayed: +sys.getVal("Stats/TriviaGamesPlayed"),
hangmanPlayed: + sys.getVal("Stats/HangmanGamesPlayed")
};
sys.writeToFile(JSONP_FILE, "setServerStats(" + JSON.stringify(stats) + ");");
}
var banlists = {
"mute": {"list": script.mutes, "term": "mute", "bot": normalbot},
"smute": {"list": script.smutes, "term": "smute", "bot": normalbot},
"mban": {"list": script.mbans, "term": "Mafia ban", "bot": mafiabot},
"hmute": {"list": script.hmutes, "term": "Hangman ban", "bot": hangbot},
"safban": {"list": script.safbans, "term": "Safari ban", "bot": safaribot}
};
for (var p in banlists) {
var hash = banlists[p].list.hash,
term = banlists[p].term,
usebot = banlists[p].bot;
for (var ip in hash) {
var split = hash[ip].split(":"),
by = split[1],
expires = split[2],
name = split[3],
reason = split[4];
if (expires > 0 && sys.time() > expires) {
sys.playerIds().forEach(function(id) {
if (sys.loggedIn(id) && ip === sys.ip(id)) {
SESSION.users(id).un(p);
if (p !== "smute") {
usebot.sendMessage(id, "Your " + term + " has expired.");
}
}
});
if (ip in hash) { // no online user with matching ip
banlists[p].list.remove(ip);
}
var msg = nonFlashing(name) + "'s " + term + " has expired. [IP: " + ip.replace("::ffff:", "") + ", By: " + nonFlashing(by) + ", Reason: " + reason + "]";
usebot.sendAll(msg, watchchannel);
if (["mban", "hmute", "safban"].contains(p)) {
usebot.sendAll(msg, sachannel);
}
else if (p !== "smute") {
usebot.sendAll(msg, staffchannel);
}
}
}
}
},
serverStartUp : function() {
SESSION.global().startUpTime = +sys.time();
scriptChecks = 0;
this.init();
},
init : function() {
script.superAdmins = ["Mahnmut", "Atli", "E.T."];
script.rules = {
"1": {
"english": [
"1. Pokémon Online is an international server:",
"- All cultures and languages are allowed on Pokémon Online and should be treated with respect."
],
"spanish": [
"1. Pokémon Online es un servidor internacional:",
"- Todas las culturas e idiomas son permitidos en Pokémon Online, y como tales, deben ser respetados."
],
"chinese": [
"1. PO官服是一个国际服务器:",
"- PO欢迎来自世界各地的语言文化,请所有用户尊重这些不同的语言文化。"
],
"french": [
"1. Pokémon Online est un serveur international:",
"- Toutes les cultures et les langues sont permises sur Pokémon Online et doivent être respectées."
]
},
"2": {
"english": [
"2. Do not disrupt the chat:",
"- Advertising (including social media accounts), spamming, using all-caps, and flooding disrupt the flow of the chat and are not allowed. Use the \"Find Battle\" option or join a tournament instead of repeatedly asking for battles in the chat."
],
"spanish": [
"2. No quebrantar el chat:",
"- La publicidad (incluyendo cuentas de redes sociales), spamming, teclear todo en mayúsculas, flooding (o sea, escribir una oración en múltiples líneas en lugar de una sola), quebrantan y/o desorganizan la fluidez normal del chat y por tanto no son permitidos. Utiliza el botón de \"Buscar Batalla\" o inscríbete a un torneo en lugar de pedir batallas repetidamente en el chat."
],
"chinese": [
"2. 不要扰乱聊天秩序:",
"- 聊天室不允许任何形式的广告或社交账号(微博/ Facebook/QQ群号/其他PO服务器的地址 ), 冗余信息,无意义的刷屏和无休止的抱怨。测试网络请用单个小写字母t,希望和他人对战请用 \"寻找对战\"按钮 或者加入 #tournaments 的比赛,而不是在聊天室内约战。"
],
"french": [
"2. Ne perturbez pas la discussion:",
"- La publicité (inclus les comptes de réseaux sociaux), le spam, l'abus de majuscules, le flood qui perturbe le cours de la discussion ne sont pas permis. Utilisez \"Chercher Combat\" ou rejoignez un tournois au lieu de demander souvent dans la discussion des combats."
]
},
"3": {
"english": [
"3. Be appropriate and respectful of others:",
"- Harassment, flaming, vulgarity, revealing of personal information, or spamming someone's PMs/Challenges will not be tolerated. Do not ask for authority. Needlessly delaying the result of a battle is explicitly forbidden. This is not a dating service. Sexual, inappropriate, or illegal sites and/or content will result in a ban."
],
"spanish": [
"3. Se apropiado y respetuoso con los demás:",
"- Acosar, insultar, la vulgaridad, revelar información personal, molestar a los demás enviándoles Spam o invitaciones de batalla constantes no será tolerado. No solicites ser Autoridad. Demorar o retrasar el resultado en una batalla está explicitamente prohibido Esto NO es un sitio de citas. Publicar o referir sitios que contengan contenido sexual, inapropiado o ilegal será sancionado con un Ban."
],
"chinese": [
"3. 尊重他人,得体交流与对战:",
"- 禁止对他人进行骚扰、挑衅、辱骂、人肉或是故意泄露他人隐私,禁止在与他人的私信、对战、观战中刷屏,或是连续发送挑战等。不要索取权限。严禁恶意挂机或拖延对战时间。这里不是一个约会交友的场所;发送任何非法、色情、不良的网站和内容都会被处于永久封禁。"
],
"french": [
"3. Soyez appropriés et respectez les autres:",
"- Le harcèlement, la provocation, la vulgarité, la divulgation d'informations personnelles ou le spam en message privé ou en défi à quelqu'un d'autre ne sera pas toléré. Ne demandez pas le pouvoir. Ne poussez pas la fin du combat trop loin sans raisons, cela est interdit. Ce n'est pas un site de rencontre. Des sites ou des liens à caractères sexuels, inappropriés ou illégaux vous fera bannir."
]
},
"4": {
"english": [
"4. Misuse of the server is prohibited:",
"- Do not attempt to cheat the ladder system, exploit bugs, or attempt to find loopholes in the rules. DDoS and other \"cyber attacks\" will not be tolerated. Evading any official punishment is grounds for banning. All appeals can be made on the forums. Do not provide false evidence or claims to the authority, nor waste their time."
],
"spanish": [
"4. El uso indebido del servidor está prohibido:",
"- No intente hacer trampa en el sistema de ranking, aprovecharse de algún bug o intentar buscar pretextos en las reglas. El DDoS y cualquier otra clase de \"ciber ataque\" no será tolerado. Evadir cualquier sanción oficial constituye la aplicación de un Ban. Todas las apelaciones o solicitudes de desbaneo se pueden hacer desde el foro. No se dirija a la Autoridad con falsas afirmaciones o evidencias, ni tampoco le haga perder tiempo."
],
"chinese": [
"4. 按照规定使用服务器:",
"- 禁止通过任何不公平的手段或是利用服务器的bug与漏洞进行ladder刷分或赚取Tournaments积分。DDoS以及其他任何网络攻击都将遭到严惩。通过任何手段避开封禁、禁言将触发将遭到永久封禁。PO论坛是发布解除封禁请求的唯一去处。不要提供虚假的证据或是浪费管理员的时间。"
],
"french": [
"4. Ne pas mal utiliser le serveur:",
"- N'essayer pas de tricher pour gagner des points, n'abusez pas des bugs, ou n'essayez pas de contourner les règles. DDoS et d'autres \"attaques cyber\" ne seront pas tolérés. N’échappez pas à des punitions officielles car cela peut vous coûter un ban. En cas de ban, les appels se font sur les forums. Ne donnez pas de fausses preuves ou de fausses informations aux autorités, ne gâchez pas leur temps non plus."
]
}
};
lastMemUpdate = 0;
bannedUrls = [];
battlesFought = +sys.getVal("Stats/BattlesFought");
lastCleared = +sys.getVal("Stats/LastCleared");
mafiachan = SESSION.global().channelManager.createPermChannel("Mafia", "Use /help to get started!");
staffchannel = SESSION.global().channelManager.createPermChannel("Indigo Plateau", "Welcome to the main staff channel! Discuss things that other users shouldn't hear here!");
sachannel = SESSION.global().channelManager.createPermChannel("Victory Road", "Welcome to all channel staff!");
tourchannel = SESSION.global().channelManager.createPermChannel("Tournaments", 'Useful commands are "/join" (to join a tournament), "/unjoin" (to leave a tournament), "/viewround" (to view the status of matches) and "/megausers" (for a list of users who manage tournaments). Please read the full Tournament Guidelines: http://pokemon-online.eu/forums/showthread.php?2079-Tour-Rules');
watchchannel = SESSION.global().channelManager.createPermChannel("Watch", "Alerts are displayed here.");
triviachan = SESSION.global().channelManager.createPermChannel("Trivia", "Play trivia here!");
revchan = SESSION.global().channelManager.createPermChannel("TrivReview", "For Trivia Admins to review questions");
//mafiarev = SESSION.global().channelManager.createPermChannel("Mafia Review", "For Mafia Admins to review themes");
hangmanchan = SESSION.global().channelManager.createPermChannel("Hangman", "Type /help to see how to play!");
blackjackchan = SESSION.global().channelManager.createPermChannel("Blackjack", "Play Blackjack here!");
safarichan = SESSION.global().channelManager.createPermChannel("Safari", "Type /help to see how to play!");
/* restore mutes, smutes, mafiabans, mafiawarns, rangebans, megausers */
script.mutes = new MemoryHash(Config.dataDir+"mutes.txt");
script.mbans = new MemoryHash(Config.dataDir+"mbans.txt");
script.smutes = new MemoryHash(Config.dataDir+"smutes.txt");
script.rangebans = new MemoryHash(Config.dataDir+"rangebans.txt");
script.contributors = new MemoryHash(Config.dataDir+"contributors.txt");
script.mafiaAdmins = new MemoryHash(Config.dataDir+"mafiaadmins.txt");
script.mafiaSuperAdmins = new MemoryHash(Config.dataDir+"mafiasuperadmins.txt");
script.hangmanAdmins = new MemoryHash(Config.dataDir+"hangmanadmins.txt");
script.hangmanSuperAdmins = new MemoryHash(Config.dataDir+"hangmansuperadmins.txt");
script.safbans = new MemoryHash(Config.dataDir+"safbans.txt");
script.ipbans = new MemoryHash(Config.dataDir+"ipbans.txt");
script.detained = new MemoryHash(Config.dataDir+"detained.txt");
script.hmutes = new MemoryHash(Config.dataDir+"hmutes.txt");
script.namesToWatch = new MemoryHash(Config.dataDir+"namesToWatch.txt");
script.namesToUnban = new MemoryHash(Config.dataDir+"namesToCookieUnban.txt");
script.idBans = new MemoryHash(Config.dataDir+"idbans.txt");
script.autoteamsAuth = new MemoryHash(Config.dataDir + "autoteamsauth.txt");
try {
script.league = JSON.parse(sys.read(Config.dataDir+"league.json")).league;
} catch (e) {
script.league = {};
}
var announceChan = (typeof staffchannel == "number") ? staffchannel : 0;
proxy_ips = {};
function addProxybans(content) {
var lines = content.split(/\n/);
for (var k = 0; k < lines.length; ++k) {
var proxy_ip = lines[k].split(":")[0];
if (proxy_ip !== 0) proxy_ips[proxy_ip] = true;
}
}
var PROXY_FILE = "proxy_list.txt";
var content = sys.getFileContent(PROXY_FILE);
if (content) { addProxybans(content); }
else sys.webCall(Config.base_url + PROXY_FILE, addProxybans);
if (typeof script.authStats == 'undefined')
script.authStats = {};
if (typeof nameBans == 'undefined') {
script.refreshNamebans();
}
if (typeof nameWarns == 'undefined') {
nameWarns = [];
try {
var serialized = JSON.parse(sys.getFileContent("scriptdata/nameWarns.json"));
for (var i = 0; i < serialized.nameWarns.length; ++i) {
nameWarns.push(new RegExp(serialized.nameWarns[i], "i"));
}
} catch (e) {
// ignore
}
}
if (SESSION.global().battleinfo === undefined) {
SESSION.global().battleinfo = {};
}
if (SESSION.global().BannedUrls === undefined) {
SESSION.global().BannedUrls = [];
sys.webCall(Config.base_url + "bansites.txt", function(resp) {
SESSION.global().BannedUrls = resp.toLowerCase().split(/\n/);
});
}
if (typeof VarsCreated != 'undefined')
return;
key = function(a,b) {
return a + "*" + sys.ip(b);
};
script.saveKey = function(thing, id, val) {
sys.saveVal(key(thing,id), val);
};
script.getKey = function(thing, id) {
var temp = key(thing,id);
if (temp) {
return sys.getVal(temp);
} else {
return false;
}
};
script.cmp = function(a, b) {
return a.toLowerCase() == b.toLowerCase();
};
//script.isMafiaAdmin = require('mafia.js').isMafiaAdmin;
//script.isMafiaSuperAdmin = require('mafia.js').isMafiaSuperAdmin;
//script.isSafariAdmin = require('safari.js').isChannelAdmin;
isSuperAdmin = function(id) {
if (typeof script.superAdmins != "object" || script.superAdmins.length === undefined) return false;
if (sys.auth(id) != 2) return false;
var name = sys.name(id);
for (var i = 0; i < script.superAdmins.length; ++i) {
if (script.cmp(name, script.superAdmins[i]))
return true;
}
return false;
};
script.battlesStopped = false;
maxPlayersOnline = 0;
lineCount = 0;
if (typeof script.chanNameBans == 'undefined') {
script.chanNameBans = [];
try {
var serialized = JSON.parse(sys.getFileContent(Config.dataDir+"chanNameBans.json"));
for (var i = 0; i < serialized.chanNameBans.length; ++i) {
script.chanNameBans.push(new RegExp(serialized.chanNameBans[i], "i"));
}
} catch (e) {
// ignore
}
}
try {
pastebin_api_key = sys.getFileContent(Config.dataDir+"pastebin_api_key").replace("\n", "");
pastebin_user_key = sys.getFileContent(Config.dataDir+"pastebin_user_key").replace("\n", "");
} catch(e) {
normalbot.sendAll("Couldn't load api keys: " + e, staffchannel);
}
sendMainTour = function(message) {
sys.sendAll(message, 0);
sys.sendAll(message, tourchannel);
};
script.allowedRangeNames = sys.getFileContent(Config.dataDir + "rangewhitelist.txt").split("\n");
callplugins("init");
VarsCreated = true;
}, /* end of init */
issueBan : function(type, src, tar, commandData, maxTime) {
var memoryhash = {"mute": script.mutes, "mban": script.mbans, "smute": script.smutes, "hmute": script.hmutes, "safban": script.safbans}[type];
var banbot;
if (type == "mban") {
banbot = mafiabot;
}
else if (type == "hmute") {
banbot = hangbot;
}
else if (type == "safban") {
banbot = safaribot;
}
else {
banbot = normalbot;
}
var verb = {"mute": "muted", "mban": "banned from Mafia", "smute": "secretly muted", "hmute": "banned from Hangman", "safban": "banned from Safari"}[type];
var nomi = {"mute": "mute", "mban": "mafia ban", "smute": "secret mute", "hmute": "hangman ban", "safban": "safari ban"}[type];
var sendAll = {
"smute": function(line) {
sys.dbAuths().map(sys.id).filter(function(uid) { return uid !== undefined; }).forEach(function(uid) {
banbot.sendMessage(uid, line);
});
},
"mban": function(line) {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, mafiachan);
banbot.sendAll(line, sachannel);
},
"mute": function(line) {
banbot.sendAll(line);
},
"hmute" : function(line) {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, hangmanchan);
banbot.sendAll(line, sachannel);
},
"safban" : function(line) {
banbot.sendAll(line, safarichan);
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, sachannel);
}
}[type];
var expires = 0;
var defaultTime = {"mute": "1d", "mban": "1d", "smute": "1d", "hmute": "1d", "safban": "1d"}[type];
var reason = "";
var timeString = "";
var data = commandData;
var ip;
var i = -1, j = -1, time = "";
if (data !== undefined) {
i = data.indexOf(":");
j = data.lastIndexOf(":");
time = data.substring(j + 1, data.length);
}
if (tar === undefined) {
if (i !== -1) {
commandData = data.substring(0, i);
tar = sys.id(commandData);
if (time === "" || isNaN(time.replace(/s\s|m\s|h\s|d\s|w\s|s|m|h|d|w/gi, ""))) {
time = defaultTime;
reason = data.slice(i + 1);
} else if (i !== j) {
reason = data.substring(i + 1, j);
}
}
}
var secs = getSeconds(time !== "" ? time : defaultTime);
// limit it!
if (typeof maxTime == "number") secs = (secs > maxTime || secs === 0 || isNaN(secs)) ? maxTime : secs;
if (secs > 0) {
timeString = getTimeString(secs);
expires = secs + parseInt(sys.time(), 10);
}
if (reason === "" && sys.auth(src) < 3) {
banbot.sendMessage(src, "You need to give a reason for the " + nomi + "!", channel);
return;
}
var tarip = tar !== undefined ? sys.ip(tar) : sys.dbIp(commandData);
if (tarip === undefined) {
banbot.sendMessage(src, "Couldn't find " + commandData, channel);
return;
}
var maxAuth = (tar ? sys.auth(tar) : sys.maxAuth(tarip));
if ((maxAuth>=sys.auth(src) && maxAuth > 0) || (type === "smute" && script.getMaxAuth(tar) > 0)) {
banbot.sendMessage(src, "You don't have sufficient auth to " + nomi + " " + commandData + ".", channel);
return;
}
var active = false;
if (memoryhash.get(tarip)) {
if (sys.time() - memoryhash.get(tarip).split(":")[0] < 15) {
banbot.sendMessage(src, "This person was recently " + verb, channel);
return;
}
active = true;
}
if (sys.loggedIn(tar)) {
if (SESSION.users(tar)[type].active) {
active = true;
}
}
sendAll((active ? nonFlashing(sys.name(src)) + " changed " + commandData.toCorrectCase() + "'s " + nomi + " time to " + (timeString === "" ? "forever!" : timeString + " from now!") : commandData.toCorrectCase() + " was " + verb + " by " + nonFlashing(sys.name(src)) + (timeString === "" ? "" : " for ") + timeString + "!") + (reason.length > 0 ? " [Reason: " + reason + "]" : "") + " [Channel: "+sys.channel(channel) + "]");
if (tarip !== "::1%0") {
sys.playerIds().forEach(function(id) {
if (sys.loggedIn(id) && sys.ip(id) === tarip)
SESSION.users(id).activate(type, sys.name(src), expires, reason, true);
});
}
else { // hack to target single user session for webclient's shared IPs
SESSION.users(tar)[type].active = true;
SESSION.users(tar)[type].by = sys.name(src);
SESSION.users(tar)[type].expires = expires;
SESSION.users(tar)[type].reason = reason;
}
if (!sys.loggedIn(tar)) {
memoryhash.add(tarip, sys.time() + ":" + sys.name(src) + ":" + expires + ":" + commandData + ":" + reason);
}
var authority= sys.name(src).toLowerCase();
script.authStats[authority] = script.authStats[authority] || {};
script.authStats[authority]["latest" + type] = [commandData, parseInt(sys.time(), 10)];
},
unban: function(type, src, tar, commandData) {
var memoryhash = {"mute": script.mutes, "mban": script.mbans, "smute": script.smutes, "hmute": script.hmutes, "safban": script.safbans}[type];
var banbot;
if (type == "mban") {
banbot = mafiabot;
}
else if (type == "hmute") {
banbot = hangbot;
}
else if (type == "safban") {
banbot = safaribot;
}
else {
banbot = normalbot;
}
var verb = {"mute": "unmuted", "mban": "unbanned from Mafia", "smute": "secretly unmuted", "hmute": "unbanned from Hangman", "safban": "unbanned from Safari"}[type];
var nomi = {"mute": "unmute", "mban": "mafia unban", "smute": "secret unmute", "hmute": "hangman unban", "safban": "safari unban"}[type];
var past = {"mute": "muted", "mban": "mafia banned", "smute": "secretly muted", "hmute": "hangman banned", "safban": "safari banned"}[type];
var sendAll = {
"smute": function(line) {
sys.dbAuths().map(sys.id).filter(function(uid) { return uid !== undefined; }).forEach(function(uid) {
banbot.sendMessage(uid, line);
});
},
"mban": function(line, ip) {
if (ip) {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, sachannel);
} else {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, mafiachan);
banbot.sendAll(line, sachannel);
}
},
"mute": function(line, ip) {
if (ip) {
banbot.sendAll(line, staffchannel);
} else {
banbot.sendAll(line);
}
},
"hmute" : function(line, ip) {
if (ip) {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, sachannel);
} else {
banbot.sendAll(line, hangmanchan);
banbot.sendAll(line, sachannel);
banbot.sendAll(line, staffchannel);
}
},
"safban" : function(line, ip) {
if (ip) {
banbot.sendAll(line, staffchannel);
banbot.sendAll(line, sachannel);
} else {
banbot.sendAll(line, safarichan);
banbot.sendAll(line, sachannel);
banbot.sendAll(line, staffchannel);
}
}
}[type];
if (tar === undefined) {
if (memoryhash.get(commandData)) {
sendAll("IP address " + commandData + " was " + verb + " by " + nonFlashing(sys.name(src)) + "!", true);
memoryhash.remove(commandData);
return;
}
var ip = sys.dbIp(commandData);
if (ip !== undefined && memoryhash.get(ip)) {
sendAll("" + commandData + " was " + verb + " by " + nonFlashing(sys.name(src)) + "!");
memoryhash.remove(ip);
return;
}
banbot.sendMessage(src, "He/she's not " + past, channel);
return;
}
if (!SESSION.users(sys.id(commandData))[type].active) {
banbot.sendMessage(src, "He/she's not " + past, channel);
return;
}
if (SESSION.users(src)[type].active && tar == src) {
banbot.sendMessage(src, "You may not " + nomi + " yourself!", channel);
return;
}
sys.playerIds().forEach(function(id) {
if (sys.loggedIn(id) && sys.ip(id) === sys.ip(tar) && SESSION.users(id)[type].active) {
SESSION.users(id).un(type);
}
});
sendAll("" + commandData + " was " + verb + " by " + nonFlashing(sys.name(src)) + "!");
},
banList: function (src, command, commandData) {
var mh;
var name;
if (command == "mutes" || command == "mutelist") {
mh = script.mutes;
name = "Muted list";
} else if (command == "smutelist") {
mh = script.smutes;
name = "Secretly muted list";
} else if (command == "mafiabans") {
mh = script.mbans;
name = "Mafiabans";
} else if (command == "hangmanmutes" || command == "hangmanbans") {
mh = script.hmutes;
name = "Hangman Bans";
} else if (command == "safaribans") {
mh = script.safbans;
name = "Safari Bans";
}
var width=5;
var max_message_length = 30000;
var tmp = [];
var t = parseInt(sys.time(), 10);
var toDelete = [];
for (var ip in mh.hash) {
if (mh.hash.hasOwnProperty(ip)) {
var values = mh.hash[ip].split(":");
var banTime = 0;
var by = "";
var expires = 0;
var banned_name;
var reason = "";
if (values.length >= 5) {
banTime = parseInt(values[0], 10);
by = values[1];
expires = parseInt(values[2], 10);
banned_name = values[3];
reason = values.slice(4);
if (expires !== 0 && expires < t) {
toDelete.push(ip);
continue;
}
} else if (command == "smutelist") {
var aliases = sys.aliases(ip);
if (aliases[0] !== undefined) {
banned_name = aliases[0];
} else {
banned_name = "~Unknown~";
}
} else {
banTime = parseInt(values[0], 10);
}
if(typeof commandData != 'undefined' && (!banned_name || banned_name.toLowerCase().indexOf(commandData.toLowerCase()) == -1))
continue;
tmp.push([ip.replace("::ffff:", ""), banned_name, by, (banTime === 0 ? "unknown" : getTimeString(t-banTime)), (expires === 0 ? "never" : getTimeString(expires-t)), utilities.html_escape(reason)]);
}
}
for (var k = 0; k < toDelete.length; ++k)
delete mh.hash[toDelete[k]];
if (toDelete.length > 0)
mh.save();
tmp.sort(function(a,b) { return a[3] - b[3];});
// generate HTML
var table_header = '<table border="1" cellpadding="5" cellspacing="0"><tr><td colspan="' + width + '"><center><strong>' + utilities.html_escape(name) + '</strong></center></td></tr><tr><th>IP</th><th>Name</th><th>By</th><th>Issued ago</th><th>Expires in</th><th>Reason</th>';
var table_footer = '</table>';
var table = table_header;
var line;
var send_rows = 0;
while(tmp.length > 0) {
line = '<tr><td>'+tmp[0].join('</td><td>')+'</td></tr>';
tmp.splice(0,1);
if (table.length + line.length + table_footer.length > max_message_length) {
if (send_rows === 0) continue; // Can't send this line!
table += table_footer;
sys.sendHtmlMessage(src, table, channel);
table = table_header;
send_rows = 0;
}
table += line;
++send_rows;
}
table += table_footer;
if (send_rows > 0) {
sys.sendHtmlMessage(src, table, channel);
} else {
normalbot.sendMessage(src, "There are no active " + name + ".", channel);
}
return;