This repository has been archived by the owner on Jul 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
darkmage.tcl
1789 lines (1782 loc) · 55.7 KB
/
darkmage.tcl
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
# $Arch: darkmage.tcl,v 1.040 2018/11/29 12:54:49 kyau Exp $
#
# ▄▄▄ ▄▄▄▄ ▄▄▄▄ ▄▄ ▄ ▄▄ ▄▄▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄
# ██ █ ██ █ ██ █ ██ █ ██ ██ █ █ ██ █ ██ ██ ▀
# ██ █ ██▄█ ██▄▀ ██▄▀ ██ ██ █ █ ██▄█ ██ ▄▄ ██▀
# ██ █ ██ █ ██ █ ██ █ ▀▀ ██ █ █ ██ █ ██ ▀█ ██ █
# ▀▀▀▀ ▀▀ ▀ ▀▀ ▀ ▀▀ ▀ ▀▀ ▀▀ ▀ ▀ ▀▀ ▀ ▀▀▀▀▀ ▀▀▀▀
#
# dark!mage - tcl botpack for eggdrop
# Copyright (C) 2018 KYAU Labs (https://kyaulabs.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
package require Tcl 8.5
package require http 2.9.0
package require tls 1.7.11
http::register https 443 [list ::tls::socket -autoservername true]
set dmver "1.040"
set releasedate "2018.11.29"
# CONFIGURATION {{{
set notify-newusers { "kyau" } ;# users to notify of new users and bots.
logfile 5 * "logs/darkMAGE.log" ;# darkMAGE logfile
set local_control "A" ;# botattr for local bots
set bn_control "*" ;# default botnet control (* is all)
set modes-per-line 4 ;# irc network modes-per-line (EFnet: 4)
set partylinelist 1 ;# display partyline users on dcc connection (0/1)
set bop_opkey "magicmonkey" ;# key used for encrypted ops verification
set bop_modeop 1 ;# requests ops when others get ops (0/1)
set bop_linkop 1 ;# requests ops from other linked bots (0/1)
set bop_icheck 1 ;# perform invite check to get in channels (0/1)
set bop_delay 10 ;# delay between requests for ops
set bop_maxreq 2 ;# maximum simultaneous op requests to send
set bop_osync 0 ;# skip op check when opping
set bop_addhost 0 ;# automatically add hosts to bots to gain ops
set bop_log 2 ;# 0 = no logging
# 1 = log: invite/limit/key/unban
# 2 = log: invite/limit/key/ops/unban
# }}}
# ----- DO NOT EDIT BELOW HERE! ----------------------------------------------- {{{
# }}}
# LOADING TEXT {{{
loadmodule filesys
putlog "\00311darkMAGE\003 \00314v$dmver\003 - \00315kyau\003 \0037<[email protected]>\003"
# }}}
# BINDS AND UNBINDS {{{
catch {unbind dcc o|o +ban *dcc:+ban}
catch {unbind dcc o act *dcc:act}
catch {unbind dcc o msg *dcc:msg}
catch {unbind dcc o say *dcc:say}
catch {unbind dcc - whom *dcc:whom}
catch {unbind dcc - op *dcc:op}
catch {unbind dcc - bots *dcc:bots}
catch {unbind msg - addhost *msg:addhost}
catch {unbind msg - op *msg:op}
bind bot - botnet botnet_proc
bind bot - botnet_chans botnet_channels
bind bot - these_chans these_chans
bind bot - vBOTNET_CHECK_EGGDROP_EXT bot_extcheck
bind bot - vBOTNET_CHECK_EGGDROP_EXT_ACK bot_extcheckack
bind chon - * dcc_chat
bind ctcp - CLIENTINFO bx_ctcp
bind ctcp - USERINFO bx_ctcp
bind ctcp - VERSION bx_ctcp
bind ctcp - FINGER bx_ctcp
bind ctcp - ERRMSG bx_ctcp
bind ctcp - ECHO bx_ctcp
bind ctcp - INVITE bx_ctcp
bind ctcp - WHOAMI bx_ctcp
bind ctcp - OP bx_ctcp
bind ctcp - OPS bx_ctcp
bind ctcp - UNBAN bx_ctcp
bind ctcp - PING bx_ctcp
bind ctcp - TIME bx_ctcp
bind dcc o|o +ban ban:+ban
bind dcc t|- +bot dcc:+bot
bind dcc m|- +user dcc:+user
bind dcc p about dcc_about
bind dcc n act *dcc:act
bind dcc m|m adduser dcc:adduser
bind dcc m autoaway dcc:autoaway
bind dcc n bitchx bx_dccbitchx
bind dcc n botnick dcc_botnick
bind dcc n botnet botnetmsg_proc
bind dcc n bots dcc_bots
bind dcc n botstat dcc_bots
bind dcc n channels cmd_channels
bind dcc - darkmage dm_help
bind dcc - dmhelp dm_help
bind dcc n dolimit dm:dcc:dolimit
bind dcc m|m hostcheck dcc:hostcheck
bind dcc n kill dcc_kill
bind dcc n msg *dcc:msg
bind dcc - op dcc_op
bind dcc n say *dcc:say
bind dcc p sv dcc_about
bind dcc o|o userlist dcc_userlist
bind dcc n vcheck dcc_extcheck
bind dcc p version dcc_about
bind dcc p whom dcc:whomall
bind msg - op msg_op
bind raw - MODE encrypted_opverify
bind time - "57 * * * *" time:keeplinked
bind raw - 001 bx_serverjoin
bind pubm -|- "*youtube.*watch?v=*" yt_info
bind pubm -|- "*youtu.be/*" yt_info
# }}}
# DEFAULT PROCS {{{
proc putbotdcc {idx dcctxt} {
set sysTime [clock seconds]
set dmtime [clock format $sysTime -format %H:%M:%S]
putdcc $idx "\[$dmtime\] \00311darkMAGE\003\00314\037:\037\003 $dcctxt"
}
proc putbotdcclog {logtxt} {
putlog "\00311darkMAGE\003\00314\037:\037\003 $logtxt"
}
proc putbotdccerr {idx errtxt} {
set sysTime [clock seconds]
set dmtime [clock format $sysTime -format %H:%M:%S]
putdcc $idx "\[$dmtime\] \00304ERROR\003\00314\037:\037\003 $errtxt"
}
proc xindex {xr xr1} {
return [join [lrange [split $xr] $xr1 $xr1]]
}
proc xrange {xr xr1 xr2} {
return [join [lrange [split $xr] $xr1 $xr2]]
}
proc xstrcmp {str1 str2} {
if {[string compare [string tolower $str1] [string tolower $str2]] == 0} {
return 1
} else {
return 0
}
}
proc putbotlog {logtxt} {
putloglev 5 "*" "darkMAGE\037:\037 $logtxt"
}
if { [info vars botnet-nick] == "" } {
set bnnick $nick
}
if { [info vars botnet-nick] != "" } {
set bnnick ${botnet-nick}
}
# Encrypted Hash
proc bop_encrypted {thost tnick} {
global bop_opkey
set sysTime [clock seconds]
set thour [clock format $sysTime -gmt true -format %H]
set tbin "md5sum"
if {[exec uname -s] == "OpenBSD"} {
set tbin "md5"
}
#putlog "\00306DEBUG:\003 tbin:{$tbin} thour:{$thour} thost:{$thost} tnick:{$tnick}"
catch {exec echo -n "$thour$thost$tnick$bop_opkey" | $tbin | cut -f 1 -d " "} result
return $result
}
proc time:keeplinked {min hour day month year} {
foreach b [userlist b] {
if {([string match "*h*" "[getuser $b BOTFL]"] || [string match "*a*" "[getuser $b BOTFL]"]) && (![string match "*r*" "[getuser $b BOTFL]"] && ![islinked $b])} {
putbotlog "Keeplinked linking: \002\ $b ...\002\ "
link "$b"
}
}
}
# }}}
# HELP {{{
proc dm_help {hand idx arg} {
global dmver
if {[matchattr $hand n]} {
putdcc $idx "darkMAGE v$dmver"
putdcc $idx "-------------------------------------------------------"
putdcc $idx "commands\037:\037"
putdcc $idx "- autoaway bitchx botnick botstat channels"
putdcc $idx "- dolimit hostcheck kill sv userlist vcheck"
putdcc $idx "- whom"
putdcc $idx "-------------------------------------------------------"
putdcc $idx "botnet commands\037:\037"
putdcc $idx "- act channels chanset control join"
putdcc $idx "- masskick massop massopall massvoice"
putdcc $idx "- massdevoice part rehash save say"
putdcc $idx "- takeover"
putdcc $idx "-------------------------------------------------------"
return 0
} elseif {[matchattr $hand m]} {
putdcc $idx "darkMAGE v$dmver"
putdcc $idx "-------------------------------------------------------"
putdcc $idx "commands\037:\037"
putdcc $idx "- adduser autoaway hostcheck sv userlist"
putdcc $idx "- whom"
putdcc $idx "-------------------------------------------------------"
return 0
} elseif {[matchattr $hand o]} {
putdcc $idx "darkMAGE v$dmver"
putdcc $idx "-------------------------------------------------------"
putdcc $idx "commands\037:\037"
putdcc $idx "- sv userlist whom"
putdcc $idx "-------------------------------------------------------"
return 0
} elseif {[matchattr $hand p]} {
putdcc $idx "darkMAGE v$dmver"
putdcc $idx "-------------------------------------------------------"
putdcc $idx "commands\037:\037"
putdcc $idx "- sv whom"
putdcc $idx "-------------------------------------------------------"
return 0
}
}
# }}}
# TAKEOVER {{{
proc bot_takeover {hand idx arg} {
if {$arg == 0} { return 0 }
set hand2 [xindex $arg 0]
set chan [xindex $arg 1]
if {([validchan $chan]) && ([botonchan $chan]) && ([botisop $chan])} {
putbotlog "taking over $chan ($hand2@$hand)"
putbotdcc $idx "taking over $chan ($hand2@$hand)"
takeover $chan
}
}
proc takeover {chan} {
global modes-per-line
set nicklist [randomize_nicks $chan]
set nicks ""
foreach nick $nicklist {
if {(![isbotnick $nick]) && ([isop $nick $chan]) && (![matchattr [nick2hand $nick $chan] n|n $chan]) && (![matchattr [nick2hand $nick $chan] b])} {
lappend nicks $nick
if {[llength $nicks] >= ${modes-per-line}} {
putquick "MODE $chan -oooo $nicks"
set nicks ""
}
}
}
if {$nicks != ""} {
putquick "MODE $chan -oooo $nicks"
}
}
proc randomize_nicks {chan} {
set nicklist ""
set nicklist2 [chanlist $chan]
while {$nicklist2 != ""} {
set i [rand [llength $nicklist2]]
lappend nicklist [xindex $nicklist2 $i]
set nicklist2 [lreplace $nicklist2 $i $i]
}
return $nicklist
}
# }}}
# MASS COMMANDS {{{
proc masskick {chan} {
if {![botisop $chan]} {
return 0
}
set nicklist [randomize_nicks $chan]
putquick "MODE $chan +im"
foreach nick $nicklist {
if {(![isbotnick $nick]) && (![isop $nick $chan]) && (![matchattr [nick2hand $nick $chan] n|n $chan]) && (![matchattr [nick2hand $nick $chan] b])} {
putquick "KICK $chan $nick :mass kick"
}
}
}
proc massop {chan} {
global modes-per-line
if {![botisop $chan]} {
return 0
}
set nicklist [randomize_nicks $chan]
set nicks ""
foreach nick $nicklist {
if {(![isop $nick $chan]) && ([onchan $nick $chan]) && ([matchattr [nick2hand $nick $chan] o|o $chan]) && (![matchattr [nick2hand $nick $chan] d|d $chan])} {
lappend nicks $nick
if {[llength $nicks] >= ${modes-per-line}} {
putquick "MODE $chan +oooo $nicks"
set nicks ""
}
}
}
if {$nicks != ""} {
putquick "MODE $chan +oooo $nicks"
}
}
proc massopall {chan} {
global modes-per-line
if {![botisop $chan]} {
return 0
}
set nicklist [randomize_nicks $chan]
set nicks ""
foreach nick $nicklist {
if {(![isop $nick $chan]) && ([onchan $nick $chan])} {
lappend nicks $nick
if {[llength $nicks] >= ${modes-per-line}} {
putquick "MODE $chan +oooo $nicks"
set nicks ""
}
}
}
if {$nicks != ""} {
putquick "MODE $chan +oooo $nicks"
}
}
proc massvoice {chan} {
global modes-per-line
if {![botisop $chan]} {
return 0
}
set nicklist [randomize_nicks $chan]
set nicks ""
foreach nick $nicklist {
if {(![isop $nick $chan]) && ([onchan $nick $chan]) && (![isvoice $nick $chan])} {
lappend nicks $nick
if {[llength $nicks] >= ${modes-per-line}} {
putquick "MODE $chan +vvvv $nicks"
set nicks ""
}
}
}
if {$nicks != ""} {
putquick "MODE $chan +vvvv $nicks"
}
}
proc massdevoice {chan} {
global modes-per-line
if {![botisop $chan]} {
return 0
}
set nicklist [randomize_nicks $chan]
set nicks ""
foreach nick $nicklist {
if {(![isop $nick $chan]) && ([onchan $nick $chan]) && ([isvoice $nick $chan])} {
lappend nicks $nick
if {[llength $nicks] >= ${modes-per-line}} {
putquick "MODE $chan -vvvv $nicks"
set nicks ""
}
}
}
if {$nicks != ""} {
putquick "MODE $chan -vvvv $nicks"
}
}
# }}}
# .BOTNET {{{
proc botnetmsg_proc {handle idx args} {
global botnick
set channels [channels]
set bot_count [countbots]
set args [lindex $args 0]
set s_flags [lindex $args 2]
set whattodo [lindex $args 0]
set botmsg [lindex $args 1]
switch -exact $whattodo {
"channels" {
putbots "botnet_chans $idx $args "
putbotdcc $idx "$botnick is on chans: $channels"
}
"control" {
botnet_control $idx $botmsg $s_flags
return
}
"takeover" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "doing takeover on $channame with $bot_count bots "
putbotdcc $idx "doing takeover on $channame with $bot_count bots "
if {[control_mybot $botnick]} {
takeover $channame
}
}
"masskick" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "masskicking on $channame using $bot_count bots "
putbotdcc $idx "masskicking on $channame using $bot_count bots "
if {[control_mybot $botnick]} {
utimer [rand 10] "masskick $channame"
}
}
"massop" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "massopping on $channame using $bot_count bots "
putbotdcc $idx "massopping on $channame using $bot_count bots "
if {[control_mybot $botnick]} {
utimer [rand 10] "massop $channame"
}
}
"massopall" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "massopping on $channame using $bot_count bots "
putbotdcc $idx "massopping all on $channame using $bot_count bots "
if {[control_mybot $botnick]} {
utimer [rand 10] "massopall $channame"
}
}
"massvoice" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "massvoice on $channame using $bot_count bots "
putbotdcc $idx "massvoice on $channame using $bot_count bots "
if {[control_mybot $botnick]} {
utimer [rand 10] "massvoice $channame"
}
}
"massdevoice" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "massdevoice on $channame using $bot_count bots "
putbotdcc $idx "massdevoice on $channame using $bot_count bots "
if {[control_mybot $botnick]} {
utimer [rand 10] "massdevoice $channame"
}
}
"join" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "joining $channame with $bot_count bots"
putbotdcc $idx "joining $channame with $bot_count bots"
if {[control_mybot $botnick]} {
channel add $channame
}
}
"chanset" {
set channame [lindex $args 1]
set settings [lrange $args 2 end]
putbots "botnet $args $handle"
putbotlog "setting $settings on $bot_count bots on channel $channame "
putbotdcc $idx "setting $settings on $bot_count bots on channel $channame "
if {[control_mybot $botnick]} {
catch {eval chanset $channame $settings}
}
}
"part" {
set channame [lindex $args 1]
putbots "botnet $args $handle"
putbotlog "parting $channame with $bot_count bots "
putbotdcc $idx "parting $channame with $bot_count bots "
if {[control_mybot $botnick]} {
catch {channel remove $channame}
}
}
"save" {
putbots "botnet $args $handle"
putbotlog "telling $bot_count bots to save "
putbotdcc $idx "telling $bot_count bots to save "
if {[control_mybot $botnick]} {
save
}
}
"rehash" {
putbots "botnet $args $handle"
putbotlog "telling $bot_count bots to rehash "
putbotdcc $idx "telling $bot_count bots to rehash "
if {[control_mybot $botnick]} {
rehash
}
}
default {
dm_help $handle $idx $args
return
}
}
}
proc botnet_channels {bot cmd args} {
set idx [lindex $args 0]
set channels [channels]
putbot $bot "these_chans $idx $channels"
}
proc these_chans {bot cmd args} {
set args [lindex $args 0]
set idx [lindex $args 0]
set channels [lrange $args 2 end]
putbotdcc $idx "$bot is on chans: $channels"
}
proc countbots {} {
global bn_control botnick
set bot_count 0
if {$bn_control == "*"} {
foreach s_bot [userlist b] {
if {([islinked $s_bot]) || ([string tolower $s_bot] == [string tolower $botnick])} {
set bot_count [expr $bot_count+1]
}
}
} else {
foreach s_bot $bn_control {
if {([islinked $s_bot]) || ([string tolower $s_bot] == [string tolower $botnick])} {
set bot_count [expr $bot_count+1]
}
}
}
return $bot_count
}
proc control_mybot {bot} {
global botnick bn_control
if {$bn_control == "*" } {
return 1
}
if {[lsearch $bn_control $bot] != -1} {
return 1
}
return 0
}
proc putbots {cmd args} {
global bn_control
if {$bn_control == "*"} {
putallbots "$cmd $args"
return
} else {
foreach s_bot $bn_control {
if {[islinked $s_bot]} {
putbot $s_bot "$cmd $args"
}
}
return
}
}
# }}}
# .BOTNET CONTROL {{{
proc botnet_control {idx args s_flags} {
global bn_control local_control botnick
set what [lindex $args 0]
if { $what == "-all"} {
set bn_control "*"
putbotdcc $idx "now controling all bots"
return 1
} elseif {$what == "-flags"} {
set x 0
set bn_control ""
foreach s_bot [userlist $s_flags] {
if {([islinked $s_bot]) || ([string tolower $s_bot] == [string tolower $botnick])} {
lappend bn_control $s_bot
set x [expr $x+1]
}
}
if {$bn_control == ""} {
set bn_control "*"
putbotdcc $idx "Illegal flag or no bots selected. Resetting to default control"
return 1
}
putbotdcc $idx "now controlling $x bots"
return 1
} elseif {$what == "-local"} {
set bn_control [userlist $local_control]
putbotdcc $idx "control set to local bots only "
return 1
} elseif {$what == "-list"} {
putbotdcc $idx "currently controlling $bn_control "
return 1
} else {
putdcc $idx "Usage: botnet control <-all | -flags <flags> | -local | -list>"
}
}
# }}}
# BOTNET PROC {{{
proc botnet_proc {bot cmd args} {
set args [lindex $args 0]
set hand [lindex $args end]
set blah [lindex $args 0]
if { ![matchattr $bot b] } {
putbotlog "\002error\002 \037::\037 unknown bot $hand@$bot asked for me to do $cmd $args (ignored)"
return 0
}
switch -exact $blah {
"takeover" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
takeover $channame
putbotlog "$hand@$bot asked me to takeover $channame "
}
"masskick" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
utimer [rand 10] "masskick $channame"
putbotlog "$hand@$bot asked me to masskick on $channame "
}
"massop" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
utimer [rand 10] "massop $channame"
putbotlog "$hand@$bot asked me to massop on $channame "
}
"massopall" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
utimer [rand 10] "massopall $channame"
putbotlog "$hand@$bot asked me to massop all on $channame "
}
"massvoice" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
utimer [rand 10] "massvoice $channame"
putbotlog "$hand@$bot asked me to massvoice on $channame "
}
"massdevoice" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
utimer [rand 10] "massdevoice $channame"
putbotlog "$hand@$bot asked me to massdevoice on $channame "
}
"join" {
set channame [lindex $args 1]
channel add $channame
putbotlog "$hand@$bot asked me to join $channame "
}
"part" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
catch {channel remove $channame}
putbotlog "$hand@$bot asked me to part $channame "
}
"save" {
save
putbotlog "$hand@$bot asked me to save"
}
"rehash" {
rehash
putbotlog "$hand@$bot asked me to do a rehash"
}
"chanset" {
set channame [lindex $args 1]
if {![validchan $channame]} {
return 0
}
set arglist [llength $args]
set settings [lrange $args 2 [expr $arglist-2]]
catch {eval chanset $channame $settings}
putbotlog "$hand@$bot asked me to set $settings on $channame "
}
}
}
proc dcc_bots {hand idx arg} {
global nick
set upbots [bots]
regsub -all " " $upbots ", " upbots
set downbots ""
foreach i [userlist b] {
if {(![islinked $i]) && ([string tolower $i] != [string tolower $nick])} {
lappend downbots $i
}
}
regsub -all " " $downbots ", " downbots
if {$upbots != ""} {
putbotdcc $idx "Bots up: $upbots"
putbotdcc $idx "(total: [llength $upbots])"
} else {
putbotdcc $idx "No bots linked"
}
if {$downbots != ""} {
putbotdcc $idx "Bots down: $downbots"
putbotdcc $idx "(total: [llength $downbots])"
} else {
putbotdcc $idx "All botes linked."
}
return 1
}
# }}}
# WHOIS: WHO ADDED USER FIELD {{{
if {![info exists whois-fields]} {
set whois-fields ""
}
set ffound 0
foreach f2 [split ${whois-fields}] {
if {[string tolower $f2] == [string tolower "Added"]} {
set ffound 1
break
}
}
if {$ffound == 0} {
append whois-fields " " "Added"
}
# }}}
# MSG: OP {{{
proc msg_op {nick uhost hand arg} {
global botnick
set pw [xindex $arg 0]
set chan [string tolower [xindex $arg 1]]
if {[xstrcmp $nick $botnick]} {
return 0
}
if {[passwdok $hand ""]} {
putbotdcclog "($nick!$uhost) $hand failed OP!"
return 0
}
if {[passwdok $hand $pw]} {
if {$chan != ""} {
if {![validchan $chan] || ![onchan $botnick $chan] || ![isop $botnick $chan]} {
putbotdcclog "($nick!$uhost) $hand failed OP!"
return 0
}
if {[onchan $nick $chan] && ![isop $nick $chan] && [matchattr [nick2hand $nick $chan] (o|#o)&-d&#-d $chan]} {
set thost [getchanhost $nick $chan]
set trandom [bop_encrypted $thost $nick]
putquick "MODE $chan +o-b $nick *!$nick@$trandom"
putbotdcclog "\00307#op#\003 \002$nick\002!$uhost \00314($hand)\0003"
}
return 0
}
foreach chan [channels] {
set chan [string tolower $chan]
if {[onchan $nick $chan] && ![isop $nick $chan] && [matchattr [nick2hand $nick $chan] (o|#o)&-d&#-d $chan]} {
set thost [getchanhost $nick $chan]
set trandom [bop_encrypted $thost $nick]
putquick "MODE $chan +o-b $nick *!$nick@$trandom"
}
}
putbotdcclog "\00307#op#\003 \002$nick\002!$uhost \00314($hand)\003"
return 0
}
putbotdcclog "($nick!$uhost) $hand failed OP!"
return 0
}
# }}}
# DCC: .+BOT {{{
proc dcc:+bot {hand idx paras} {
set user [lindex $paras 0]
if {[validuser $user]} {
*dcc:+bot $hand $idx $paras
} else {
*dcc:+bot $hand $idx $paras
if {[validuser $user]} {
setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
tellabout $hand $user
}
}
}
proc tellabout {hand user} {
global nick notify-newusers
foreach ppl ${notify-newusers} {
sendnote $nick $ppl "introduced to $user by $hand"
}
}
# }}}
# DCC: .+USER {{{
proc dcc:+user {hand idx paras} {
set user [lindex $paras 0]
if {[validuser $user]} {
*dcc:+user $hand $idx $paras
} else {
*dcc:+user $hand $idx $paras
if {[validuser $user]} {
setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
tellabout $hand $user
}
}
}
# }}}
# DCC: .ABOUT {{{
proc dcc_about {hand idx args} {
global dmver
putbotdcc $idx "\0037#about#\003"
putbotdcc $idx "darkMAGE v$dmver - kyau <[email protected]>"
}
# }}}
# DCC: .ADDUSER {{{
proc dcc:adduser {hand idx paras} {
set user [lindex $paras 1]
if {$user == ""} {
if {[string index $paras 0] == "!"} {
set user [string range [lindex $paras 0] 1 end]
} else {
set user [lindex $paras 0]
}
}
if {[validuser $user]} {
*dcc:adduser $hand $idx $paras
} else {
*dcc:adduser $hand $idx $paras
if {[validuser $user]} {
setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
tellabout $hand $user
}
}
}
# }}}
# DCC: .CHANNELS {{{
proc cmd_channels {hand idx args} {
putbotdcc $idx "\0037#channels#\003"
set chans {}
foreach chan [channels] {
if {![botisop $chan]} {
#putdcc $idx "$chan"
lappend chans "\00305$chan\003"
} else {
#putdcc $idx "@$chan"
lappend chans "$chan"
}
}
putbotdcc $idx "$chans"
}
# }}}
# DCC: .OP {{{
proc dcc_op {hand idx arg} {
global botnick
set nick [xindex $arg 0]
if {$nick == ""} {
putbotdcc $idx "\002usage:\002 op \[nickname\] \[#channel\]"
return 0
}
set chan [xindex $arg 1]
if {$chan != ""} {
putlog "moo1"
if {![matchattr [set hand [nick2hand $nick $chan]] o|o $chan]} { return 0 }
} else {
set chan {}
set tnum 0
foreach ichan [channels] {
putlog "$tnum:chan:$ichan"
if {[botisop $ichan] && [matchattr [set hand [nick2hand $nick $ichan]] o|o $ichan] && ![isop $nick $ichan]} {
lappend chan $ichan
}
incr tnum
}
if {$chan == ""} { return 0 }
}
if {[llength $chan] == 1} {
if {![onchan $nick [join $chan]]} {
putbotdccerr $idx "$nick is not on [join $chan]."
return 0
}
putlog "moo2"
if {![isop $botnick [join $chan]]} {
putbotdccerr $idx "I can't help you now because I'm not a chan op on [join $chan]."
return 0
}
if {![matchattr [nick2hand $nick [join $chan]] o|#o [join $chan]]} {
putbotdccerr $idx "$nick is not a channel op on [join $chan]."
return 0
}
set thost [getchanhost $nick [join $chan]]
set trandom [bop_encrypted $thost $nick]
putquick "MODE [join $chan] +o-b $nick *!$nick@$trandom"
return 1
} else {
putlog "made it!"
foreach ichan $chan {
if {[onchan $nick $ichan] && [isop $botnick $ichan] && [matchattr [nick2hand $nick $ichan] o|#o $ichan]} {
set thost [getchanhost $nick $ichan]
set trandom [bop_encrypted $thost $nick]
putquick "MODE $ichan +o-b $nick *!$nick@$trandom"
}
}
return 1
}
}
# }}}
# DCC: .USERLIST {{{
proc dcc_userlist {hand idx arg} {
if {[string tolower [xindex $arg 0]] == "help"} {
putbotdcc $idx "\002\usage:\002\ userlist \[flags\] \[#channel\]"
} else {
if {[xindex $arg 0] != ""} {
set flags [xindex $arg 0]
if {[xindex $arg 1] != ""} {
set chan [xindex $arg 1]
if {![validchan $chan]} {
putbotdcc $idx "ERROR: No such channel"
return 0
}
if {[string match *|* $flags]} {
set flags [xindex [split $flags |] 0]&[xindex [split $flags |] 1]
} else {
set flags "&$flags"
}
set userlist [userlist $flags $chan]
} else {
set userlist [userlist $flags]
}
} else {
set userlist [userlist]
}
putbotdcc $idx "Searching..."
set i2 0
foreach i $userlist {
if {[passwdok $i ""]} {
putbotdcc $idx "!$i ([xindex [getuser $i hosts] 0]) <[chattr $i]>"
} else {
putbotdcc $idx "$i ([xindex [getuser $i hosts] 0]) <[chattr $i]>"
}
incr i2
}
putbotdcc $idx "Found $i2 person(s) out of [countusers] matching specified flag"
}
return 1
}
# }}}
# DCC: .WHOM {{{
proc dcc:whomall {hand idx arg} {
if {$arg != "*"} {
*dcc:whom $hand $idx $arg
return
}
putbotdcc $idx "\00315whom all\003"
putbotdcc $idx " Nick Chanl Bot Idle Away Host"
putbotdcc $idx " --------- ----- --------- ------ ---- ------------------------------"
foreach person [whom *] {
set nck [lindex $person 0]
set bot [lindex $person 1]
set hst [lindex $person 2]
set sts [lindex $person 3]
set idl [lindex $person 4]
set awy [lindex $person 5]
set chn [lindex $person 6]
if {$sts == "-"} {set sts " "}
if {$chn > 99999} {set chn "local"}
if {$chn == "-1"} {set chn "off"}
set d [expr $idl / 1440]
set h [expr [expr $idl % 1440] / 60]
set m [expr [expr $idl % 1440] % 60]
set nid "${d}d${h}h"
if {$d == "0" && $h == "0"} {set nid "${m} min"}
if {$d == "0" && $h != "0"} {set nid "${h}h${m}m"}
if {[lindex $hst 1] == $bot} {set hst [lindex $hst 0]}
if {$awy != ""} {set aws "YES"} {set aws "NO"}
putbotdcc $idx [format "%-10s %-5s %-9s %-6s %-4s %-1s" ${sts}$nck $chn $bot $nid $aws $hst]
}
}
# }}}
# EVENT: DCC CHAT (MOTD) {{{
proc dcc_chat {hand idx} {
global botnick server nick partylinelist uptime version
dccsimul $idx ".echo off"
putdcc $idx "\00311▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄ \003\00314▄ \003\00311▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄\003\00310▄ \003\00311▄▄▄▄▄▄▄\003"
putdcc $idx "\00311,10▓▀\003 \00314▄ \003\00311,10▓█\003 \00311,10▓▀\003\00314░ \003\00311,10▓█\003 \00311,10██\003\00314░▄ \003\00311,10▓█\003 \00311,10▓▀\003\00314 ▀ \003\00311,10▓\00311,01█ \003\00311,10▓▀\003\00314░▄ \003\00311,10▓▀\003\00314░▄ \003\00311,10▓█\003 \00311,10▓▀\003\00314░ \003\00311,10▓█\003 \00311,10▓▀\003 \00310▄\003\00311▄▄▄ \003\00311,10▓▀\003\00310▄▄ \003\00311▀▀\003"
putdcc $idx "\00311,10▒\003\00310█ \003\00314▀\003\00310▄\003\00311,10▒\003\00310█ \003\00311,10░\003\00310▓\003\00311▀▀▀\003\00311,10▒▀\003 \00311▓\003\00310▓ \003\00314▓ \003\00311,10░▀\003 \00311,10░\003\00310▓\003\00311▀▀\003\00311,10▀\003\00311,01█▄ \003\00311,10░\003\00310▓ \003\00314▓ \003\00311,10░\003\00310▓ \003\00314▓ \003\00311,10▒▀\003 \00311,10░\003\00310▓\003\00311▀▀▀\003\00311,10▒▀\003 \00311,10▒\003\00310█▄ \00311,10▒▀\003 \00311,10▒\003\00310▓▄\003\00314░ \003\00311,10▓▀\003"
putdcc $idx "\00310▀▀▀▀▀▀\003\00314░ \003\00310▀▀ \003\00314▀ \003\00311,10░\003\00310█ ▀▀\003\00314░ \003\00310▀▀ \003\00314▀ \003\00311,10░\003\00310█ ▀▀ \003\00314▀ \003\00310▀▀ \003\00314▀ \003\00311,10░\003\00310█ ▀▀ \003\00314▀ \003\00311,10░\003\00310█ \003\00314░\003\00310▀▀▀▀▀▀ ▀▀▀▀▀▀\003"
putdcc $idx " "
putdcc $idx " Bot: \00300$botnick\003 Users: \00300[countusers]\003"
putdcc $idx " Server: \00300$server\003"
putdcc $idx " OS: \00300[exec uname -sr]\003"
set ver [split $version " "]
putdcc $idx " Running: \00300eggdrop v[lindex $ver 0] (ssl+ipv6)\003"
putdcc $idx " Uptime: \00300$uptime\003"
putdcc $idx " Channels:"
set chans {}
foreach chan [channels] {
if {![botisop $chan]} {
#putdcc $idx "$chan"
lappend chans "\0034$chan\003"
} else {
#putdcc $idx "@$chan"
lappend chans "\00310$chan\003"
}
}
putdcc $idx " $chans"
putdcc $idx " "
putdcc $idx " Use \002\00300.help\003\002 for basic help."
putdcc $idx " Usr \002\00300.darkmage\003\002 for botnet help."
if {$partylinelist == 1} {
set tmpcount [whom 0]
if {[llength $tmpcount] != 0} {
putdcc $idx " Partyline Users:"
foreach dcclist1 [whom 0] {
set thehand [lindex $dcclist1 0]
if {[matchattr $thehand n]} {
set pcw "\00304(owner)\003"
} elseif {[matchattr $thehand m]} {
set pcw "\00306(master)\003"
} elseif {[matchattr $thehand o]} {
set pcw "(op)"
} else {
set pcw "(user)"
}
putdcc $idx " $pcw \002\00300$thehand\003\002 on \00310[lindex $dcclist1 1]\003"
}
}
}
putdcc $idx " "
}
# }}}
# EVENT: BAN {{{
proc ban:+ban {handle idx arg} {
if {$arg == ""} {
*dcc:+ban $handle $idx $arg