-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbot.py
More file actions
1522 lines (1446 loc) · 63.7 KB
/
bot.py
File metadata and controls
1522 lines (1446 loc) · 63.7 KB
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/python3
# Mode60 https://m0de-60.github.io/web - SDH1.1.4 Final
# ABOUT INFO# ==========================================================================================================
# Title..........: Super DuckHunt v1.1.4 Python IRC Bot
# File...........: bot.py (bot script dependant functions)
# Python version.: v3.12.0 (does not work in older versions)
# Script version.: v1.1.4
# Language.......: English
# Description....: This is a function module used for Super DuckHunt.
# ======================================================================================================================
from configparser import RawConfigParser
from configparser import ConfigParser
import configparser
import re
import time
import random
# CURRENT FUNCTIONS LIST - SEE FUNCTION SECTION FOR DESCRIPTIONS =======================================================
# cnfcleanup
# data_check
# duckinfo
# iecheck
# inveffect
# isaccess
# isbotmaster
# resetdef
# resetshot
# searchthebushes
# shopprice
# timeconvertmsg
# tshotplus
# userdat
# ======================================================================================================================
# noinspection PySimplifyBooleanCheck
# debugging function
def debug(mode, data):
if mode == '0':
print('DEBUG: ' + str(data))
return
if mode != '0':
print(str(mode) + ': ' + str(data))
return
# FUNCTION #============================================================================================================
# Name...........: cnfcleanup
# Description....: routine maintenance procedure for duckhunt.cnf
# Syntax.........: cnfcleanup()
# Parameters.....: None
# Return values..: None
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def cnfcleanup():
parser = RawConfigParser()
parser.read('duckhunt.cnf')
for name, value in parser.items('expl_ammo'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'expl_ammo', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('sabotage'):
datkey = '%s' % name
cnfdelete('duckhunt.cnf', 'sabotage', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('trigger_lock'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'trigger_lock', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('bread_lock'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'bread_lock', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('duck_jam'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'duck_jam', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('gun_grease'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'gun_grease', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'gun_grease', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if float(timem) >= float(hour24()):
cnfdelete('duckhunt.cnf', 'gun_grease', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('silencer'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'silencer', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'silencer', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'silencer', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('lucky_charm'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'lucky_charm', str(datkey))
continue
dat = gettok(cnfread('duckhunt.cnf', 'lucky_charm', str(datkey)), 0, ',')
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'lucky_charm', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('sunglasses'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'sunglasses', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'sunglasses', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'sunglasses', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('accident_insurance'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'accident_insurance', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'accident_insurance', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'accident_insurance', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('rain_coat'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'rain_coat', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'rain_coat', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'rain_coat', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('duck_bomb'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'duck_bomb', str(datkey))
continue
dat = gettok(cnfread('duckhunt.cnf', 'duck_bomb', str(datkey)), 0, ',')
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'duck_bomb', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('bedazzled'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'bedazzled', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'bedazzled', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour1()):
cnfdelete('duckhunt.cnf', 'bedazzled', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('soggy'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'soggy', str(datkey))
continue
dat = cnfread('duckhunt.cnf', 'soggy', str(datkey))
timem = time.time() - float(dat)
# print(str(datkey) + ' TIME: ' + str(timem))
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'soggy', str(datkey))
continue
time.sleep(0.1)
for name, value in parser.items('bombed'):
datkey = '%s' % name
if not cnfexists('duckhunt.cnf', 'ducks', str(datkey)):
cnfdelete('duckhunt.cnf', 'bombed', str(datkey))
continue
time.sleep(0.1)
return
# ===> cnfcleanup
# FUNCTION #============================================================================================================
# Name...........: data_check
# Description....: checks and handles items/effects time entries. This function also doubles as invetory/effects
# retreival for !duckstats, and used to determine if user has certain item in their inventory,
# replacing the use of b'inv' and b'effects' in duckinfo().
# Syntax.........: data_check(user, idtype, ext)
# Parameters.....: user - username to be checked
# idtype - Time entry idtype (see remarks)
# ext - optional extended data (see rmarks)
# Return values..: None specific, True for success and False for failure (in certain parameters)
# Author.........: Neo_Nemesis
# Modified.......:
# Remarks........: Acceptable types: gun_grease, trigger_lock, silencer, lucky_charm, sunglasses
# lucky_charm, rain_coat, soggy, bedazzled (see example)
# Optional Extended data: 'add', 'del', 'get' (see example)
# Example........: data_check('username', 'gun_grease')
# --> this will check for an existing gun_grease timer and if time is spent, removes entry
# data_check('username', 'trigger_lock', 'add')
# --> this will add a trigger_lock time entry for username, existing entries are overwritten.
# data_check('username', 'silencer', 'del')
# --> this will remove a silencer time entry for username, if it exists.
# --> returns False is no entry exists
# data_check('username', 'lucky_charm', 'get')
# --> this will check to see if username has a lucky_charm entry, and returns the value.
# --> returns False is no entry exists
# ======================================================================================================================
def data_check(user, idtype, ext=''):
if ext == 'add':
cnfwrite('duckhunt.cnf', idtype, user, str(time.time()))
return True
elif ext == 'del':
if cnfexists('duckhunt.cnf', idtype, user) is False:
return False
cnfdelete('duckhunt.cnf', idtype, user)
return True
elif ext == 'get':
if cnfexists('duckhunt.cnf', idtype, user) is False:
return False
if cnfexists('duckhunt.cnf', idtype, user) is True:
return cnfread('duckhunt.cnf', idtype, user)
return False
elif ext == '' and cnfexists('duckhunt.cnf', idtype, user):
timem = cnfread('duckhunt.cnf', idtype, user)
# update 1.1.0 - for lucky charm and expansion and duck bomb recode
if numtok(str(timem), ',') > 1:
timem = gettok(str(timem), 0, ',')
# # # ===
timem = time.time() - float(timem)
if idtype == 'gun_grease':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'gun_grease', user)
return
# update 1.1.0 - removed 24 hour parameter for Gun Lock
# if idtype == 'trigger_lock':
# if timem >= float(hour24()):
# cnfdelete('duckhunt.cnf', 'trigger_lock', user)
# return
if idtype == 'silencer':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'silencer', user)
return
# update 1.1.0 - lucky charm change, now stored in token string " time,lcxp "
if idtype == 'lucky_charm':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'lucky_charm', user)
return
if idtype == 'sunglasses':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'sunglasses', user)
return
if idtype == 'accident_insurance':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'accident_insurance', user)
return
if idtype == 'rain_coat':
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'rain_coat', user)
return
# update v1.1.0 - restructured duck bomb code for !bomb recode
if idtype == 'duck_bomb':
bombent = gettok(cnfread('duckhunt.cnf', 'duck_bomb', user), 1, ',')
if int(bombent) == 0 and timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'duck_bomb', user)
return
if int(bombent) > 0 and timem >= float(hour24()):
cnfwrite('duckhunt.cnf', 'duck_bomb', user, str(time.time()) + ',0')
return
if idtype == 'bedazzled':
if timem >= float(hour1()):
cnfdelete('duckhunt.cnf', 'bedazzled', user)
return
if idtype == 'soggy':
if timem >= float(hour1()):
cnfdelete('duckhunt.cnf', 'soggy', user)
return
# explosive ammo, update 1.1.0
if idtype == 'expl_ammo':
if cnfexists('duckhunt.cnf', 'expl_ammo', str(user)):
uself = cnfread('duckhunt.cnf', 'expl_ammo', str(user))
if int(uself) == 0:
cnfdelete('duckhunt.cnf', 'expl_ammo', str(user))
return
# popcorn ammo, update 1.1.0
if idtype == 'popcorn':
if cnfexists('duckhunt.cnf', 'popcorn', str(user)):
popl = cnfread('duckhunt.cnf', 'popcorn', str(user))
if int(popl) == 0:
cnfdelete('duckhunt.cnf', 'popcorn', str(user))
return
# ===> data_check
# FUNCTION #============================================================================================================
# Name...........: duckinfo
# Description....: Returns or changes specified user Duck stats
# Syntax.........: duckinfo(user, req, data)
# Parameters.....: user - username
# req - info to be retreived
# data - optional, new data to be written
# Return values..: Returns specified duck stats
# Successful data write - 1
# Error/unkown command - -1
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def duckinfo(user, req, data=''):
cnfdat = cnfread('duckhunt.cnf', 'ducks', str(user))
if req == b'ammo':
if data == '':
return gettok(cnfdat, 0, ',')
else:
duck_info = reptok(cnfdat, 0, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'ducks':
if data == '':
return gettok(cnfdat, 1, ',')
else:
duck_info = reptok(cnfdat, 1, ',', str(data))
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'gducks':
if data == '':
return gettok(cnfdat, 2, ',')
else:
duck_info = reptok(cnfdat, 2, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'xp':
if data == '':
return gettok(cnfdat, 3, ',')
else:
duck_info = reptok(cnfdat, 3, ',', str(data))
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'level':
if data == '':
return gettok(cnfdat, 4, ',')
else:
duck_info = reptok(cnfdat, 4, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'levelup':
if data == '':
return gettok(cnfdat, 5, ',')
else:
duck_info = reptok(cnfdat, 5, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'effects':
if data == '':
return gettok(cnfdat, 6, ',')
else:
duck_info = reptok(cnfdat, 6, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'inv':
if data == '':
return gettok(cnfdat, 7, ',')
else:
duck_info = reptok(cnfdat, 7, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'guninfo':
if data == '':
return gettok(cnfdat, 8, ',')
else:
duck_info = reptok(cnfdat, 8, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'best':
if data == '':
return gettok(cnfdat, 9, ',')
else:
duck_info = reptok(cnfdat, 9, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'accidents':
if data == '':
return gettok(cnfdat, 10, ',')
else:
duck_info = reptok(cnfdat, 10, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'bread':
if data == '':
return gettok(cnfdat, 11, ',')
else:
duck_info = reptok(cnfdat, 11, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
if req == b'friend':
if data == '':
return gettok(cnfdat, 12, ',')
else:
duck_info = reptok(cnfdat, 12, ',', data)
cnfwrite('duckhunt.cnf', 'ducks', str(user), duck_info)
return 1
return -1
# ===> duckinfo
# FUNCTION #============================================================================================================
# Name...........: iecheck
# Description....: Checks all items/effect time entries and removes any that time result is over the limit
# Syntax.........: iecheck(user)
# Parameters.....: user - username to be checked
# Return values..: None
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def iecheck(user):
if cnfexists('duckhunt.cnf', 'ducks', str(user)) is False:
return
# gun grease check =====================================================================================================
if cnfexists('duckhunt.cnf', 'gun_grease', user) is True:
timem = cnfread('duckhunt.cnf', 'gun_grease', user)
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'gun_grease', user)
# Gun Lock check ===================================================================================================
# update 1.1.0 - removed 24 hour parameter and replaced with different parameters
# if cnfexists('duckhunt.cnf', 'trigger_lock', user) is True:
# timem = cnfread('duckhunt.cnf', 'trigger_lock', user)
# timem = time.time() - float(timem)
# if timem >= float(hour24()):
# cnfdelete('duckhunt.cnf', 'trigger_lock', user)
# silencer check =======================================================================================================
if cnfexists('duckhunt.cnf', 'silencer', user) is True:
timem = cnfread('duckhunt.cnf', 'silencer', user)
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'silencer', user)
# lucky charm check ====================================================================================================
# update 1.1.0 - lucky charm now stored as token string " time,lcxp "
if cnfexists('duckhunt.cnf', 'lucky_charm', user) is True:
timem = gettok(cnfread('duckhunt.cnf', 'lucky_charm', user), 0, ',')
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'lucky_charm', user)
# sunglasses check =====================================================================================================
if cnfexists('duckhunt.cnf', 'sunglasses', user) is True:
timem = cnfread('duckhunt.cnf', 'sunglasses', user)
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'sunglasses', user)
# accident insurance check =============================================================================================
if cnfexists('duckhunt.cnf', 'accident_insurance', user) is True:
timem = cnfread('duckhunt.cnf', 'accident_insurance', user)
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'accident_insurance', user)
# rain coat check ======================================================================================================
if cnfexists('duckhunt.cnf', 'rain_coat', user) is True:
timem = cnfread('duckhunt.cnf', 'rain_coat', user)
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'rain_coat', user)
# duck bomb check ======================================================================================================
# update 1.1.0 restructured duck bomb for !bomb recode ENTRY: b'username' = time,X
# X = bomb uses, if X = 0 then no bombs for 24 hrs
if cnfexists('duckhunt.cnf', 'duck_bomb', user) is True:
bombent = gettok(cnfread('duckhunt.cnf', 'duck_bomb', user), 1, ',')
if int(bombent) == 0:
timem = gettok(cnfread('duckhunt.cnf', 'duck_bomb', user), 0, ',')
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfdelete('duckhunt.cnf', 'duck_bomb', user)
if int(bombent) > 0:
timem = gettok(cnfread('duckhunt.cnf', 'duck_bomb', user), 0, ',')
timem = time.time() - float(timem)
if timem >= float(hour24()):
cnfwrite('duckhunt.cnf', 'duck_bomb', user, str(time.time()) + ',0')
# soggy check ==========================================================================================================
if cnfexists('duckhunt.cnf', 'soggy', user) is True:
timem = cnfread('duckhunt.cnf', 'soggy', user)
timem = time.time() - float(timem)
if timem >= float(hour1()):
cnfdelete('duckhunt.cnf', 'soggy', user)
# bedazzled check ======================================================================================================
if cnfexists('duckhunt.cnf', 'bedazzled', user) is True:
timem = cnfread('duckhunt.cnf', 'bedazzled', user)
timem = time.time() - float(timem)
if timem >= float(hour1()):
cnfdelete('duckhunt.cnf', 'bedazzled', user)
# expl ammo check ======================================================================================================
# update 1.1.0
if cnfexists('duckhunt.cnf', 'expl_ammo', user) is True:
expl = cnfread('duckhunt.cnf', 'expl_ammo', user)
if int(expl) == 0:
cnfdelete('duckhunt.cnf', 'expl_ammo', user)
# popcorn check ========================================================================================================
# update 1.1.0
if cnfexists('duckhunt.cnf', 'popcorn', user) is True:
pop = cnfread('duckhunt.cnf', 'popcorn', user)
if int(pop) == 0:
cnfdelete('duckhunt.cnf', 'popcorn', user)
# ===> iecheck
# FUNCTION #============================================================================================================
# Name...........: inveffect
# Description....: Returns a formatted string for use in !duckstats for inventory and effects display
# Syntax.........: inveffect(user)
# Parameters.....: user - username to be formatted
# Return values..: Returns a formatted string
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def inveffect(user):
huntingbag = '0'
effects = '0'
# gun grease
data_check(str(user), 'gun_grease')
if cnfexists('duckhunt.cnf', 'gun_grease', str(user)) is True:
huntingbag = '\x037,1Gun Grease'
# gun lock
if cnfexists('duckhunt.cnf', 'trigger_lock', str(user)) is True:
invuse = cnfread('duckhunt.cnf', 'trigger_lock', str(user))
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 ' + 'Gun Lock \x034,1[' + str(invuse) + ']'
if huntingbag == '0':
huntingbag = '\x037,1Gun Lock\x034,1 [' + str(invuse) + ']'
# silencer
data_check(str(user), 'silencer')
if cnfexists('duckhunt.cnf', 'silencer', str(user)) is True:
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 ' + 'Silencer'
if huntingbag == '0':
huntingbag = '\x037,1Silencer'
# lucky charm
data_check(str(user), 'lucky_charm')
if cnfexists('duckhunt.cnf', 'lucky_charm', str(user)) is True:
invuse = gettok(cnfread('duckhunt.cnf', 'lucky_charm', str(user)), 1, ',')
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 Lucky Charm \x034,1[+' + str(invuse) + 'xp]'
if huntingbag == '0':
huntingbag = '\x037,1Lucky Charm \x034,1[+' + str(invuse) + 'xp]'
# sunglasses
data_check(str(user), 'sunglasses')
if cnfexists('duckhunt.cnf', 'sunglasses', str(user)) is True:
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 ' + 'Sunglasses'
if huntingbag == '0':
huntingbag = '\x037,1Sunglasses'
# accident insurance
data_check(str(user), 'accident_insurance')
if cnfexists('duckhunt.cnf', 'accident_insurance', str(user)) is True:
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 ' + 'Accident Insurance'
if huntingbag == '0':
huntingbag = '\x037,1Accident Insurance'
# rain coat
data_check(str(user), 'rain_coat')
if cnfexists('duckhunt.cnf', 'rain_coat', str(user)) is True:
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 ' + 'Rain Coat'
if huntingbag == '0':
huntingbag = '\x037,1Rain Coat'
# v.1.1.0 for bread expansion
if cnfexists('duckhunt.cnf', 'bread_lock', str(user)) is True:
invuse = cnfread('duckhunt.cnf', 'bread_lock', str(user))
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 Bread Box Lock \x034,1[' + str(invuse) + ']'
if huntingbag == '0':
huntingbag = '\x037,1Bread Box Lock \x034,1[' + str(invuse) + ']'
# v.1.1.0 expl ammo
data_check(str(user), 'expl_ammo')
if cnfexists('duckhunt.cnf', 'expl_ammo', str(user)) is True:
expl = cnfread('duckhunt.cnf', 'expl_ammo', str(user))
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 Explosive Ammo \x034,1[' + str(expl) + ']'
if huntingbag == '0':
huntingbag = '\x037,1Explosive Ammo \x034,1[' + str(expl) + ']'
# v.1.1.0 bag of popcorn
data_check(str(user), 'popcorn')
if cnfexists('duckhunt.cnf', 'popcorn', str(user)) is True:
pop = cnfread('duckhunt.cnf', 'popcorn', str(user))
if huntingbag != '0':
huntingbag = huntingbag + ' \x030,1|\x037,1 Bag of Popcorn \x034,1[' + str(pop) + ']'
if huntingbag == '0':
huntingbag = '\x037,1Bag of Popcorn \x034,1[' + str(pop) + ']'
# assemble hunting bag
if huntingbag != '0':
huntingbag = '\x030,1[HUNTING BAG] ' + huntingbag
if huntingbag == '0':
huntingbag = '\x030,1[HUNTING BAG]\x034,1 None'
# bedazzled
data_check(str(user), 'bedazzled')
if cnfexists('duckhunt.cnf', 'bedazzled', str(user)) is True:
if effects != '0':
effects = effects + ' \x030,1|\x037,1 ' + 'Bedazzled'
if effects == '0':
effects = '\x037,1Bedazzled'
# soggy
data_check(str(user), 'soggy')
if cnfexists('duckhunt.cnf', 'soggy', str(user)) is True:
if effects != '0':
effects = effects + ' \x030,1|\x037,1 ' + 'Soggy'
if effects == '0':
effects = '\x037,1Soggy'
# sabotaged
if cnfexists('duckhunt.cnf', 'sabotage', str(user)) is True:
if effects != '0':
effects = effects + ' \x030,1|\x037,1 ' + 'Sabotage'
if effects == '0':
effects = '\x037,1Sabotage'
# bombed
if cnfexists('duckhunt.cnf', 'bombed', str(user)) is True:
if effects != '0':
effects = effects + ' \x030,1|\x037,1 Duck Bombed'
if effects == '0':
effects = '\x037,1Duck Bombed'
# assemble effects box
if effects != '0':
effects = '\x030,1[EFFECTS] ' + effects
if effects == '0':
effects = '\x030,1[EFFECTS]\x034,1 None'
# return formatted message
return huntingbag + '::' + effects
# ===> inveffect
# FUNCTION #============================================================================================================
# Name...........: isaccess
# Description....: checks if user has bot access to botmaster and/or admin
# Syntax.........: isaccess(user)
# Parameters.....: user - username to be checked
# Return values..: Returns True - user exists in botmaster or admin list
# Returns False - user does not exist in botmaster or admin list
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def isaccess(user):
# print(user)
admin = cnfread('duckhunt.cnf', 'duckhunt', 'admin')
# print(admin)
botmaster = cnfread('duckhunt.cnf', 'duckhunt', 'botmaster')
# print(botmaster)
if istok(str(admin), str(user), ',') is True:
return True
if istok(str(botmaster), str(user), ',') is True:
return True
return False
# ===> isaccess
# FUNCTION #============================================================================================================
# Name...........: resetdef
# Description....: Restores duckhunt.cnf to pre-configured original settings
# Syntax.........: resetdef()
# Parameters.....: None
# Return values..: None
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def resetdef():
cnfwrite('duckhunt.cnf', 'duckhunt', 'maxducks', '6')
global maxducks
maxducks = 6
cnfwrite('duckhunt.cnf', 'duckhunt', 'spawntime', '1800')
global spawntime
spawntime = 1800
cnfwrite('duckhunt.cnf', 'duckhunt', 'flytime', '1500')
global flytime
flytime = 1500
cnfwrite('duckhunt.cnf', 'duckhunt', 'duckexp', '15')
global duckexp
duckexp = 15
cnfwrite('duckhunt.cnf', 'duckhunt', 'duckfear', '45')
global duckfear
duckfear = 45
cnfwrite('duckhunt.cnf', 'duckhunt', 'duckgold', '40')
global duckgold
duckgold = 40
cnfwrite('duckhunt.cnf', 'duckhunt', 'friendrate', '70')
global friendrate
friendrate = 71
cnfwrite('duckhunt.cnf', 'duckhunt', 'floodcheck', '10,8')
global flood_check
flood_check = True
cnfwrite('duckhunt.cnf', 'rules', 'gunricochet', '5')
global gunricochet
gunricochet = 5
cnfwrite('duckhunt.cnf', 'rules', 'thebushes', '15')
global thebushes
thebushes = 15
cnfwrite('duckhunt.cnf', 'rules', 'gunconf', 'on')
global gunconf
gunconf = 'on'
cnfwrite('duckhunt.cnf', 'rules', 'infammo', 'off')
global infammo
infammo = 'off'
cnfwrite('duckhunt.cnf', 'rules', 'bang', 'on')
global bang
bang = 'on'
cnfwrite('duckhunt.cnf', 'rules', 'bef', 'on')
global bef
bef = 'on'
cnfwrite('duckhunt.cnf', 'duckhunt', 'maint', '24')
global maint
maint = '24'
cnfwrite('duckhunt.cnf', 'duckhunt', 'maint_time', str(time.time()))
global maint_time
maint_time = str(time.time())
time.sleep(0.10)
parser = RawConfigParser()
parser.read('duckhunt.cnf')
for name, value in parser.items('flood_protection'):
datkey = '%s' % name
cnfdelete('duckhunt.cnf', 'flood_protection', str(datkey))
continue
time.sleep(0.10)
cnfwrite('duckhunt.cnf', 'flood_protection', '!bang', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!duckstats', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!shop', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!bef', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!reload', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!bomb', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!tshot', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!mshot', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!help', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!swim', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!wshot', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!dshot', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!about', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!topduck', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!reloaf', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '!bread', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '\x01version\x01', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '\x01finger\x01', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', '\x01ping', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', 'version', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', 'finger', 'True')
cnfwrite('duckhunt.cnf', 'flood_protection', 'ping', 'True')
time.sleep(0.10)
resetshot()
time.sleep(0.10)
statreset()
return
# ===> resetdef
# FUNCTION #============================================================================================================
# Name...........: resetshot
# Description....: Resets total shot counter data
# Syntax.........: resetshot()
# Parameters.....: None
# Return values..: None
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def resetshot():
cnfwrite('duckhunt.cnf', 'top_shot', 'daily', '0')
global daily
daily = '0'
cnfwrite('duckhunt.cnf', 'top_shot', 'weekly', '0')
global weekly
weekly = '0'
cnfwrite('duckhunt.cnf', 'top_shot', 'monthly', '0')
global monthly
monthly = '0'
cnfwrite('duckhunt.cnf', 'top_shot', 'totalshot', '0')
global totalshot
totalshot = '0'
cnfwrite('duckhunt.cnf', 'top_shot', 't_day', '1')
cnfwrite('duckhunt.cnf', 'top_shot', 't_week', '1')
cnfwrite('duckhunt.cnf', 'top_shot', 't_month', '1')
return
# ===> resetshot
# FUNCTION #============================================================================================================
# Name...........: searchthebushes
# Description....: Function control for searching the bushes
# Syntax.........: searchthebushes(user)
# Parameters.....: user = username of player who is searching
# Return values..: returns a formatted message for searching theb ushes
# Author.........: Neo_Nemesis
# Modified.......:
# ======================================================================================================================
def searchthebushes(user):
srchtxt = 'By searching the bushes around the duck, you find'
ammo = duckinfo(user, b'ammo')
global bang
bang = cnfread('duckhunt.cnf', 'rules', 'bang')
global bef
bef = cnfread('duckhunt.cnf', 'rules', 'bef')
rounds = gettok(ammo, 0, '?')
mrounds = gettok(ammo, 2, '?')
mags = gettok(ammo, 1, '?')
mmags = gettok(ammo, 3, '?')
xp = duckinfo(str(user), b'xp')
srch = random.randint(1, 11)
if int(srch) == 1 or int(srch) == 3 or int(srch) == 5 or int(srch) == 6 or int(srch) == 7 or int(srch) == 8 or int(srch) == 11:
srch = random.randrange(1, 11, 1)
if int(srch) == 1:
return str(srchtxt) + ' a broken Lucky Charm. \x033Better luck next time.\x03'
if int(srch) == 2:
return str(srchtxt) + ' a fishing weight. \x033Better luck next time.\x03'
if int(srch) == 3:
xp = int(xp) + 50
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a duck booklet. \x033[+50 xp]\x03'
if int(srch) == 4:
xp = int(xp) + 5
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a duck feather. \x033[+5 xp]\x03'
if int(srch) == 5:
if int(rounds) == int(mrounds) or bang == 'off':
return str(srchtxt) + ' a rusty fishing lure. \x033Better luck next time.\x03'
if int(rounds) < int(mrounds):
rounds = int(rounds) + 1
ammo = str(rounds) + '?' + str(mags) + '?' + str(mrounds) + '?' + str(mmags)
duckinfo(user, b'ammo', ammo)
return str(srchtxt) + ' an extra bullet. \x033[Rounds: ' + str(rounds) + '/' + str(mrounds) + ' | Magazines: ' + str(mags) + '/' + str(mmags) + '\x03'
if int(srch) == 6:
data_check(str(user), 'lucky_charm')
if cnfexists('duckhunt.cnf', 'lucky_charm', str(user)):
xp = int(xp) + 5
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a duck feather. \x033[+5 xp]\x03'
if not cnfexists('duckhunt.cnf', 'lucky_charm', str(user)):
# found = 'Lucky Charm'
lcxp = random.randint(3, 8)
cnfwrite('duckhunt.cnf', 'lucky_charm', str(user), str(time.time()) + ',' + str(lcxp))
return str(srchtxt) + ' a Lucky Charm. \x033You will earn an extra ' + str(lcxp) + ' xp for every duck for 24 hrs.\x03'
if int(srch) == 7:
# found = 'Golden Duck Feather'
xp = int(xp) + 150
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a golden duck feather. \x033[+150 xp]\x03'
if int(srch) == 8:
# found = 'Frog'
xp = int(xp) + 25
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a frog. * RIBBIT * \x033[+25 xp]\x03'
if int(srch) == 9:
# found = 'Sunglasses'
cnfwrite('duckhunt.cnf', 'sunglasses', str(user), str(time.time()))
return str(srchtxt) + ' a pair of Sunglasses. \x033You are now protected from bedazzlement for 24 hours.\x03'
# future secrets: this second frog will eventually become a fishing pole. Trout master?
if int(srch) == 10:
xp = int(xp) + 25
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a frog. * RIBBIT * \x033[+25 xp]\x03'
if int(srch) == 11:
xp = int(xp) + 175
duckinfo(str(user), b'xp', str(xp))
return str(srchtxt) + ' a duck enthusiast booklet. \x033[+175 xp]\x03'
# ===> searchthebushes
# FUNCTION #============================================================================================================
# Name...........: shopprice
# Description....: Determines price of specified item. CHANGE YOUR PRICE VALUES HERE
# Item prices vary based on user stats, for !shop
# Syntax.........: shopprice(user, itemid)
# Parameters.....: user - name of user who is using !shop
# itemid - !shop ID of the item.
# Return values..: Returns the specified price of the item
# Returns 0 if unknown/invalid itemid specified
# Author.........: Neo_Nemesis
# Remarks........: Update 1.1.0, shop remodel - moved some items, created new items
# more cost handling based on player stats
# Modified.......:
# ======================================================================================================================
def shopprice(user, itemid):
# data prep
ammo = duckinfo(user, b'ammo')
mrounds = gettok(ammo, 2, '?')
mmags = gettok(ammo, 3, '?')
guninfo = duckinfo(user, b'guninfo')
accuracy = gettok(guninfo, 0, '?')
mreliability = gettok(guninfo, 2, '?')
# Extra Bullet
if int(itemid) == 1:
return 7
# Refill Magazine
if int(itemid) == 2:
if int(mrounds) == 7:
return 20
if int(mrounds) == 8:
return 25
if int(mrounds) == 9:
return 30
if int(mrounds) == 10:
return 35
if int(mrounds) >= 11:
return 40
# gun cleaning
if int(itemid) == 3:
if int(mreliability) <= 80:
return 30
if 80 < int(mreliability) < 85:
return 35
if 85 <= int(mreliability) < 90:
return 40
if 90 <= int(mreliability) < 95:
return 45
if 95 <= int(mreliability) <= 100:
return 50
# explosive ammo
if int(itemid) == 4:
return 35
# return confiscated gun
if int(itemid) == 5:
return 30
# gun grease
if int(itemid) == 6:
return 15
# gun uprade
if int(itemid) == 7:
if 90 < int(accuracy) < 100 <= int(mreliability):
return 350
elif int(accuracy) <= 75 and int(mreliability) <= 80:
return 200
elif int(accuracy) > 75 and int(mreliability) > 80:
return 300
else:
return 250
# Gun Lock
if int(itemid) == 8:
if int(mrounds) == 7:
return 25
if int(mrounds) == 8:
return 30
if int(mrounds) == 9:
return 35
if int(mrounds) == 10:
return 40
if int(mrounds) == 11:
return 45
if int(mrounds) >= 12:
return 50
# silencer
if int(itemid) == 9:
return 20
# lucky charm
if int(itemid) == 10:
return 30
# sunglasses