-
Notifications
You must be signed in to change notification settings - Fork 7
/
beholder.py
executable file
·2302 lines (2126 loc) · 117 KB
/
beholder.py
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
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
beholder.py - a game-reporting and general services IRC bot for
the hardfought.org NetHack server.
Copyright (c) 2017 A. Thomson, K. Simpson
Based on original code from:
deathbot.py - a game-reporting IRC bot for AceHack
Copyright (c) 2011, Edoardo Spadolini
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
from twisted.internet import reactor, protocol, ssl, task
from twisted.internet.protocol import Protocol, ReconnectingClientFactory
from twisted.words.protocols import irc
from twisted.python import filepath, log
from twisted.python.logfile import DailyLogFile
from twisted.application import internet, service
import site # to help find botconf
import base64 # for sasl login
import sys # for logging something4
import datetime # for timestamp stuff
import time # for !time
import ast # for conduct/achievement bitfields - not really used
import os # for check path exists (dumplogs), and chmod
import stat # for chmod mode bits
import re # for hello, and other things.
import urllib # for dealing with NH4 variants' #&$#@ spaces in filenames.
import shelve # for persistent !tell messages
import random # for !rng and friends
import glob # for matching in !whereis
import requests # for !rumor
site.addsitedir('.')
from botconf import HOST, PORT, CHANNEL, NICK, USERNAME, REALNAME, BOTDIR
from botconf import PWFILE, FILEROOT, WEBROOT, LOGROOT, PINOBOT, ADMIN
from botconf import SERVERTAG
#try: from botconf import LOGBASE
#except: LOGBASE = "/var/log/Beholder.log"
try: from botconf import LL_TURNCOUNTS
except: LL_TURNCOUNTS = {}
try: from botconf import DCBRIDGE
except: DCBRIDGE = None
try: from botconf import TEST
except: TEST = False
try:
from botconf import REMOTES
except:
SLAVE = True #if we have no slaves, we (probably) are the slave
REMOTES = {}
try:
from botconf import MASTERS
except:
SLAVE = False #if we have no master we (definitely) are the master
MASTERS = []
def fromtimestamp_int(s):
return datetime.datetime.fromtimestamp(int(s))
def timedelta_int(s):
return datetime.timedelta(seconds=int(s))
def isodate(s):
return datetime.datetime.strptime(s, "%Y%m%d").date()
def fixdump(s):
return s.replace("_",":")
xlogfile_parse = dict.fromkeys(
("points", "deathdnum", "deathlev", "maxlvl", "hp", "maxhp", "deaths",
"starttime", "curtime", "endtime", "user_seed",
"uid", "turns", "xplevel", "exp","depth","dnum","score","amulet", "lltype"), int)
xlogfile_parse.update(dict.fromkeys(
("conduct", "event", "carried", "flags", "achieve"), ast.literal_eval))
xlogfile_parse["realtime"] = timedelta_int
def parse_xlogfile_line(line, delim):
record = {}
for field in line.strip().decode(encoding='UTF-8', errors='ignore').split(delim):
key, _, value = field.partition("=")
if key in xlogfile_parse:
value = xlogfile_parse[key](value)
record[key] = value
return record
class DeathBotProtocol(irc.IRCClient):
nickname = NICK
username = USERNAME
realname = REALNAME
admin = ADMIN
slaves = {}
for r in REMOTES:
slaves[REMOTES[r][1]] = r
# if we're the master, include ourself on the slaves list
if not SLAVE:
slaves[NICK] = [WEBROOT,NICK,FILEROOT]
#...and the masters list
MASTERS += [NICK]
try:
password = open(PWFILE, "r").read().strip()
except:
password = "NotTHEPassword"
sourceURL = "https://github.com/NHTangles/beholder"
versionName = "beholder.py"
versionNum = "0.1"
dump_url_prefix = WEBROOT + "userdata/{name[0]}/{name}/"
dump_file_prefix = FILEROOT + "dgldir/userdata/{name[0]}/{name}/"
if not SLAVE:
scoresURL = WEBROOT + "nethack/scoreboard (HDF) or https://nethackscoreboard.org (ALL)"
rceditURL = WEBROOT + "nethack/rcedit"
helpURL = WEBROOT + "nethack"
logday = time.strftime("%d")
chanLogName = LOGROOT + CHANNEL + time.strftime("-%Y-%m-%d.log")
chanLog = open(chanLogName,'a')
os.chmod(chanLogName,stat.S_IRUSR|stat.S_IWUSR|stat.S_IRGRP|stat.S_IROTH)
xlogfiles = {filepath.FilePath(FILEROOT+"nh343-hdf/var/xlogfile"): ("nh343", ":", "nh343/dumplog/{starttime}.nh343.txt"),
filepath.FilePath(FILEROOT+"nh363-hdf/var/xlogfile"): ("nh363", "\t", "nethack/dumplog/{starttime}.nh.html"),
filepath.FilePath(FILEROOT+"nh370.112-hdf/var/xlogfile"): ("nh370", "\t", "nethack/dumplog/{starttime}.nh.html"),
filepath.FilePath(FILEROOT+"grunthack-0.3.0/var/xlogfile"): ("gh", ":", "gh/dumplog/{starttime}.gh.txt"),
filepath.FilePath(FILEROOT+"dnethack-3.23.0/xlogfile"): ("dnh", ":", "dnethack/dumplog/{starttime}.dnh.txt"),
filepath.FilePath(FILEROOT+"fiqhackdir/data/xlogfile"): ("fh", ":", "fiqhack/dumplog/{dumplog}"),
filepath.FilePath(FILEROOT+"dynahack/dynahack-data/var/xlogfile"): ("dyn", ":", "dynahack/dumplog/{dumplog}"),
filepath.FilePath(FILEROOT+"nh4dir/save/xlogfile"): ("nh4", ":", "nethack4/dumplog/{dumplog}"),
filepath.FilePath(FILEROOT+"fourkdir-4.3.0.5/save/xlogfile"): ("4k", "\t", "nhfourk/dumps/{dumplog}"),
filepath.FilePath(FILEROOT+"sporkhack-0.7.0/var/xlogfile"): ("sp", "\t", "sporkhack/dumplog/{starttime}.sp.txt"),
filepath.FilePath(FILEROOT+"xnethack-8.0.0.1/var/xlogfile"): ("xnh", "\t", "xnethack/dumplog/{starttime}.xnh.html"),
filepath.FilePath(FILEROOT+"splicehack-1.2.0/var/xlogfile"): ("spl", "\t", "splicehack/dumplog/{starttime}.splice.html"),
filepath.FilePath(FILEROOT+"nh13d/xlogfile"): ("nh13d", ":", "nh13d/dumplog/{starttime}.nh13d.txt"),
filepath.FilePath(FILEROOT+"slashem-0.0.8E0F2/xlogfile"): ("slshm", ":", "slashem/dumplog/{starttime}.slashem.txt"),
filepath.FilePath(FILEROOT+"notdnethack-2024.05.15/xlogfile"): ("ndnh", ":", "notdnethack/dumplog/{starttime}.ndnh.txt"),
filepath.FilePath(FILEROOT+"notnotdnethack-2024.05.15/xlogfile"): ("nndnh", ":", "notnotdnethack/dumplog/{starttime}.nndnh.txt"),
filepath.FilePath(FILEROOT+"evilhack-0.8.4/var/xlogfile"): ("evil", "\t", "evilhack/dumplog/{starttime}.evil.html"),
filepath.FilePath(FILEROOT+"slashthem-0.9.7/xlogfile"): ("slth", ":", "slashthem/dumplog/{starttime}.slth.txt"),
filepath.FilePath(FILEROOT+"gnollhack-4.2.0.16/var/xlogfile"): ("gnoll", "\t", "gnollhack/dumplog/{starttime}.gnoll.html"),
filepath.FilePath(FILEROOT+"acehack/xlogfile"): ("ace", ":", "acehack/dumplog/{starttime}.ace.txt"),
filepath.FilePath(FILEROOT+"hackem-1.3.2/var/xlogfile"): ("hackm", "\t", "hackem/dumplog/{starttime}.hackem.html"),
filepath.FilePath(FILEROOT+"nethackathon/var/xlogfile"): ("nhthon", "\t", "nethackathon/dumplog/{starttime}.nhthon.html"),
filepath.FilePath(FILEROOT+"unnethack-6.0.12/var/xlogfile"): ("un", "\t", "unnethack/dumplog/{starttime}.un.txt.html")}
livelogs = {filepath.FilePath(FILEROOT+"nh343-hdf/var/livelog"): ("nh343", ":"),
filepath.FilePath(FILEROOT+"nh363-hdf/var/livelog"): ("nh363", "\t"),
filepath.FilePath(FILEROOT+"nh370.112-hdf/var/livelog"): ("nh370", "\t"),
filepath.FilePath(FILEROOT+"grunthack-0.3.0/var/livelog"): ("gh", ":"),
filepath.FilePath(FILEROOT+"dnethack-3.23.0/livelog"): ("dnh", ":"),
filepath.FilePath(FILEROOT+"fourkdir-4.3.0.5/save/livelog"): ("4k", "\t"),
filepath.FilePath(FILEROOT+"fiqhackdir/data/livelog"): ("fh", ":"),
filepath.FilePath(FILEROOT+"sporkhack-0.7.0/var/livelog"): ("sp", ":"),
filepath.FilePath(FILEROOT+"xnethack-8.0.0.1/var/livelog"): ("xnh", "\t"),
filepath.FilePath(FILEROOT+"splicehack-1.2.0/var/livelog"): ("spl", "\t"),
filepath.FilePath(FILEROOT+"nh13d/livelog"): ("nh13d", ":"),
filepath.FilePath(FILEROOT+"slashem-0.0.8E0F2/livelog"): ("slshm", ":"),
filepath.FilePath(FILEROOT+"notdnethack-2024.05.15/livelog"): ("ndnh", ":"),
filepath.FilePath(FILEROOT+"notnotdnethack-2024.05.15/livelog"): ("nndnh", ":"),
filepath.FilePath(FILEROOT+"evilhack-0.8.4/var/livelog"): ("evil", "\t"),
filepath.FilePath(FILEROOT+"slashthem-0.9.7/livelog"): ("slth", ":"),
filepath.FilePath(FILEROOT+"gnollhack-4.2.0.16/var/livelog"): ("gnoll", "\t"),
filepath.FilePath(FILEROOT+"acehack/livelog"): ("ace", ":"),
filepath.FilePath(FILEROOT+"hackem-1.3.2/var/livelog"): ("hackm", "\t"),
filepath.FilePath(FILEROOT+"unnethack-6.0.12/var/livelog"): ("un", "\t")}
# Forward events to other bots at the request of maintainers of other variant-specific channels
forwards = {"nh343" : [],
"nh363" : [],
"nh370" : [],
"zapm" : [],
"gh" : [],
"dnh" : [],
"fh" : [],
"dyn" : [],
"nh4" : [],
"4k" : [],
"sp" : [],
"xnh" : [],
"spl" : [],
"nh13d" : [],
"slshm" : [],
"tnnt" : [],
"nhthon" : [],
"ndnh" : [],
"nndnh" : [],
"evil" : [],
"slth" : [],
"gnoll" : [],
"ace" : [],
"hackm" : [],
"un" : []}
# for displaying variants and server tags in colour
displaystring = {"nh343" : "\x0315nh343\x03",
"nh363" : "\x0307nh363\x03",
"nh370" : "\x0307nh370\x03",
"zapm" : "\x0303zapm\x03",
"gh" : "\x0304gh\x03",
"dnh" : "\x0313dnh\x03",
"fh" : "\x0310fh\x03",
"dyn" : "\x0305dyn\x03",
"nh4" : "\x0306nh4\x03",
"4k" : "\x03114k\x03",
"sp" : "\x0314sp\x03",
"xnh" : "\x0309xnh\x03",
"spl" : "\x0303spl\x03",
"nh13d" : "\x0311nh13d\x03",
"slshm" : "\x0314slshm\x03",
"ndnh" : "\x0313ndnh\x03",
"nndnh" : "\x0313nndnh\x03",
"evil" : "\x0304evil\x03",
"tnnt" : "\x0310tnnt\x03",
"nhthon" : "\x0310nhthon\x03",
"un" : "\x0308un\x03",
"slth" : "\x0305slth\x03",
"gnoll" : "\x0309gnoll\x03",
"ace" : "\x0311ace\x03",
"hackm" : "\x0315hackm\x03",
"hdf-us" : "\x1D\x0304hdf-us\x03\x0F",
"hdf-au" : "\x1D\x0303hdf-au\x03\x0F",
"hdf-eu" : "\x1D\x0312hdf-eu\x03\x0F"}
# put the displaystring for a thing in square brackets
def displaytag(self, thing):
return '[' + self.displaystring.get(thing,thing) + ']'
# for !who or !players or whatever we end up calling it
# Reduce the repetitive crap
DGLD=FILEROOT+"dgldir/"
INPR=DGLD+"inprogress-"
inprog = { "nh343" : [INPR+"nh343-hdf/"],
"nh363" : [INPR+"nh363-hdf/"],
"nh370" : [INPR+"nh370.16-hdf/", INPR+"nh370.17-hdf/",
INPR+"nh370.18-hdf/", INPR+"nh370.20-hdf/",
INPR+"nh370.22-hdf/", INPR+"nh370.23-hdf/",
INPR+"nh370.27-hdf/", INPR+"nh370.28-hdf/",
INPR+"nh370.29-hdf/", INPR+"nh370.30-hdf/",
INPR+"nh370.31-hdf/", INPR+"nh370.32-hdf/",
INPR+"nh370.35-hdf/", INPR+"nh370.36-hdf/",
INPR+"nh370.38-hdf/", INPR+"nh370.39-hdf/",
INPR+"nh370.40-hdf/", INPR+"nh370.42-hdf/",
INPR+"nh370.43-hdf/", INPR+"nh370.46-hdf/",
INPR+"nh370.47-hdf/", INPR+"nh370.50-hdf/",
INPR+"nh370.51-hdf/", INPR+"nh370.53-hdf/",
INPR+"nh370.58-hdf/", INPR+"nh370.59-hdf/",
INPR+"nh370.60-hdf/", INPR+"nh370.61-hdf/",
INPR+"nh370.62-hdf/", INPR+"nh370.64-hdf/",
INPR+"nh370.65-hdf/", INPR+"nh370.66-hdf/",
INPR+"nh370.69-hdf/", INPR+"nh370.70-hdf/",
INPR+"nh370.71-hdf/", INPR+"nh370.73-hdf/",
INPR+"nh370.78-hdf/", INPR+"nh370.80-hdf/",
INPR+"nh370.82-hdf/", INPR+"nh370.83-hdf/",
INPR+"nh370.84-hdf/", INPR+"nh370.86-hdf/",
INPR+"nh370.87-hdf/", INPR+"nh370.88-hdf/",
INPR+"nh370.89-hdf/", INPR+"nh370.90-hdf/",
INPR+"nh370.94-hdf/", INPR+"nh370.95-hdf/",
INPR+"nh370.97-hdf/", INPR+"nh370.101-hdf/",
INPR+"nh370.102-hdf/", INPR+"nh370.103-hdf/",
INPR+"nh370.105-hdf/", INPR+"nh370.106-hdf/",
INPR+"nh370.107-hdf/", INPR+"nh370.110-hdf/",
INPR+"nh370.112-hdf/"],
"zapm" : [INPR+"zapm/"],
"gh" : [INPR+"gh024/", INPR+"gh030/"],
"un" : [INPR+"un531/", INPR+"un532/",
INPR+"un600/", INPR+"un601/",
INPR+"un602/", INPR+"un603/",
INPR+"un604/", INPR+"un605/",
INPR+"un606/", INPR+"un607/",
INPR+"un608/", INPR+"un609/",
INPR+"un6010/", INPR+"un6011/",
INPR+"un6012/"],
"dnh" : [INPR+"dnh3171/", INPR+"dnh318/",
INPR+"dnh319/", INPR+"dnh3191/",
INPR+"dnh320/", INPR+"dnh321/",
INPR+"dnh3211/", INPR+"dnh3212/",
INPR+"dnh3213/", INPR+"dnh3214/",
INPR+"dnh322/", INPR+"dnh323/"],
"fh" : [INPR+"fh/"],
"4k" : [INPR+"4k/", INPR+"4k4305/"],
"nh4" : [INPR+"nh4/"],
"sp" : [INPR+"sp065/", INPR+"sp070/"],
"xnh" : [INPR+"xnh040/", INPR+"xnh041/",
INPR+"xnh50/", INPR+"xnh51/",
INPR+"xnh51.1/", INPR+"xnh51.2/",
INPR+"xnh51.3/", INPR+"xnh600/",
INPR+"xnh610/", INPR+"xnh620/",
INPR+"xnh630/", INPR+"xnh700/",
INPR+"xnh7001/", INPR+"xnh710/",
INPR+"xnh800/", INPR+"xnh8001/"],
"spl" : [INPR+"spl063/", INPR+"spl064/",
INPR+"spl070/", INPR+"spl071/",
INPR+"spl071.21/", INPR+"spl080/",
INPR+"spl081/", INPR+"spl082/",
INPR+"spl100/", INPR+"spl110/",
INPR+"spl120/"],
"nh13d" : [INPR+"nh13d/"],
"slshm" : [INPR+"slashem/"],
"ndnh" : [INPR+"ndnh-524/", INPR+"ndnh-1224/",
INPR+"ndnh-0416/", INPR+"ndnh-0521/",
INPR+"ndnh-0322/", INPR+"ndnh-0530/",
INPR+"ndnh-0918/", INPR+"ndnh-0515/",
INPR+"ndnh-0515v2/"],
"nndnh" : [INPR+"nndnh-0515/"],
"evil" : [INPR+"evil040/", INPR+"evil041/",
INPR+"evil042/", INPR+"evil050/",
INPR+"evil060/", INPR+"evil070/",
INPR+"evil071/", INPR+"evil080/",
INPR+"evil081/", INPR+"evil082/",
INPR+"evil083/", INPR+"evil084/"],
"tnnt" : [INPR+"tnnt/"],
"nhthon" : [INPR+"nethackathon/"],
"slth" : [INPR+"slth095/", INPR+"slth096/",
INPR+"slth097/"],
"gnoll" : [INPR+"gnoll4104/", INPR+"gnoll410b2/",
INPR+"gnoll410b4/", INPR+"gnoll410b9/",
INPR+"gnoll410b14/", INPR+"gnoll410b15/",
INPR+"gnoll41041/", INPR+"gnoll410/",
INPR+"gnoll411/", INPR+"gnoll4123/",
INPR+"gnoll41316/", INPR+"gnoll41339/",
INPR+"gnoll41350/", INPR+"gnoll41352/",
INPR+"gnoll42016/"],
"ace" : [INPR+"ace/"],
"hackm" : [INPR+"hackem100/", INPR+"hackem110/",
INPR+"hackem114/", INPR+"hackem120/",
INPR+"hackem122/", INPR+"hackem130/",
INPR+"hackem131/", INPR+"hackem132/"],
"dyn" : [INPR+"dyn/"]}
# for !whereis
whereis = {"nh343": [FILEROOT+"nh343-hdf/var/whereis/"],
"nh363": [FILEROOT+"nh363-hdf/var/whereis/"],
"nh370": [FILEROOT+"nh370.16-hdf/var/whereis/",
FILEROOT+"nh370.17-hdf/var/whereis/",
FILEROOT+"nh370.18-hdf/var/whereis/",
FILEROOT+"nh370.20-hdf/var/whereis/",
FILEROOT+"nh370.22-hdf/var/whereis/",
FILEROOT+"nh370.23-hdf/var/whereis/",
FILEROOT+"nh370.27-hdf/var/whereis/",
FILEROOT+"nh370.28-hdf/var/whereis/",
FILEROOT+"nh370.29-hdf/var/whereis/",
FILEROOT+"nh370.30-hdf/var/whereis/",
FILEROOT+"nh370.31-hdf/var/whereis/",
FILEROOT+"nh370.32-hdf/var/whereis/",
FILEROOT+"nh370.35-hdf/var/whereis/",
FILEROOT+"nh370.36-hdf/var/whereis/",
FILEROOT+"nh370.38-hdf/var/whereis/",
FILEROOT+"nh370.39-hdf/var/whereis/",
FILEROOT+"nh370.40-hdf/var/whereis/",
FILEROOT+"nh370.42-hdf/var/whereis/",
FILEROOT+"nh370.43-hdf/var/whereis/",
FILEROOT+"nh370.46-hdf/var/whereis/",
FILEROOT+"nh370.47-hdf/var/whereis/",
FILEROOT+"nh370.50-hdf/var/whereis/",
FILEROOT+"nh370.51-hdf/var/whereis/",
FILEROOT+"nh370.53-hdf/var/whereis/",
FILEROOT+"nh370.58-hdf/var/whereis/",
FILEROOT+"nh370.59-hdf/var/whereis/",
FILEROOT+"nh370.60-hdf/var/whereis/",
FILEROOT+"nh370.61-hdf/var/whereis/",
FILEROOT+"nh370.62-hdf/var/whereis/",
FILEROOT+"nh370.64-hdf/var/whereis/",
FILEROOT+"nh370.65-hdf/var/whereis/",
FILEROOT+"nh370.66-hdf/var/whereis/",
FILEROOT+"nh370.69-hdf/var/whereis/",
FILEROOT+"nh370.70-hdf/var/whereis/",
FILEROOT+"nh370.71-hdf/var/whereis/",
FILEROOT+"nh370.73-hdf/var/whereis/",
FILEROOT+"nh370.78-hdf/var/whereis/",
FILEROOT+"nh370.80-hdf/var/whereis/",
FILEROOT+"nh370.82-hdf/var/whereis/",
FILEROOT+"nh370.83-hdf/var/whereis/",
FILEROOT+"nh370.84-hdf/var/whereis/",
FILEROOT+"nh370.86-hdf/var/whereis/",
FILEROOT+"nh370.87-hdf/var/whereis/",
FILEROOT+"nh370.88-hdf/var/whereis/",
FILEROOT+"nh370.89-hdf/var/whereis/",
FILEROOT+"nh370.90-hdf/var/whereis/",
FILEROOT+"nh370.94-hdf/var/whereis/",
FILEROOT+"nh370.95-hdf/var/whereis/",
FILEROOT+"nh370.97-hdf/var/whereis/",
FILEROOT+"nh370.101-hdf/var/whereis/",
FILEROOT+"nh370.102-hdf/var/whereis/",
FILEROOT+"nh370.103-hdf/var/whereis/",
FILEROOT+"nh370.105-hdf/var/whereis/",
FILEROOT+"nh370.106-hdf/var/whereis/",
FILEROOT+"nh370.107-hdf/var/whereis/",
FILEROOT+"nh370.110-hdf/var/whereis/",
FILEROOT+"nh370.112-hdf/var/whereis/"],
"gh": [FILEROOT+"grunthack-0.2.4/var/whereis/",
FILEROOT+"grunthack-0.3.0/var/whereis/"],
"dnh": [FILEROOT+"dnethack-3.17.1/whereis/",
FILEROOT+"dnethack-3.18.0/whereis/",
FILEROOT+"dnethack-3.19.0/whereis/",
FILEROOT+"dnethack-3.19.1/whereis/",
FILEROOT+"dnethack-3.20.0/whereis/",
FILEROOT+"dnethack-3.21.0/whereis/",
FILEROOT+"dnethack-3.21.1/whereis/",
FILEROOT+"dnethack-3.21.2/whereis/",
FILEROOT+"dnethack-3.21.3/whereis/",
FILEROOT+"dnethack-3.21.4/whereis/",
FILEROOT+"dnethack-3.22.0/whereis/",
FILEROOT+"dnethack-3.23.0/whereis/"],
"fh": [FILEROOT+"fiqhackdir/data/"],
"dyn": [FILEROOT+"dynahack/dynahack-data/var/whereis/"],
"nh4": [FILEROOT+"nh4dir/save/whereis/"],
"4k": [FILEROOT+"fourkdir/save/",
FILEROOT+"fourkdir-4.3.0.5/save/"],
"sp": [FILEROOT+"sporkhack-0.6.5/var/",
FILEROOT+"sporkhack-0.7.0/var/"],
"xnh": [FILEROOT+"xnethack-0.4.0/var/whereis/",
FILEROOT+"xnethack-0.4.1/var/whereis/",
FILEROOT+"xnethack-5.0/var/whereis/",
FILEROOT+"xnethack-5.1/var/whereis/",
FILEROOT+"xnethack-5.1.1/var/whereis/",
FILEROOT+"xnethack-5.1.2/var/whereis/",
FILEROOT+"xnethack-5.1.3/var/whereis/",
FILEROOT+"xnethack-6.0.0/var/whereis/",
FILEROOT+"xnethack-6.1.0/var/whereis/",
FILEROOT+"xnethack-6.2.0/var/whereis/",
FILEROOT+"xnethack-6.3.0/var/whereis/",
FILEROOT+"xnethack-7.0.0/var/whereis/",
FILEROOT+"xnethack-7.0.0.1/var/whereis/",
FILEROOT+"xnethack-7.1.0/var/whereis/",
FILEROOT+"xnethack-8.0.0/var/whereis/",
FILEROOT+"xnethack-8.0.0.1/var/whereis/"],
"spl": [FILEROOT+"splicehack-0.6.3/var/whereis/",
FILEROOT+"splicehack-0.6.4/var/whereis/",
FILEROOT+"splicehack-0.7.0/var/whereis/",
FILEROOT+"splicehack-0.7.1/var/whereis/",
FILEROOT+"splicehack-0.7.1-21/var/whereis/",
FILEROOT+"splicehack-0.8.0/var/whereis/",
FILEROOT+"splicehack-0.8.1/var/whereis/",
FILEROOT+"splicehack-0.8.2/var/whereis/",
FILEROOT+"splicehack-1.0.0/var/whereis/",
FILEROOT+"splicehack-1.1.0/var/whereis/",
FILEROOT+"splicehack-1.2.0/var/whereis/"],
"nh13d": [FILEROOT+"nh13d/whereis/"],
"slshm": [FILEROOT+"slashem-0.0.8E0F2/whereis/"],
"ndnh": [FILEROOT+"notdnethack-2019.05.24/whereis/",
FILEROOT+"notdnethack-2019.12.24/whereis/",
FILEROOT+"notdnethack-2020.04.16/whereis/",
FILEROOT+"notdnethack-2021.05.21/whereis/",
FILEROOT+"notdnethack-2022.03.22/whereis/",
FILEROOT+"notdnethack-2022.05.30/whereis/",
FILEROOT+"notdnethack-2022.09.18/whereis/",
FILEROOT+"notdnethack-2023.05.15/whereis/",
FILEROOT+"notdnethack-2024.05.15/whereis/"],
"nndnh": [FILEROOT+"notnotdnethack-2024.05.15/whereis/"],
"evil": [FILEROOT+"evilhack-0.4.0/var/whereis/",
FILEROOT+"evilhack-0.4.1/var/whereis/",
FILEROOT+"evilhack-0.4.2/var/whereis/",
FILEROOT+"evilhack-0.5.0/var/whereis/",
FILEROOT+"evilhack-0.6.0/var/whereis/",
FILEROOT+"evilhack-0.7.0/var/whereis/",
FILEROOT+"evilhack-0.7.1/var/whereis/",
FILEROOT+"evilhack-0.8.0/var/whereis/",
FILEROOT+"evilhack-0.8.1/var/whereis/",
FILEROOT+"evilhack-0.8.2/var/whereis/",
FILEROOT+"evilhack-0.8.3/var/whereis/",
FILEROOT+"evilhack-0.8.4/var/whereis/"],
"tnnt": [FILEROOT+"tnnt/var/whereis/"],
"nhthon": [FILEROOT+"nethackathon/var/whereis/"],
"slth": [FILEROOT+"slashthem-0.9.5/whereis/",
FILEROOT+"slashthem-0.9.6/whereis/",
FILEROOT+"slashthem-0.9.7/whereis/"],
"gnoll": [FILEROOT+"gnollhack-4.1.2.3/var/whereis/",
FILEROOT+"gnollhack-4.1.3.16/var/whereis/",
FILEROOT+"gnollhack-4.1.3.39/var/whereis/",
FILEROOT+"gnollhack-4.1.3.50/var/whereis/",
FILEROOT+"gnollhack-4.1.3.52/var/whereis/",
FILEROOT+"gnollhack-4.2.0.16/var/whereis/"],
"hackm": [FILEROOT+"hackem-1.0.0/var/whereis/",
FILEROOT+"hackem-1.1.0/var/whereis/",
FILEROOT+"hackem-1.1.4/var/whereis/",
FILEROOT+"hackem-1.2.0/var/whereis/",
FILEROOT+"hackem-1.2.2/var/whereis/",
FILEROOT+"hackem-1.3.0/var/whereis/",
FILEROOT+"hackem-1.3.1/var/whereis/",
FILEROOT+"hackem-1.3.2/var/whereis/"],
"un": [FILEROOT+"un531/var/unnethack/",
FILEROOT+"un532/var/unnethack/",
FILEROOT+"unnethack-6.0.0/var/unnethack/",
FILEROOT+"unnethack-6.0.1/var/unnethack/",
FILEROOT+"unnethack-6.0.2/var/unnethack/",
FILEROOT+"unnethack-6.0.3/var/unnethack/",
FILEROOT+"unnethack-6.0.4/var/unnethack/",
FILEROOT+"unnethack-6.0.5/var/unnethack/",
FILEROOT+"unnethack-6.0.6/var/unnethack/",
FILEROOT+"unnethack-6.0.7/var/whereis/",
FILEROOT+"unnethack-6.0.8/var/whereis/",
FILEROOT+"unnethack-6.0.9/var/whereis/",
FILEROOT+"unnethack-6.0.10/var/whereis/",
FILEROOT+"unnethack-6.0.11/var/whereis/",
FILEROOT+"unnethack-6.0.12/var/whereis/"]}
dungeons = {"nh343": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"nh363": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"nh370": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"gh": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"dnh": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","Law Quest",
"Neutral Quest","The Lost Cities","Chaos Quest","The Quest",
"Sokoban","Fort Ludios","The Lost Tomb","The Sunless Sea",
"The Temple of Moloch","The Dispensary","Vlad's Tower",
"The Elemental Planes"],
"ndnh": ["The Dungeons of Doom","Gehennom","Nowhere","The Collapsed Mineshaft",
"The Gnomish Mines","The Ice Caves","The Black Forest","The Dismal Swamp",
"The Archipelago","Law Quest","Neutral Quest","The Lost Cities","Chaos Quest",
"The Quest","Lokoban","Fort Ludios","The Void","Sacristy","The Lost Tomb",
"The Sunless Sea","The Temple of Moloch","The Dispensary","The Spire",
"Vlad's Tower","The Elemental Planes"],
"nndnh": ["The Dungeons of Doom","Gehennom","Nowhere","The Collapsed Mineshaft",
"The Gnomish Mines","The Ice Caves","The Black Forest","The Dismal Swamp",
"The Archipelago","Law Quest","Neutral Quest","The Lost Cities","Chaos Quest",
"The Quest","Lokoban","Fort Ludios","The Void","Sacristy","The Lost Tomb",
"The Sunless Sea","The Temple of Moloch","The Dispensary","The Spire",
"Vlad's Tower","The Elemental Planes"],
"fh": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"dyn": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Town","Fort Ludios","One-eyed Sam's Market","Vlad's Tower",
"The Dragon Caves","The Elemental Planes","Advent Calendar"],
"nh4": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"4k": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Advent Calendar","Vlad's Tower",
"The Elemental Planes"],
"sp": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"xnh": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"spl": ["The Dungeons of Doom","The Void","The Icy Wastes","The Dark Forest",
"Mysterious Laboratory","Gehennom","The Gnomish Mines","Banquet Hall",
"The Quest","Sokoban","One-eyed Sam's Market",
"Fort Ludios","Vlad's Tower","The Elemental Planes"],
"nh13d": ["The Dungeons of Doom"],
"slshm": ["The Dungeons of Doom","Gehennom","The Gnomish Mines",
"The Quest","Sokoban","Town","Fort Ludios",
"One-eyed Sam's Market","Vlad's Tower","The Dragon Caves",
"The Elemental Planes"],
"slth": ["The Dungeons of Doom","Gehennom","The Gnomish Mines",
"The Quest","Sokoban","Town","Grund's Stronghold","Fort Ludios","The Wyrm Caves",
"One-eyed Sam's Market","The Lost Tomb","The Spider Caves","The Sunless Sea",
"The Temple of Moloch","The Giant Caverns","Vlad's Tower","Frankenstein's Lab",
"The Elemental Planes"],
"tnnt": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","DevTeam's Office","Deathmatch Arena",
"Vlad's Tower","The Elemental Planes"],
"nhthon": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","DevTeam's Office","Deathmatch Arena",
"Vlad's Tower","The Elemental Planes"],
"evil": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","Goblin Town",
"The Quest","Sokoban","Fort Ludios","The Ice Queen's Realm","The Hidden Dungeon",
"Vecna's Domain","Vlad's Tower","Purgatory","The Wizards Tower",
"The Elemental Planes"],
"gnoll": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Large Circular Dungeon",
"The Quest","Sokoban","Fort Ludios","Plane of the Modron","Hellish Pastures",
"Vlad's Tower","The Elemental Planes"],
"ace": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Fort Ludios","Vlad's Tower","The Elemental Planes"],
"hackm": ["The Dungeons of Doom","Gehennom","The Gnomish Mines","The Quest",
"Sokoban","Town","Grund's Stronghold","Fort Ludios","The Wyrm Caves",
"One-eyed Sam's Market","The Lost Levels","The Temple of Moloch","Vecna's Domain",
"Vlad's Tower","The Elemental Planes"],
"un": ["The Dungeons of Doom","Gehennom","Sheol","The Gnomish Mines",
"The Quest","Sokoban","Town","The Ruins of Moria","Fort Ludios",
"One-eyed Sam's Market","Vlad's Tower","The Dragon Caves",
"The Elemental Planes","Advent Calendar"]}
# variant related stuff that does not relate to xlogfile processing
rolename = {
# Vanilla
"arc": "archeologist",
"bar": "barbarian",
"cav": "caveman",
"hea": "healer",
"kni": "knight",
"mon": "monk",
"pri": "priest",
"ran": "ranger",
"rog": "rogue",
"sam": "samurai",
"tou": "tourist",
"val": "valkyrie",
"wiz": "wizard",
# NetHack 1.3d Vanilla has a role of 'Elf' as well as 'Fighter' and 'Ninja' (the latter already included below from SlashTHEM roles)
"elf": "elf",
"fig": "fighter",
# Dnh, includes all of vanilla
"ana": "anachrononaut",
"bin": "binder",
"nob": "noble",
"pir": "pirate",
"brd": "troubadour",
"con": "convict",
"mad": "madman",
# Ndnh, includes all of vanilla and dnh
"acu": "illithanachronounbinder",
# Nndnh, includes all of vanilla and dnh, ndnh
"oct": "octopode",
# SpliceHack, includes all of vanilla
"car": "cartomancer",
"dra": "dragon rider",
# Evilhack, includes all of vanilla
"inf": "infidel",
# SLASH'EM/SlashTHEM/HackEM
"und": "undead slayer",
"fla": "flame mage",
"ice": "ice mage",
"nec": "necromancer",
"yeo": "yeoman",
"jed": "jedi",
"nin": "ninja",
"unt": "undertaker",
"pal": "paladin",
"loc": "locksmith",
"cor": "corsair",
"chf": "chef",
"fir": "firefighter",
"off": "officer",
"ele": "electric mage",
"aci": "acid mage",
"hac": "hacker",
"gee": "geek",
"dru": "drunk",
"gla": "gladiator",
"div": "diver",
"lun": "lunatic",
"mus": "musician",
"zoo": "zookeeper",
}
racename = {
# Vanilla
"dwa": "dwarf",
"elf": "elf",
"gno": "gnome",
"hum": "human",
"orc": "orc",
# Grunt, includes vanilla
"gia": "giant",
"kob": "kobold",
"ogr": "ogre",
# Dnh, includes vanilla
"clk": "clockwork automaton",
"hlf": "half-dragon",
"inc": "incantifier",
"vam": "vampire",
"yuk": "yuki-onna",
"dro": "drow",
"bat": "chiropteran",
"and": "android",
# Ndnh, includes all of vanilla and dnh
"sal": "salamander",
"eth": "etherealoid",
"ent": "treant",
# 4k, includes vanilla
"scu": "scurrier",
"syl": "sylph",
#SpliceHack, includes vanilla
"inf": "infernal",
"mer": "merfolk",
#EvilHack, includes vanilla
"cen": "centaur",
"hob": "hobbit",
"ith": "illithid",
"trt": "tortle",
"dra": "draugr",
#SLASH'EM/Hack'EM
"dop": "doppelganger",
"lyc": "lycanthrope",
#SlashTHEM
"ill": "illithid",
"nym": "nymph",
"tro": "troll",
"gul": "ghoul",
}
# save typing these out in multiple places
vanilla_roles = ["arc","bar","cav","hea","kni","mon","pri",
"ran","rog","sam","tou","val","wiz"]
vanilla_races = ["dwa","elf","gno","hum","orc"]
# varname: ([aliases],[roles],[races],"github org/role/mainbranch[/subdirs]")
# first alias will be used for !variant
# note this breaks if a player has the same name as an alias
# so don't do that (I'm looking at you, FIQ)
# the github string is used for rumors:
# https://raw.githubusercontent.com/[YOUR STRING HERE]/dat/rumors.fal
# should be a valid url
variants = {"nh343": (["nh343", "nethack", "343"],
vanilla_roles, vanilla_races,
"NHTangles/NetHack/hardfought"),
"nh363": (["nh363", "363", "363-hdf"],
vanilla_roles, vanilla_races,
None),
"nh370": (["nh370", "370", "370-hdf"],
vanilla_roles, vanilla_races,
"NetHack/NetHack/NetHack-3.7"),
"nh13d": (["nh13d", "13d"],
vanilla_roles + ["elf", "fig", "nin"], None,
None), # special hardcoded case because it doesn't behave like the rest
"nh4": (["nethack4", "n4"],
vanilla_roles, vanilla_races,
"NHTangles/nethack4/master/libnethack"),
"gh": (["grunthack", "grunt"],
vanilla_roles, vanilla_races + ["gia", "kob", "ogr"],
"NHTangles/GruntHack/master"),
"dnh": (["dnethack", "dn"],
vanilla_roles
+ ["ana", "bin", "nob", "pir", "brd", "con", "mad"],
vanilla_races
+ ["clk", "con", "bat", "dro", "hlf", "inc", "vam", "swn", "and"],
"Chris-plus-alphanumericgibberish/dNAO/compat-3.22.0"), # not ideal...
"ndnh": (["notdnethack", "ndn"],
vanilla_roles
+ ["ana", "bin", "nob", "pir", "brd", "con", "mad", "acu"],
vanilla_races
+ ["clk", "con", "bat", "dro", "hlf", "inc", "vam", "swn", "and", "sal", "eth", "ent"],
"demogorgon22/notdnethack/master"),
"nndnh": (["notnotdnethack", "nnd"],
vanilla_roles
+ ["ana", "bin", "nob", "pir", "brd", "con", "mad", "acu"],
vanilla_races
+ ["clk", "con", "bat", "dro", "hlf", "inc", "vam", "swn", "and", "sal", "eth", "ent", "oct"],
"k21971/notnotdnethack/master"),
"un": (["unnethack", "unh"],
vanilla_roles + ["con"], vanilla_races,
"unnethack/unnethack/master"),
"xnh": (["xnethack", "xnh"],
vanilla_roles, vanilla_races,
"copperwater/xNetHack/master"),
"spl": (["splicehack", "splice", "spl"],
vanilla_roles + ["con", "pir", "car", "dra"], vanilla_races + ["vam", "inf", "mer"],
"NullCGT/SpliceHack/Master"),
"dyn": (["dynahack", "dyna"],
vanilla_roles + ["con"], vanilla_races + ["vam"],
"tung/DynaHack/unnethack/libnitrohack"), # ???
"fh": (["fiqhack"], # not "fiq" see comment above
vanilla_roles, vanilla_races,
"FredrIQ/fiqhack/development/libnethack"),
"sp": (["sporkhack", "spork"],
vanilla_roles, vanilla_races,
"NHTangles/sporkhack/master"),
"4k": (["nhfourk", "nhf", "fourk"],
vanilla_roles, vanilla_races + ["gia", "scu", "syl"],
"tsadok/nhfourk/master/libnethack"),
"slshm": (["slash", "slash'em", "slshm"],
vanilla_roles + ["fla", "ice", "nec", "und", "yeo"],
vanilla_races + ["dop", "dro", "hob", "lyc", "vam"],
"k21971/SlashEM/master"),
"slth": (["slashthem", "slth"],
vanilla_roles + ["fla", "ice", "nec", "und", "yeo", "jed",
"nin", "unt", "pal", "loc", "cor", "chf",
"fir", "off", "ele", "aci", "hac", "gee",
"dru", "gla", "div", "lun", "mus", "zoo"],
vanilla_races + ["dop", "dro", "hob", "lyc", "vam", "ill", "nym", "tro", "gul"],
"k21971/SlashTHEM/master"),
"tnnt": (["tnnt"],
vanilla_roles, vanilla_races,
None), # no different from vanilla
"nhthon": (["nethackathon", "nhthon"],
vanilla_roles, vanilla_races,
None), # no different from vanilla
"evil": (["evilhack", "evil", "evl"],
vanilla_roles + ["con", "inf"],
vanilla_races + ["cen", "gia", "hob", "ith", "trt", "dro", "dra"],
"k21971/EvilHack/master"),
"ace": (["ace"],
vanilla_roles, vanilla_races,
None), # no different from vanilla
"hackm": (["hackem", "hackm"],
vanilla_roles + ["con", "inf", "fla", "ice", "nec", "und", "yeo", "jed", "pir"],
vanilla_races + ["cen", "gia", "hob", "ith", "trt", "vam", "dop"],
"elunna/hackem/master"),
"gnoll": (["gnoll", "gnollhack"],
vanilla_roles, vanilla_races,
"hyvanmielenpelit/GnollHack/master")}
# variants which support streaks.
streakvars = ["nh343", "nh363", "nh370", "nh13d", "gh", "dnh", "un", "sp", "xnh", "spl", "slshm", "tnnt", "nhthon", "ndnh", "evil", "slth", "ace", "gnoll", "hackm", "nndnh"]
# for !asc statistics - assume these are the same for all variants, or at least the sane ones.
aligns = ["Law", "Neu", "Cha", "Una", "Non"]
genders = ["Mal", "Fem", "Nbn"]
#who is making tea? - bots of the nethack community who have influenced this project.
brethren = ["Rodney", "Athame", "Arsinoe", "Izchak", "TheresaMayBot", "FCCBot", "the late Pinobot", "Announcy", "demogorgon", "the /dev/null/oracle", "NotTheOracle\\dnt", "Croesus", "Hecubus", "Yendor"]
looping_calls = None
# SASL auth nonsense required if we run on AWS
# copied from https://github.com/habnabit/txsocksx/blob/master/examples/tor-irc.py
# irc_CAP and irc_9xx are UNDOCUMENTED.
def connectionMade(self):
self.sendLine('CAP REQ :sasl')
#self.deferred = Deferred()
irc.IRCClient.connectionMade(self)
def irc_CAP(self, prefix, params):
if params[1] != 'ACK' or params[2].split() != ['sasl']:
print('sasl not available')
self.quit('')
sasl_string = '{0}\0{0}\0{1}'.format(self.nickname, self.password)
sasl_b64_bytes = base64.b64encode(sasl_string.encode(encoding='UTF-8',errors='strict'))
self.sendLine('AUTHENTICATE PLAIN')
self.sendLine('AUTHENTICATE ' + sasl_b64_bytes.decode('UTF-8'))
def irc_903(self, prefix, params):
self.sendLine('CAP END')
def irc_904(self, prefix, params):
print('sasl auth failed', params)
self.quit('')
irc_905 = irc_904
def signedOn(self):
self.factory.resetDelay()
self.startHeartbeat()
self.sendLine('MODE {} -R'.format(self.nickname))
if not SLAVE: self.join(CHANNEL)
random.seed()
self.logs = {}
for xlogfile, (variant, delim, dumpfmt) in self.xlogfiles.items():
self.logs[xlogfile] = (self.xlogfileReport, variant, delim, dumpfmt)
for livelog, (variant, delim) in self.livelogs.items():
self.logs[livelog] = (self.livelogReport, variant, delim, "")
self.logs_seek = {}
self.looping_calls = {}
#lastgame shite
self.lastgame = "No last game recorded"
self.lg = {}
self.lastasc = "No last ascension recorded"
self.la = {}
# for populating lg/la per player at boot, we need to track game end times
# variant and variant:player don't need this if we assume the xlogfiles are
# ordered within variant.
self.lge = {}
self.tlastgame = 0
self.lae = {}
self.tlastasc = 0
# streaks
self.curstreak = {}
self.longstreak = {}
for v in self.streakvars:
# curstreak[var][player] = (start, end, length)
self.curstreak[v] = {}
# longstreak - as above
self.longstreak[v] = {}
# ascensions (for !asc)
# "!asc plr var" will give something like Rodney's output.
# "!asc plr" will give breakdown by variant.
# "!asc" or "!asc var" will be as above, assuming requestor's nick.
# asc[var][player][role] = count;
# asc[var][player][race] = count;
# asc[var][player][align] = count;
# asc[var][player][gender] = count;
# assumes 3-char abbreviations for role/race/align/gender, and no overlaps.
# for asc ratio we need total games too
# allgames[var][player] = count;
self.asc = {}
self.allgames = {}
for v in self.variants.keys():
self.asc[v] = {};
self.allgames[v] = {};
# for !tell
try:
self.tellbuf = shelve.open(BOTDIR + "/tellmsg.db", writeback=True)
except:
self.tellbuf = shelve.open(BOTDIR + "/tellmsg", writeback=True, protocol=2)
# for !setmintc
try:
self.plr_tc = shelve.open(BOTDIR + "/plrtc.db", writeback=True)
except:
self.plr_tc = shelve.open(BOTDIR + "/plrtc", writeback=True, protocol=2)
# Commands must be lowercase here.
self.commands = {"ping" : self.doPing,
"time" : self.doTime,
"pom" : self.doPom,
"porn" : self.doPom, #for Elronnd
"hello" : self.doHello,
"beer" : self.doBeer,
"tea" : self.doTea,
"coffee" : self.doTea,
"whiskey" : self.doTea,
"whisky" : self.doTea,
"vodka" : self.doTea,
"rum" : self.doTea,
"tequila" : self.doTea,
"scotch" : self.doTea,
"booze" : self.doTea,
"potion" : self.doTea,
"goat" : self.doGoat,
"lotg" : self.doLotg,
"rng" : self.doRng,
"role" : self.doRole,
"race" : self.doRace,
"variant" : self.doVariant,
"tell" : self.takeMessage,
"source" : self.doSource,
"lastgame" : self.multiServerCmd,
"lastasc" : self.multiServerCmd,
"scores" : self.doScoreboard,
"sb" : self.doScoreboard,
"rcedit" : self.doRCedit,
"commands" : self.doCommands,
"help" : self.doHelp,
"coltest" : self.doColTest,
"players" : self.multiServerCmd,
"who" : self.multiServerCmd,
"asc" : self.multiServerCmd,
"streak" : self.multiServerCmd,
"whereis" : self.multiServerCmd,
"8ball" : self.do8ball,
"setmintc" : self.multiServerCmd,
"rumor" : self.doRumor,
"rumour" : self.doRumor,
# these ones are for control messages between master and slaves
# sender is checked, so these can't be used by the public
"#q#" : self.doQuery,
"#r#" : self.doResponse}
# commands executed based on contents of #Q# message
self.qCommands = {"players" : self.getPlayers,
"who" : self.getPlayers,
"whereis" : self.getWhereIs,
"asc" : self.getAsc,
"streak" : self.getStreak,
"lastasc" : self.getLastAsc,
"lastgame": self.getLastGame,
"setmintc": self.setPlrTC}
# callbacks to run when all slaves have responded
self.callBacks = {"players" : self.outPlayers,
"who" : self.outPlayers,
"whereis" : self.outWhereIs,
"asc" : self.outAscStreak,
"streak" : self.outAscStreak,
# TODO: timestamp these so we can report the very last one
# For now, use the !asc/!streak callback as it's generic enough
"lastasc" : self.outAscStreak,
"lastgame": self.outAscStreak,
"setmintc": self.outPlrTC}
# checkUsage outputs a message and returns false if input is bad
# returns true if input is ok
self.checkUsage ={"whereis" : self.usageWhereIs,
"asc" : self.usageAsc,
"streak" : self.usageStreak,
#"lastgame": self.usageLastGame,
#"lastasc" : self.usageLastAsc,
"setmintc": self.usagePlrTC}
# seek to end of livelogs
for filepath in self.livelogs:
with filepath.open("r") as handle:
handle.seek(0, 2)
self.logs_seek[filepath] = handle.tell()
# sequentially read xlogfiles from beginning to pre-populate lastgame data.
for filepath in self.xlogfiles:
with filepath.open("r") as handle:
for line in handle.readlines():
delim = self.logs[filepath][2]
game = parse_xlogfile_line(line, delim)
game["variant"] = self.logs[filepath][1]
if game["variant"] == "fh":
game["dumplog"] = fixdump(game["dumplog"])
if game["variant"] == "nh4":
game["dumplog"] = fixdump(game["dumplog"])
game["dumpfmt"] = self.logs[filepath][3]
for line in self.logs[filepath][0](game,False):