-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchanrelay.tcl
1426 lines (1332 loc) · 49.4 KB
/
chanrelay.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
# chanrelay.tcl 3.14
#
# A way to link your channels
#
# Author: CrazyCat <crazycat@c-p-f.org>
# http://www.eggdrop.fr
# irc.zeolia.net #eggdrop
#
# Declare issues at https://gitlab.com/tcl-scripts/chanrelay
# No issue means no bug :)
#
## DESCRIPTION ##
#
# This TCL is a complete relay script wich works with botnet.
# All you have to do is to include this tcl in all the eggdrop who
# are concerned by it.
#
# You can use it as a spy or a full duplex communication tool.
#
# It don't mind if the eggdrops are on the same server or not,
# it just mind about the channels and the handle of each eggdrop.
## CHANGELOG ##
#
# 3.14 - The Pi edition :)
# Now possible to change the (user@network) displayed
# just add the usermask correct value in settings
# %nick% and %network% are dynamic variables
# Think to escape chars as [] or {}
#
# 3.13
# Modified join/part/quit procs
# Add a limit to message length
#
# 3.12
# Added colors for actions and non-message
#
#
# 3.11
# Made the "oper" setting functionnal
# Removed MDS support
#
# 3.10
# Added debug log. It can be enable and disable in configuration
# and with /msg rc.debug <on|off>
#
# 3.9
# Added exclusion list to ignore some users
# Added a way to restrict relay to an internal user list
#
# 3.81
# Action mades by server are no more using nick "*"
# Added a protection on oper actions:
# the action must come from the oper bot
# Correction of the quit transmission: when the bot leaves,
# it now detect and transmit
# Added botnet status broadcast
# Changed the unload system (thanks to MenzAgitat)
#
# 3.8
# Correction : the config file can now use username for naming,
# allowing to have relaying eggdrops in the same place with
# different settings
#
# 3.7
# Addition of @commandes (public) restricted to operators:
# @topic <network|all> a new topic :
# Changes topic on specified network (or all)
# @mode <network|all> +mode [arg][,-mode [arg]] :
# Changes modes on specified network (or all)
# All modes must be separated with a comma
# @kick <network|all> user [reason] :
# Kicks user on specified network (or all)
# @ban <network|all> user [reason]:
# Ban-kick user on specified network (or all)
# Default reason and banmask are in the conf section
#
# 3.6-3
# Correction of trans mode on/off
#
# 3.6-2
# Correction of the logging of actions (/me)
# Nick was replaced with ACTION
# Correction of empty chan list (!who)
#
# 3.6-1
# Correction of the !who command
# It's now possible to have the list from a specific server
#
# 3.6
# Correction of modes catching / transmitting
#
# 3.5 (Beta)
# Integration of Message Delivery Service (MDS)
# by MenzAgitat
#
# 3.4
# Settings modified by msg commands are now saved
# Correction of small bugs
# Best verification of settings sent
# Acknowledgement and error messages added
#
# 3.3-1
# Correction for /msg eggdrop trans <action> [on|off]
#
# 3.3
# Added lines introducing beginning and ending of userlist
#
# 3.2
# Added gray user highlight
#
# 3.1
# Added check for linked bot
# Corrected parse of some messages
# Corrected pub commands
#
# 3.0
# Complete modification of configuration
# Use of namespace
# No more broadcast, the relay is done with putbot
## TODO ##
#
# Enhance configuration
# Allow save of configuration
# Multi-languages
## CONFIGURATION ##
#
# For each eggdrop in the relay, you have to
# indicate his botnet nick, the chan and the network.
#
# Syntax:
# set regg(USERNAME) {
# "chan" "#CHANNEL"
# "network" "NETWORK"
#}
# with:
# USERNAME : The username sets in eggdrop.conf (case-sensitive)
# optionaly, you can override default values:
# * highlight (0/1/2/3): is speaker highlighted ? (no/bold/undelined/gray)
# * snet (y/n): is speaker'network shown ?
# * transmit (y/n): does eggdrop transmit his channel activity ?
# * receive (y/n): does eggdrop diffuse other channels activity ?
# * oper (y/n): does the eggdrop accept @ commands (topic, kick, ban) ?
# * syn_topic (y/n): if set to Yes, the eggdrop will
# synchronize the channel topic when changed on
# another chan of the relay
#
# userlist(beg) is the sentence announcing the start of !who
# userlist(end) is the sentence announcing the end of !who
namespace eval crelay {
# debug mode : set to 1 to enable
set debug 0
variable regg
variable default
variable userlist
set regg(Excalibur) {
"chan" "#eggdrop"
"network" "Zeolia"
"highlight" 0
"log" "y"
"oper" "y"
"syn_topic" "y"
"col_act" "lightred"
"col_jpq" "lightblue"
"col_mode" "green"
"usermask" "\[%network%\] <%nick%>"
}
set regg(CrazyEgg) {
"chan" "#eggdrop"
"network" "Epiknet"
"highlight" 3
"oper" "y"
}
set regg(CC_Egg) {
"chan" "#eggdrop"
"network" "Europnet"
}
# You can edit values but not remove
# or you'll break the system
set default {
"highlight" 1
"snet" "y"
"transmit" "y"
"receive" "y"
"log" "n"
"oper" "n"
"syn_topic" "n"
"col_act" "purple"
"col_jpq" "cyan"
"col_mode" "green"
"usermask" "(%nick%@%network%)"
}
# Fill this list with the nick of the users
# who WON'T BE relayed, as services bot
variable users_excluded {\[Guru\] Pan}
# Fill this list with the nick of the users
# wich will be THE ONLY ONES to be relayed
variable users_only {}
# transmission configuration
set trans_pub "y"; # transmit the pub
set trans_act "y"; # transmit the actions (/me)
set trans_nick "y"; # transmit the nick changement
set trans_join "y"; # transmit the join
set trans_part "y"; # transmit the part
set trans_quit "y"; # transmit the quit
set trans_topic "y"; # transmit the topic changements
set trans_kick "y"; # transmit the kicks
set trans_mode "y"; #transmit the mode changements
set trans_who "y"; # transmit the who list
# reception configuration
set recv_pub "y"; # recept the pub
set recv_act "y"; # recept the actions (/me)
set recv_nick "y"; # recept the nick changement
set recv_join "y"; # recept the join
set recv_part "y"; # recept the part
set recv_quit "y"; # recept the quit
set recv_topic "y"; # recept the topic changements
set recv_kick "y"; # recept the kicks
set recv_mode "y"; # recept the mode changements
set recv_who "y"; # recept the who list
set userlist(beg) "Beginning of userlist"
set userlist(end) "End of userlist"
# Set the banmask to use in banning the IPs
# Default banmask is set to 1
# 1 - *!*@some.domain.com
# 2 - *!*@*.domain.com
# 3 - *!*ident@some.domain.com
# 4 - *!*ident@*.domain.com
# 5 - *!*ident*@some.domain.com
# 6 - *nick*!*@*.domain.com
# 7 - *nick*!*@some.domain.com
# 8 - nick!ident@some.domain.com
# 9 - nick!ident@*.host.com
set bantype 1
# The default (ban)kick reason.
# %n will be replaced with the kicker name
set breason "You have been kicked by %n"
# Path and name of the config file
# %b will be replaced with the botnick
variable config "databases/%b.chanrelay.db"
# Path and name of the logfile (used for debug)
variable logfile "databases/chanrelay.log"
# max length of a message
variable msglen 350
variable author "CrazyCat"
variable version "3.13"
}
####################################
# DO NOT EDIT ANYTHING BELOW #
####################################
proc ::crelay::init {args} {
variable me
array set me $::crelay::default
array set me $::crelay::regg($::username)
if { [file exists $::crelay::config] } {
::crelay::preload
}
if { $me(transmit) == "y" } {
bind msg o|o "trans" ::crelay::set:trans
if { $::crelay::trans_pub == "y" } { bind pubm - * ::crelay::trans:pub }
if { $::crelay::trans_act == "y" } { bind ctcp - "ACTION" ::crelay::trans:act }
if { $::crelay::trans_nick == "y" } { bind nick - * ::crelay::trans:nick }
if { $::crelay::trans_join == "y" } { bind join - * ::crelay::trans:join }
if { $::crelay::trans_part == "y" } { bind part - * ::crelay::trans:part }
if { $::crelay::trans_quit == "y" } {
bind sign - * ::crelay::trans:quit
bind evnt - disconnect-server ::crelay::trans:selfquit
}
if { $::crelay::trans_topic == "y" } { bind topc - * ::crelay::trans:topic }
if { $::crelay::trans_kick == "y" } { bind kick - * ::crelay::trans:kick }
if { $::crelay::trans_mode == "y" } { bind raw - "MODE" ::crelay::trans:mode }
if { $::crelay::trans_who == "y" } { bind pub - "!who" ::crelay::trans:who }
if { $me(oper) == "y" } {
bind pub -|o "@topic" ::crelay::trans:otopic
bind pub -|o "@mode" ::crelay::trans:omode
bind pub -|o "@kick" ::crelay::trans:okick
bind pub -|o "@ban" ::crelay::trans:oban
bind pub -|o "@voice" ::crelay::trans:ovoice
bind pub -|o "@hop" ::crelay::trans:ohop
bind pub -|o "@op" ::crelay::trans:oop
}
}
if { $me(receive) =="y" } {
bind msg o|o "recv" ::crelay::set:recv
if { $::crelay::recv_pub == "y" } { bind bot - ">pub" ::crelay::recv:pub }
if { $::crelay::recv_act == "y" } { bind bot - ">act" ::crelay::recv:act }
if { $::crelay::recv_nick == "y" } { bind bot - ">nick" ::crelay::recv:nick }
if { $::crelay::recv_join == "y" } { bind bot - ">join" ::crelay::recv:join }
if { $::crelay::recv_part == "y" } { bind bot - ">part" ::crelay::recv:part }
if { $::crelay::recv_quit == "y" } { bind bot - ">quit" ::crelay::recv:quit }
if { $::crelay::recv_topic == "y" } { bind bot - ">topic" ::crelay::recv:topic }
if { $::crelay::recv_kick == "y" } { bind bot - ">kick" ::crelay::recv:kick }
if { $::crelay::recv_mode == "y" } { bind bot - ">mode" ::crelay::recv:mode }
if { $::crelay::recv_who == "y" } {
bind bot - ">who" ::crelay::recv:who
bind bot - ">wholist" ::crelay::recv:wholist
}
bind bot - ">otopic" ::crelay::recv:otopic
bind bot - ">omode" ::crelay::recv:omode
bind bot - ">okick" ::crelay::recv:okick
bind bot - ">oban" ::crelay::recv:oban
bind disc - * ::crelay::recv:disc
bind link - * ::crelay::recv:link
bind bot - ">list" ::crelay::recv:list
bind bot - ">users" ::crelay::recv:users
}
::crelay::set:hl $me(highlight);
if { $me(log) == "y"} {
logfile sjpk $me(chan) "logs/[string range $me(chan) 1 end].log"
}
bind msg -|o "rc.status" ::crelay::help:status
bind msg - "rc.help" ::crelay::help:cmds
bind msg -|o "rc.light" ::crelay::set:light
bind msg -|o "rc.net" ::crelay::set:snet
bind msg -|o "rc.syntopic" ::crelay::set:syn_topic
bind msg -|o "rc.debug" ::crelay::set:debug
bind bot - ">notop" ::crelay::recv:error
variable eggdrops
variable chans
variable networks
foreach bot [array names ::crelay::regg] {
array set tmp $::crelay::regg($bot)
lappend eggdrops $bot
lappend chans $tmp(chan)
lappend networks $tmp(network)
}
::crelay::save
bind evnt -|- prerehash ::crelay::deinit
package forget ChanRelay
package provide ChanRelay $::crelay::version
}
# Reads settings from a file
proc ::crelay::preload {args} {
regsub -all %b $::crelay::config $::username fname
if { [file exists $fname] } {
set fp [open $fname r]
set settings [read -nonewline $fp]
close $fp
foreach line [split $settings "\n"] {
set lset [split $line "|"]
switch [lindex $lset 0] {
transmit { set ::crelay::me(transmit) [lindex $lset 1] }
receive { set ::crelay::me(receive) [lindex $lset 1] }
snet { set ::crelay::me(snet) [lindex $lset 1] }
highlight { set ::crelay::me(highligt) [lindex $lset 1] }
syn_topic { set ::crelay::me(syn_topic) [lindex $lset 1] }
col_act { set ::crelay::me(col_act) [lindex $lset 1] }
col_mode { set ::crelay::me(col_mode) [lindex $lset 1] }
col_jpq { set ::crelay::me(col_jpq) [lindex $lset 1] }
default {
set ::crelay::[lindex $lset 0] [lindex $lset 1]
}
}
}
} else {
::crelay::save
}
}
# Save all settings in a file
proc ::crelay::save {args} {
regsub -all %b $::crelay::config $::username fname
set fp [open $fname w]
puts $fp "transmit|$::crelay::me(transmit)"
puts $fp "receive|$::crelay::me(receive)"
puts $fp "snet|$::crelay::me(snet)"
puts $fp "highlight|$::crelay::me(highlight)"
puts $fp "col_act|$::crelay::me(col_act)"
puts $fp "col_mode|$::crelay::me(col_mode)"
puts $fp "col_jpq|$::crelay::me(col_jpq)"
puts $fp "trans_pub|$::crelay::trans_pub"
puts $fp "trans_act|$::crelay::trans_act"
puts $fp "trans_nick|$::crelay::trans_nick"
puts $fp "trans_join|$::crelay::trans_join"
puts $fp "trans_part|$::crelay::trans_part"
puts $fp "trans_quit|$::crelay::trans_quit"
puts $fp "trans_topic|$::crelay::trans_topic"
puts $fp "trans_kick|$::crelay::trans_kick"
puts $fp "trans_mode|$::crelay::trans_mode"
puts $fp "trans_who|$::crelay::trans_who"
puts $fp "recv_pub|$::crelay::recv_pub"
puts $fp "recv_act|$::crelay::recv_act"
puts $fp "recv_nick|$::crelay::recv_nick"
puts $fp "recv_join|$::crelay::recv_join"
puts $fp "recv_part|$::crelay::recv_part"
puts $fp "recv_quit|$::crelay::recv_quit"
puts $fp "recv_topic|$::crelay::recv_topic"
puts $fp "recv_kick|$::crelay::recv_kick"
puts $fp "recv_mode|$::crelay::recv_mode"
puts $fp "recv_who|$::crelay::recv_who"
puts $fp "syn_topic|$::crelay::me(syn_topic)"
close $fp
}
proc ::crelay::deinit {args} {
putlog "Starting unloading CHANRELAY $::crelay::version"
::crelay::save
putlog "Settings are saved in $::crelay::config"
foreach binding [lsearch -inline -all -regexp [binds *[set ns [::tcl::string::range ::crelay 2 end]]*] " \{?(::)?$ns"] {
unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
}
putlog "CHANRELAY $::crelay::version unloaded"
package forget ChanRelay
namespace delete ::crelay
}
namespace eval crelay {
variable hlnick
variable snet
variable syn_topic
# Setting of hlnick
proc set:light { nick uhost handle arg } {
# message binding
switch [string tolower $arg] {
"bo" { ::crelay::set:hl 1; }
"un" { ::crelay::set:hl 2; }
"gr" { ::crelay::set:hl 3; }
"off" { ::crelay::set:hl 0; }
default { puthelp "NOTICE $nick :you must chose \002(bo)\002ld , \037(un)\037derline, \00314(gr)\003ay or (off)" }
}
::crelay::save
return 0;
}
proc set:hl { arg } {
# global hlnick setting function
switch [string tolower $arg] {
1 { set ::crelay::hlnick "\002"; }
2 { set ::crelay::hlnick "\037"; }
3 { set ::crelay::hlnick "\00314"; }
default { set ::crelay::hlnick ""; }
}
}
variable colors { "white" "\00300" "black" "\00301" "blue" "\00302" "green" "\00303"
"lightred" "\00304" "brown" "\00305" "purple" "\00306" "orange" "\00307"
"yellow" "\00308" "lightgreen" "\00309" "cyan" "\00310" "lightcyan" "\00311"
"lightblue" "\00312" "pink" "\00313" "grey" "\00314" "lightgrey" "\00315" }
proc colorize {type text} {
set text [stripcodes abcgru $text]
if {$type eq "act" && $::crelay::me(col_act) ne ""} {
set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_act)]$text\003"
} elseif {$type eq "mode" && $::crelay::me(col_mode) ne ""} {
set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_mode)]$text\003"
} elseif { $type eq "jpq" && $::crelay::me(col_jpq) ne ""} {
set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_jpq)]$text\003"
}
return $text
}
# Setting of show network
proc set:snet {nick host handle arg } {
set arg [string tolower $arg]
if { $arg == "yes" } {
set ::crelay::snet "y"
puthelp "NOTICE $nick :Network is now showed"
} elseif { $arg == "no" } {
set ::crelay::snet "n"
puthelp "NOTICE $nick :Network is now hidden"
} else {
puthelp "NOTICE $nick :you must chose yes or no"
return 0
}
::crelay::save
}
proc set:syn_topic {nick host handle arg} {
set arg [string tolower $arg]
if { $arg == "yes" } {
set ::crelay::syn_topic "y"
puthelp "NOTICE $nick :Topic synchro is now enabled"
} elseif { $arg == "no" } {
set ::crelay::syn_topic "n"
puthelp "NOTICE $nick :Topic synchro is now disabled"
} else {
puthelp "NOTICE $nick :you must choose yes or no"
return 0
}
}
proc set:debug { nick host handle arg} {
set arg [string tolower $arg]
if { $arg == "yes" } {
set ::crelay::debug 1
puthelp "NOTICE $nick :Debug mode is now enabled"
} elseif { $arg == "no" } {
set ::crelay::debug 0
puthelp "NOTICE $nick :Debug mode is now disabled"
} else {
puthelp "NOTICE $nick :Debug mode is actually setted to $::crelay::debug"
return 0
}
}
# proc setting of transmission by msg
proc set:trans { nick host handle arg } {
if { $::crelay::me(transmit) == "y" } {
if { $arg == "" } {
putquick "NOTICE $nick :you'd better try /msg $::botnick trans help"
}
if { [lindex [split $arg] 0] == "help" } {
putquick "NOTICE $nick :usage is /msg $::botnick trans <value> on|off"
putquick "NOTICE $nick :with <value> = pub, act, nick, join, part, quit, topic, kick, mode, who"
return 0
} else {
switch [lindex [split $arg] 0] {
"pub" { set type pubm }
"act" { set type ctcp }
"nick" { set type nick }
"join" { set type join }
"part" { set type part }
"quit" { set type sign }
"topic" { set type topc }
"kick" { set type kick }
"mode" { set type mode }
"who" { set type who }
default {
putquick "NOTICE $nick :Bad mode. Try /msg $::botnick trans help"
return 0
}
}
set proc_change "::crelay::trans:[lindex [split $arg] 0]"
set mod_change "::crelay::trans_[lindex [split $arg] 0]"
if { [lindex [split $arg] 1] eq "on" } {
if { $type eq "mode" } {
bind raw - "MODE" ::crelay::trans:mode
} else {
bind $type - * $proc_change
}
if { $type eq "sign"} {
bind evnt - disconnect-server ::crelay::trans:selfquit
}
set ${mod_change} "y"
putserv "NOTICE $nick :Transmission of [lindex [split $arg] 0] enabled"
} elseif { [lindex [split $arg] 1] eq "off" } {
if { $type eq "mode" } {
unbind raw - "MODE" ::crelay::trans:mode
} else {
unbind $type - * $proc_change
}
if { $type eq "sign"} {
unbind evnt - disconnect-server ::crelay::trans:selfquit
}
set ${mod_change} "n"
putserv "NOTICE $nick :Transmission of [lindex [split $arg] 0] disabled"
} else {
putquick "NOTICE $nick :[lindex [split $arg] 1] is not a correct value, choose \002on\002 or \002off\002"
}
}
} else {
putquick "NOTICE $nick :transmission is not activated, you can't change anything"
}
::crelay::save
}
# proc setting of reception by msg
proc set:recv { nick host handle arg } {
if { $::crelay::me(receive) == "y" } {
if { $arg == "" } {
putquick "NOTICE $nick :you'd better try /msg $::botnick recv help"
}
if { [lindex [split $arg] 0] == "help" } {
putquick "NOTICE $nick :usage is /msg $::botnick recv <value> on|off"
putquick "NOTICE $nick :with <value> = pub, act, nick, join, part, quit, topic, kick, mode, who"
return 0
} else {
switch [lindex [split $arg] 0] {
"pub" -
"act" -
"nick" -
"join" -
"part" -
"quit" -
"topic" -
"kick" -
"mode" -
"who" { set type [lindex [split $arg] 0] }
default {
putquick "NOTICE $nick :Bad mode. Try /msg $::botnick recv help"
return 0
}
}
set change ">$type"
set proc_change "::crelay::recv:$type"
set mod_change "::crelay::recv_$type"
if { [lindex [split $arg] 1] eq "on" } {
bind bot - $change $proc_change
set ${mod_change} "y"
putserv "NOTICE $nick :Reception of $type enabled"
} elseif { [lindex [split $arg] 1] == "off" } {
unbind bot - $change $proc_change
set ${mod_change} "n"
putserv "NOTICE $nick :Reception of $type disabled"
} else {
putquick "NOTICE $nick :[lindex [split $arg] 1] is not a correct value, choose \002on\002 or \002off\002"
}
}
} else {
putquick "NOTICE $nick :reception is not activated, you can't change anything"
}
::crelay::save
}
# Generates an user@network name
# based on nick and from bot using usermask setting
proc make:user { nick frm_bot } {
if {[string length $::crelay::hlnick] > 0 } {
set ehlnick [string index $::crelay::hlnick 0]
} else {
set ehlnick ""
}
set umask $::crelay::me(usermask)
array set him $::crelay::regg($frm_bot)
regsub -all %network% $umask $him(network) umask
if {$nick == "*"} {
regsub -all {(%nick%|@)} $umask "" umask
set speaker [concat "$::crelay::hlnick$umask$ehlnick"]
} else {
regsub -all %nick% $umask $nick umask
set speaker $::crelay::hlnick$umask$ehlnick
}
return $speaker
}
# Logs virtual channel activity
proc cr:log { lev chan line } {
if { $::crelay::me(log) == "y" } {
putloglev $lev "$chan" "$line"
}
return 0
}
# Global transmit procedure
proc trans:bot { usercmd chan usernick text } {
if { $::crelay::debug == 1 } { dlog "Transmission $usercmd from $usernick / $chan" }
if {[llength $::crelay::users_only]>0 && [lsearch -nocase $::crelay::users_only $usernick]==-1} {
return 0
}
if {[llength $::crelay::users_excluded]>0 && [lsearch -nocase $::crelay::users_excluded $usernick]!=-1} {
return 0
}
set transmsg [concat $usercmd $usernick $text]
set ::crelay::eob 0
if {[string tolower $chan] == [string tolower $::crelay::me(chan)]} {
foreach bot [array names ::crelay::regg] {
if {$bot != $::username && [islinked $bot]} {
putbot $bot $transmsg
if { $::crelay::debug == 1 } { dlog "Sent to $bot : $transmsg" }
if {$usercmd == ">who" } { incr ::crelay::eob }
}
}
} else {
return 0
}
}
# proc transmission of pub (trans_pub = y)
proc trans:pub {nick uhost hand chan text} {
if { [string tolower [lindex [split $text] 0]] == "!who" } { return 0; }
if { [string tolower [lindex [split $text] 0]] == "@topic" } { return 0; }
if { [string tolower [lindex [split $text] 0]] == "@mode" } { return 0; }
if { [string tolower [lindex [split $text] 0]] == "@ban" } { return 0; }
if { [string tolower [lindex [split $text] 0]] == "@kick" } { return 0; }
foreach splmsg [::crelay::split_line $text [expr {$::crelay::msglen - [::tcl::string::length [::crelay::make:user $nick $::username]]}]] {
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >pub $chan $nick $splmsg" }
::crelay::trans:bot ">pub" $chan $nick $splmsg
}
}
# proc transmission of action (trans_act = y)
proc trans:act {nick uhost hand chan key text} {
set arg [concat $key $text]
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >act $chan $nick $arg" }
::crelay::trans:bot ">act" $chan $nick $arg
}
# proc transmission of nick changement
proc trans:nick {nick uhost hand chan newnick} {
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >nick $chan $nick $newnick" }
::crelay::trans:bot ">nick" $chan $nick $newnick
}
# proc transmission of join
proc trans:join {nick uhost hand chan} {
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >join $chan $chan $nick" }
::crelay::trans:bot ">join" $chan $chan "$nick!$uhost"
}
# proc transmission of part
proc trans:part {nick uhost hand chan text} {
set arg [concat $chan $text]
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >part $chan $nick $arg" }
::crelay::trans:bot ">part" $chan $nick $arg
}
# proc transmission of quit
proc trans:quit {nick host hand chan text} {
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >quit $chan $nick $text" }
::crelay::trans:bot ">quit" $chan $nick $text
}
# Proc to get our self quit
proc trans:selfquit {type} {
::crelay::trans:bot ">quit" $::crelay::me(chan) $::botnick "I don't know why but I left server"
}
# proc transmission of topic changement
proc trans:topic {nick uhost hand chan topic} {
set arg [concat $chan $topic]
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >topic $chan $nick $arg" }
::crelay::trans:bot ">topic" $chan $nick $arg
}
# proc transmission of kick
proc trans:kick {nick uhost hand chan victim reason} {
set arg [concat $victim $chan $reason]
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >kick $chan $nick $arg" }
::crelay::trans:bot ">kick" $chan $nick $arg
}
# proc transmission of mode changement
proc trans:mode {from keyw text} {
set nick [lindex [split $from !] 0]
set chan [lindex [split $text] 0]
set text [concat $nick $text]
if { $::crelay::debug == 1 } { dlog "Prepare transmission : >mode $chan $nick $text" }
::crelay::trans:bot ">mode" $chan $nick $text
}
# proc transmission of "who command"
proc trans:who {nick uhost handle chan args} {
if { [join [lindex [split $args] 0]] != "" } {
set netindex [lsearch -nocase $::crelay::networks [lindex [split $args] 0]]
if { $netindex == -1 } {
putserv "PRIVMSG $nick :$args est un réseau inconnu";
return 0
} else {
set ::crelay::eol 0
set ::crelay::bol 0
set ::crelay::eob 1
putbot [lindex $::crelay::eggdrops $netindex] ">who $nick"
}
} else {
set ::crelay::eol 0
set ::crelay::bol 0
::crelay::trans:bot ">who" $chan $nick ""
}
}
# Error reception
proc recv:error {frm_bot command arg} {
# putlog "$command - $arg"
return 0
}
# proc reception of pub
proc recv:pub {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending pub [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
putquick "PRIVMSG $::crelay::me(chan) :$speaker [join [lrange $argl 1 end]]"
::crelay::cr:log p "$::crelay::me(chan)" "<[lindex $argl 0]> [join [lrange $argl 1 end]]"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of action
proc recv:act {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending act [join [lrange $argl 2 end]] to $::crelay::me(chan)" }
set text [::crelay::colorize "act" "* $speaker [join [lrange $argl 2 end]]"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log p "$::crelay::me(chan)" "Action: [lindex $argl 0] [join [lrange $argl 2 end]]"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of nick changement
proc recv:nick {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending nick [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
set text [::crelay::colorize "jpq" "*** $speaker is now known as [join [lrange $argl 1 end]]"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log j "$::crelay::me(chan)" "Nick change: [lindex $argl 0] -> [join [lrange $argl 1 end]]"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of join
proc recv:join {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [lindex $argl 1]
if { $::crelay::debug == 1 } { dlog "Sending join [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
set text [::crelay::colorize "jpq" "--> $speaker has joined channel [lindex $argl 0]@[lindex $::crelay::networks $him]"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 1] joined $::crelay::me(chan)."
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of part
proc recv:part {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending part [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
if {[llength $argl]<4} {
set partmsg ""
} else {
set partmsg " ([join [lrange $argl 2 end]])"
}
#set text [::crelay::colorize "jpq" "<-- $speaker has left channel [lindex $argl 1] ([join [lrange $argl 2 end]])"]
set text [::crelay::colorize "jpq" "<-- $speaker has left channel [lindex $argl 1]$partmsg"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 0] left $::crelay::me(chan) ([join [lrange $argl 2 end]])"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of quit
proc recv:quit {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if {[llength $argl]<3} {
set quitmsg ""
} else {
set quitmsg " ([join [lrange $argl 1 end]])"
}
if { $::crelay::debug == 1 } { dlog "Sending quit [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
#set text [::crelay::colorize "jpq" "-//- $speaker has quit ([join [lrange $argl 1 end]])"]
set text [::crelay::colorize "jpq" "-//- $speaker has quit$quitmsg"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 0] left irc: ([join [lrange $argl 1 end]])"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of topic changement
proc recv:topic {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending topic [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
if { $::crelay::me(syn_topic) == "y" } {
putserv "TOPIC $::crelay::me(chan) :[join [lrange $argl 2 end]]"
} else {
putquick "PRIVMSG $::crelay::me(chan) :*** $speaker changes topic of [lindex $argl 1] to '[join [lrange $argl 2 end]]'"
}
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of kick
proc recv:kick {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 1] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending kick [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
set text [::crelay::colorize "jpq" "*** $speaker has been kicked from [lindex $argl 2] by [lindex $argl 0]: [join [lrange $argl 3 end]]"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
::crelay::cr:log k "$::crelay::me(chan)" "[lindex $argl 1] kicked from $::crelay::me(chan) by [lindex $argl 0]:[join [lrange $argl 3 end]]"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# proc reception of mode changement
proc recv:mode {frm_bot command arg} {
if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
set argl [split $arg]
set speaker [::crelay::make:user [lindex $argl 1] $frm_bot]
if { $::crelay::debug == 1 } { dlog "Sending mode [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
set text [::crelay::colorize "mode" "*** $speaker set mode [join [lrange $argl 2 end]]"]
putquick "PRIVMSG $::crelay::me(chan) :$text"
} else {
if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
}
return 0
}
# reception of !who command
proc recv:who {frm_bot command arg} {
set nick $arg
set ulist ""
set cusr 0
if {![botonchan $::crelay::me(chan)]} {
putbot $frm_bot ">wholist $::crelay::me(chan) $nick eol"
return 0
}
foreach user [chanlist $::crelay::me(chan)] {
if { $user == $::botnick } { continue; }
if { [isop $user $::crelay::me(chan)] == 1 } {
set st "@"
} elseif { [ishalfop $user $::crelay::me(chan)] == 1 } {
set st "%"
} elseif { [isvoice $user $::crelay::me(chan)] == 1 } {
set st "%"
} else {
set st ""
}
incr cusr 1
append ulist " $st$user"
if { $cusr == 5 } {
putbot $frm_bot ">wholist $::crelay::me(chan) $nick $ulist"
set ulist ""
set cusr 0
}
}
if { $ulist != "" } {
putbot $frm_bot ">wholist $::crelay::me(chan) $nick $ulist"
}
putbot $frm_bot ">wholist $::crelay::me(chan) $nick eol"
}
# Proc reception of a who list
proc recv:wholist {frm_bot command arg} {
set nick [join [lindex [split $arg] 1]]
set speaker [::crelay::make:user $frm_bot $frm_bot]
if {$::crelay::bol == 0} {
incr ::crelay::bol
putserv "NOTICE $nick :*** $::crelay::userlist(beg)"
}
if { [join [lrange [split $arg] 2 end]] == "eol"} {
incr ::crelay::eol
if {$::crelay::eol == $::crelay::eob} {
putserv "NOTICE $nick :*** $::crelay::userlist(end)"
}
} else {
putserv "NOTICE $nick :$speaker [join [lrange [split $arg] 2 end]]"
}
}
######################################
# Operators commands
#
proc trans:otopic {nick uhost handle chan text} {
if {[::crelay::isOper $::username]==0} {
putserv "NOTICE $nick :Sorry but I'm not setted as oper in chanrelay"