Advertisement
Guest User

Untitled

a guest
Dec 14th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 70.77 KB | None | 0 0
  1. # chanrelay.tcl 4.0
  2. #
  3. # A way to link your channels
  4. #
  5. # Author: CrazyCat <crazycat@c-p-f.org>
  6. # https://www.eggdrop.fr
  7. # irc.zeolia.net #eggdrop
  8. #
  9. # Declare issues at https://gitlab.com/tcl-scripts/chanrelay
  10. # No issue, no bug :)
  11. #
  12. ## DESCRIPTION ##
  13. #
  14. # This TCL is a complete relay script wich works with botnet.
  15. # All you have to do is to include this tcl in all the eggdrop who
  16. # are concerned by it.
  17. #
  18. # You can use it as a spy or a full duplex communication tool.
  19. #
  20. # It don't mind if the eggdrops are on the same server or not,
  21. # it just mind about the channels and the handle of each eggdrop.
  22.  
  23. ## CHANGELOG ##
  24. #
  25. # 4.00 - i18n
  26. #
  27.  
  28. ## CONFIGURATION ##
  29. #
  30. # For each eggdrop in the relay, you have to
  31. # indicate his botnet nick, the chan and the network.
  32. #
  33. # Syntax:
  34. # set regg(USERNAME) {
  35. #   "chan"      "#CHANNEL"
  36. #   "network"   "NETWORK"
  37. #}
  38. # with:
  39. # USERNAME : The username sets in eggdrop.conf (case-sensitive)
  40. # optionaly, you can override default values:
  41. # * highlight (0/1/2/3): is speaker highlighted ? (no/bold/undelined/gray)
  42. # * snet (y/n): is speaker'network shown ?
  43. # * transmit (y/n): does eggdrop transmit his channel activity ?
  44. # * receive (y/n): does eggdrop diffuse other channels activity ?
  45. # * oper (y/n): does the eggdrop accept @ commands (topic, kick, ban) ?
  46. # * syn_topic (y/n): if set to Yes, the eggdrop will
  47. #   synchronize the channel topic when changed on
  48. #   another chan of the relay
  49. # * col_act (color) : color used to display actions
  50. # * col_mode (color) : color used to display mode changement
  51. # * col_jqp (color) : color used to display join/quit/part
  52.  
  53.  
  54. namespace eval crelay {
  55.  
  56.         #####################
  57.         ### CONFIGURATION ###
  58.         #####################
  59.  
  60.         ###     BASIC     ###
  61.         variable regg
  62.         set regg(sender) {
  63.                 "chan"      "#chan1"
  64.                 "network"   "Irc1"
  65.                 "highlight" 0
  66.                 "log"       "y"
  67.                 "oper"      "y"
  68.                 "syn_topic" "y"
  69.                 "col_act"   "lightred"
  70.                 "col_jpq"   "lightblue"
  71.                 "col_mode"  "green"
  72.                 "usermask"      "<%nick%@%network%>"
  73.         }
  74.  
  75.         set regg(reader) {
  76.                 "chan"      "#chan2"
  77.                 "network"   "Irc2"
  78.                 "highlight" 0
  79.                 "oper"      "y"
  80.         }
  81.  
  82.         # set regg(CC_Egg) {
  83.         #       "chan"      "#eggdrop"
  84.         #       "network"   "Europnet"
  85.         # }
  86.  
  87.         # /!\ You can edit following values but
  88.         # DO NOT remove any
  89.         variable default
  90.         set default {
  91.                 "highlight" 1
  92.                 "snet"      "y"
  93.                 "transmit"  "y"
  94.                 "receive"   "y"
  95.                 "log"       "y"
  96.                 "oper"      "y"
  97.                 "syn_topic" "n"
  98.                 "col_act"   "purple"
  99.                 "col_jpq"   "cyan"
  100.                 "col_mode"  "green"
  101.                 "usermask"      "(%nick%@%network%)"
  102.         }
  103.  
  104.         ###     GLOBAL     ###
  105.         # debug mode : set to 1 to enable
  106.         set debug 0
  107.  
  108.         # language to use : default is english, french, spanish, german and portuguese available
  109.         set lang english
  110.  
  111.         # Fill this list with the nick of the users
  112.         # who WON'T BE relayed, as services bot
  113.         variable users_excluded {\[Guru\] Pan}
  114.  
  115.         # Fill this list with the nick of the users
  116.         # wich will be THE ONLY ONES to be relayed
  117.         variable users_only {}
  118.  
  119.         # Set the banmask to use in banning the IPs
  120.         # Default banmask is set to 1
  121.         # 1 - *!*@some.domain.com
  122.         # 2 - *!*@*.domain.com
  123.         # 3 - *!*ident@some.domain.com
  124.         # 4 - *!*ident@*.domain.com
  125.         # 5 - *!*ident*@some.domain.com
  126.         # 6 - *nick*!*@*.domain.com
  127.         # 7 - *nick*!*@some.domain.com
  128.         # 8 - nick!ident@some.domain.com
  129.         # 9 - nick!ident@*.host.com
  130.         set bantype 1
  131.  
  132.         # max length of a message
  133.         variable msglen 350
  134.  
  135.         ###     FILES     ###
  136.         # Path and name of the config file
  137.         # %b will be replaced with the botnick
  138.         variable crconf "%b.chanrelay.db"
  139.  
  140.         # Path and name of the logfile (used for debug)
  141.         variable crlog "chanrelay.log"
  142.  
  143.         ###     INITIAL     ###
  144.         # transmission configuration
  145.         set trans_pub "y"; # transmit the pub
  146.         set trans_act "y"; # transmit the actions (/me)
  147.         set trans_nick "y"; # transmit the nick changement
  148.         set trans_join "y"; # transmit the join
  149.         set trans_part "y"; # transmit the part
  150.         set trans_quit "y"; # transmit the quit
  151.         set trans_topic "y"; # transmit the topic changements
  152.         set trans_kick "y"; # transmit the kicks
  153.         set trans_mode "y"; #transmit the mode changements
  154.         set trans_who "y"; # transmit the who list
  155.  
  156.         # reception configuration
  157.         set recv_pub "y"; # recept the pub
  158.         set recv_act "y"; # recept the actions (/me)
  159.         set recv_nick "y"; # recept the nick changement
  160.         set recv_join "y"; # recept the join
  161.         set recv_part "y"; # recept the part
  162.         set recv_quit "y"; # recept the quit
  163.         set recv_topic "y"; # recept the topic changements
  164.         set recv_kick "y"; # recept the kicks
  165.         set recv_mode "y"; # recept the mode changements
  166.         set recv_who "y"; # recept the who list
  167. }
  168.  
  169. ####################################
  170. #    DO NOT EDIT ANYTHING BELOW    #
  171. ####################################
  172. namespace eval crelay {
  173.  
  174.         variable author "CrazyCat"
  175.         variable version "4.00"
  176.         variable userlist
  177.         variable hlnick
  178.         variable snet
  179.         variable syn_topic
  180.         set topicsynced 0
  181.  
  182.         variable crpath "[file dirname [file normalize [info script]]]/crtools/"
  183.         variable fname
  184.  
  185.         proc init {args} {
  186.                 variable me
  187.                 array set me $::crelay::default
  188.                 array set me $::crelay::regg($::username)
  189.                 regsub -all %b ${::crelay::crpath}${::crelay::crconf} $::username fname
  190.                 if { [file exists $fname] } {
  191.                         ::crelay::preload
  192.                 }
  193.                 if { $me(transmit) == "y" } {
  194.                         bind msg o|o "trans" ::crelay::set:trans
  195.                         if { $::crelay::trans_pub == "y" } { bind pubm - * ::crelay::trans:pub }
  196.                         if { $::crelay::trans_act == "y" } { bind ctcp - "ACTION" ::crelay::trans:act }
  197.                         if { $::crelay::trans_nick == "y" } { bind nick - * ::crelay::trans:nick }
  198.                         if { $::crelay::trans_join == "y" } { bind join - * ::crelay::trans:join }
  199.                         if { $::crelay::trans_part == "y" } { bind part - * ::crelay::trans:part }
  200.                         if { $::crelay::trans_quit == "y" } {
  201.                                 bind sign - * ::crelay::trans:quit
  202.                                 bind evnt - disconnect-server ::crelay::trans:selfquit
  203.                         }
  204.                         if { $::crelay::trans_topic == "y" } { bind topc - * ::crelay::trans:topic }
  205.                         if { $::crelay::trans_kick == "y" } { bind kick - * ::crelay::trans:kick }
  206.                         if { $::crelay::trans_mode == "y" } { bind raw - "MODE" ::crelay::trans:mode }
  207.                         if { $::crelay::trans_who == "y" } { bind pub - "!who" ::crelay::trans:who }
  208.                         if { $me(oper) == "y" } {
  209.                                 bind pub -|o "@topic" ::crelay::trans:otopic
  210.                                 bind pub -|o "@mode" ::crelay::trans:omode
  211.                                 bind pub -|o "@kick" ::crelay::trans:okick
  212.                                 bind pub -|o "@ban" ::crelay::trans:oban
  213.                                 bind pub -|o "@voice" ::crelay::trans:ovoice
  214.                                 bind pub -|o "@vop" ::crelay::trans:ovoice
  215.                                 bind pub -|o "@hop" ::crelay::trans:ohop
  216.                                 bind pub -|o "@op" ::crelay::trans:oop
  217.                         }
  218.                 }
  219.                 if { $me(receive) =="y" } {
  220.                         bind msg o|o "recv" ::crelay::set:recv
  221.                         if { $::crelay::recv_pub == "y" } { bind bot - ">pub" ::crelay::recv:pub }
  222.                         if { $::crelay::recv_act == "y" } { bind bot - ">act" ::crelay::recv:act }
  223.                         if { $::crelay::recv_nick == "y" } { bind bot - ">nick" ::crelay::recv:nick }
  224.                         if { $::crelay::recv_join == "y" } { bind bot - ">join" ::crelay::recv:join }
  225.                         if { $::crelay::recv_part == "y" } { bind bot - ">part" ::crelay::recv:part }
  226.                         if { $::crelay::recv_quit == "y" } { bind bot - ">quit" ::crelay::recv:quit }
  227.                         if { $::crelay::recv_topic == "y" } { bind bot - ">topic" ::crelay::recv:topic }
  228.                         if { $::crelay::recv_kick == "y" } { bind bot - ">kick" ::crelay::recv:kick }
  229.                         if { $::crelay::recv_mode == "y" } { bind bot - ">mode" ::crelay::recv:mode }
  230.                         if { $::crelay::recv_who == "y" } {
  231.                                 bind bot - ">who" ::crelay::recv:who
  232.                                 bind bot - ">wholist" ::crelay::recv:wholist
  233.                         }
  234.                         bind bot - ">otopic" ::crelay::recv:otopic
  235.                         bind bot - ">omode" ::crelay::recv:omode
  236.                         bind bot - ">okick" ::crelay::recv:okick
  237.                         bind bot - ">oban" ::crelay::recv:oban
  238.                         bind disc - * ::crelay::recv:disc
  239.                         bind link - * ::crelay::recv:link
  240.                         bind bot - ">list" ::crelay::recv:list
  241.                         bind bot - ">users" ::crelay::recv:users
  242.                 }
  243.  
  244.                 ::crelay::set:hl $me(highlight);
  245.  
  246.                 if { $me(log) == "y"} {
  247.                         logfile sjpk $me(chan) "logs/[string range $me(chan) 1 end].log"
  248.                 }
  249.                 bind msg -|o "rc.status" ::crelay::help:status
  250.                 bind msg - "rc.help" ::crelay::help:cmds
  251.                 bind msg -|o "rc.light" ::crelay::set:light
  252.                 bind msg -|o "rc.net" ::crelay::set:snet
  253.                 bind msg -|o "rc.syntopic" ::crelay::set:syn_topic
  254.                 bind msg -|o "rc.debug" ::crelay::set:debug
  255.                 bind bot - ">notop" ::crelay::recv:error
  256.  
  257.                 variable eggdrops
  258.                 variable chans
  259.                 variable networks
  260.                 foreach bot [array names ::crelay::regg] {
  261.                         array set tmp $::crelay::regg($bot)
  262.                         lappend eggdrops $bot
  263.                         lappend chans $tmp(chan)
  264.                         lappend networks $tmp(network)
  265.                 }
  266.                 ::crelay::save
  267.                 bind evnt -|- prerehash ::crelay::deinit
  268.  
  269.                 package forget ChanRelay
  270.                 package provide ChanRelay $::crelay::version
  271.         }
  272.  
  273.         proc preload {args} {
  274.                 regsub -all %b ${::crelay::crpath}${::crelay::crconf} $::username fname
  275.                 if { [file exists $fname] } {
  276.                         set fp [open $fname r]
  277.                         set settings [read -nonewline $fp]
  278.                         close $fp
  279.                         foreach line [split $settings "\n"] {
  280.                                 set lset [split $line "|"]
  281.                                 switch [lindex $lset 0] {
  282.                                         transmit { set ::crelay::me(transmit) [lindex $lset 1] }
  283.                                         receive { set ::crelay::me(receive) [lindex $lset 1] }
  284.                                         snet { set ::crelay::me(snet) [lindex $lset 1] }
  285.                                         highlight { set ::crelay::me(highligt) [lindex $lset 1] }
  286.                                         syn_topic { set ::crelay::me(syn_topic) [lindex $lset 1] }
  287.                                         col_act { set ::crelay::me(col_act) [lindex $lset 1] }
  288.                                         col_mode { set ::crelay::me(col_mode) [lindex $lset 1] }
  289.                                         col_jpq { set ::crelay::me(col_jpq) [lindex $lset 1] }
  290.                                         default {
  291.                                                 set ::crelay::[lindex $lset 0] [lindex $lset 1]
  292.                                         }
  293.                                 }
  294.                         }
  295.                 } else {
  296.                         ::crelay::save
  297.                 }
  298.         }
  299.  
  300.         # Save all settings in a file
  301.         proc save {args} {
  302.                 regsub -all %b ${::crelay::crpath}${::crelay::crconf} $::username fname
  303.                 set fp [open $fname w]
  304.                 puts $fp "transmit|$::crelay::me(transmit)"
  305.                 puts $fp "receive|$::crelay::me(receive)"
  306.                 puts $fp "snet|$::crelay::me(snet)"
  307.                 puts $fp "highlight|$::crelay::me(highlight)"
  308.                 puts $fp "col_act|$::crelay::me(col_act)"
  309.                 puts $fp "col_mode|$::crelay::me(col_mode)"
  310.                 puts $fp "col_jpq|$::crelay::me(col_jpq)"
  311.                 puts $fp "trans_pub|$::crelay::trans_pub"
  312.                 puts $fp "trans_act|$::crelay::trans_act"
  313.                 puts $fp "trans_nick|$::crelay::trans_nick"
  314.                 puts $fp "trans_join|$::crelay::trans_join"
  315.                 puts $fp "trans_part|$::crelay::trans_part"
  316.                 puts $fp "trans_quit|$::crelay::trans_quit"
  317.                 puts $fp "trans_topic|$::crelay::trans_topic"
  318.                 puts $fp "trans_kick|$::crelay::trans_kick"
  319.                 puts $fp "trans_mode|$::crelay::trans_mode"
  320.                 puts $fp "trans_who|$::crelay::trans_who"
  321.                 puts $fp "recv_pub|$::crelay::recv_pub"
  322.                 puts $fp "recv_act|$::crelay::recv_act"
  323.                 puts $fp "recv_nick|$::crelay::recv_nick"
  324.                 puts $fp "recv_join|$::crelay::recv_join"
  325.                 puts $fp "recv_part|$::crelay::recv_part"
  326.                 puts $fp "recv_quit|$::crelay::recv_quit"
  327.                 puts $fp "recv_topic|$::crelay::recv_topic"
  328.                 puts $fp "recv_kick|$::crelay::recv_kick"
  329.                 puts $fp "recv_mode|$::crelay::recv_mode"
  330.                 puts $fp "recv_who|$::crelay::recv_who"
  331.                 puts $fp "syn_topic|$::crelay::me(syn_topic)"
  332.                 close $fp
  333.                 ::crelay::preload
  334.         }
  335.  
  336.         proc deinit {args} {
  337.                 putlog "Starting unloading CHANRELAY $::crelay::version"
  338.                 ::crelay::save
  339.                 regsub %b $::crelay::crconf $::username fname
  340.                 putlog "CHANRELAY: Settings are saved in $fname"
  341.                 foreach binding [lsearch -inline -all -regexp [binds *[set ns [::tcl::string::range ::crelay 2 end]]*] " \{?(::)?$ns"] {
  342.                         unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
  343.                 }
  344.                 putlog "CHANRELAY $::crelay::version unloaded"
  345.                 package forget ChanRelay
  346.                 namespace delete ::crelay
  347.         }
  348.  
  349.         variable hlnick
  350.         variable snet
  351.         variable syn_topic
  352.         set topicsynced 0
  353.  
  354.         # Setting of hlnick
  355.         proc set:light { nick uhost handle arg } {
  356.                 # message binding
  357.                 switch [string tolower $arg] {
  358.                         "bo" { ::crelay::set:hl 1; }
  359.                         "un" { ::crelay::set:hl 2; }
  360.                         "gr" { ::crelay::set:hl 3; }
  361.                         "off" { ::crelay::set:hl 0; }
  362.                         default { puthelp "NOTICE $nick :[::msgcat::mc "you must chose \002(bo)\002ld , \037(un)\037derline, \00314(gr)\003ay or (off)"]" }
  363.                 }
  364.                 ::crelay::save
  365.                 return 0;
  366.         }
  367.  
  368.         proc set:hl { arg } {
  369.                 # global hlnick setting function
  370.                 switch [string tolower $arg] {
  371.                         1 { set ::crelay::hlnick "\002"; }
  372.                         2 { set ::crelay::hlnick "\037"; }
  373.                         3 { set ::crelay::hlnick "\00314"; }
  374.                         default { set ::crelay::hlnick ""; }
  375.                 }
  376.         }
  377.  
  378.         variable colors { "white" "\00300" "black" "\00301" "blue" "\00302" "green" "\00303"
  379.                 "lightred" "\00304" "brown" "\00305" "purple" "\00306" "orange" "\00307"
  380.                 "yellow" "\00308" "lightgreen" "\00309" "cyan" "\00310" "lightcyan" "\00311"
  381.                 "lightblue" "\00312" "pink" "\00313" "grey" "\00314" "lightgrey" "\00315" }
  382.  
  383.         proc colorize {type text} {
  384.                 set text [stripcodes abcgru $text]
  385.                 if {$type eq "act" && $::crelay::me(col_act) ne ""} {
  386.                         set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_act)]$text\003"
  387.                 } elseif {$type eq "mode" && $::crelay::me(col_mode) ne ""} {
  388.                         set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_mode)]$text\003"
  389.                 } elseif { $type eq "jpq" && $::crelay::me(col_jpq) ne ""} {
  390.                         set text "[::tcl::string::map $::crelay::colors $::crelay::me(col_jpq)]$text\003"
  391.                 }
  392.                 return $text
  393.         }
  394.  
  395.         # Setting of show network
  396.         proc set:snet {nick host handle arg } {
  397.                 set arg [string tolower $arg]
  398.                 if { $arg == "yes" } {
  399.                         set ::crelay::snet "y"
  400.                         puthelp "NOTICE $nick :[::msgcat::mc "Network is now showed"]"
  401.                 } elseif { $arg == "no" } {
  402.                         set ::crelay::snet "n"
  403.                         puthelp "NOTICE $nick :[::msgcat::mc "Network is now hidden"]"
  404.                 } else {
  405.                         puthelp "NOTICE $nick :[::msgcat::mc "You must chose yes or no"]"
  406.                         return 0
  407.                 }
  408.                 ::crelay::save
  409.         }
  410.  
  411.         proc set:syn_topic {nick host handle arg} {
  412.                 set arg [string tolower $arg]
  413.                 if { $arg == "yes" } {
  414.                         set ::crelay::syn_topic "y"
  415.                         puthelp "NOTICE $nick :[::msgcat::mc "Topic synchro is now enabled"]"
  416.                 } elseif { $arg == "no" } {
  417.                         set ::crelay::syn_topic "n"
  418.                         puthelp "NOTICE $nick :[::msgcat::mc "Topic synchro is now disabled"]"
  419.                 } else {
  420.                         puthelp "NOTICE $nick :[::msgcat::mc "You must chose yes or no"]"
  421.                         return 0
  422.                 }
  423.         }
  424.  
  425.         proc set:debug { nick host handle arg} {
  426.                 set arg [string tolower $arg]
  427.                 if { $arg == "yes" } {
  428.                         set ::crelay::debug 1
  429.                         puthelp "NOTICE $nick :[::msgcat::mc "Debug mode is now enabled"]"
  430.                 } elseif { $arg == "no" } {
  431.                         set ::crelay::debug 0
  432.                         puthelp "NOTICE $nick :[::msgcat::mc "Debug mode is now disabled"]"
  433.                 } else {
  434.                         puthelp "NOTICE $nick :[::msgcat::mc "Debug mode is actually setted to %1\$s" $::crelay::debug]"
  435.                         return 0
  436.                 }
  437.         }
  438.  
  439.         # proc setting of transmission by msg
  440.         proc set:trans { nick host handle arg } {
  441.                 if { $::crelay::me(transmit) == "y" } {
  442.                         if { $arg == "" } {
  443.                                 putquick "NOTICE $nick :[::msgcat::mc "You'd better try /msg %1\$s trans help" $::botnick]"
  444.                        }
  445.                        if { [lindex [split $arg] 0] == "help" } {
  446.                                putquick "NOTICE $nick :[::msgcat::mc "Usage is /msg %1\$s trans <setting> on|off" $::botnick]"
  447.                                putquick "NOTICE $nick :[::msgcat::mc "with <setting> in pub, act, nick, join, part, quit, topic, kick, mode, who"]"
  448.                                return 0
  449.                        } else {
  450.                                switch [lindex [split $arg] 0] {
  451.                                        "pub" { set type pubm }
  452.                                        "act" { set type ctcp }
  453.                                        "nick" { set type nick }
  454.                                        "join" { set type join }
  455.                                        "part" { set type part }
  456.                                        "quit" { set type sign }
  457.                                        "topic" { set type topc }
  458.                                        "kick" { set type kick }
  459.                                        "mode" { set type mode }
  460.                                        "who" { set type who }
  461.                                        default {
  462.                                                putquick "NOTICE $nick :[::msgcat::mc "Bad setting. Try /msg %1\$s trans help" $::botnick]"
  463.                                                return 0
  464.                                        }
  465.                                }
  466.                                set proc_change "::crelay::trans:[lindex [split $arg] 0]"
  467.                                set mod_change "::crelay::trans_[lindex [split $arg] 0]"
  468.                                if { [lindex [split $arg] 1] eq "on" } {
  469.                                        if { $type eq "mode" } {
  470.                                                bind raw - "MODE" ::crelay::trans:mode
  471.                                        } else {
  472.                                                bind $type - * $proc_change
  473.                                        }
  474.                                        if { $type eq "sign"} {
  475.                                                bind evnt - disconnect-server ::crelay::trans:selfquit
  476.                                        }
  477.                                        set ${mod_change} "y"
  478.                                        putserv "NOTICE $nick :[::msgcat::mc "Transmission of %1\$s enabled" [lindex [split $arg] 0]]"
  479.                                } elseif { [lindex [split $arg] 1] eq "off" } {
  480.                                        if { $type eq "mode" } {
  481.                                                unbind raw - "MODE" ::crelay::trans:mode
  482.                                        } else {
  483.                                                unbind $type - * $proc_change
  484.                                        }
  485.                                        if { $type eq "sign"} {
  486.                                                unbind evnt - disconnect-server ::crelay::trans:selfquit
  487.                                        }
  488.                                        set ${mod_change} "n"
  489.                                        putserv "NOTICE $nick :[::msgcat::mc "Transmission of %1\$s disabled" [lindex [split $arg] 0]]"
  490.                                } else {
  491.                                        putquick "NOTICE $nick :[::msgcat::mc "%1\$s is not a correct value, choose \002on\002 or \002off\002" [lindex [split $arg] 1]]"
  492.                                }
  493.                        }
  494.                } else {
  495.                        putquick "NOTICE $nick :[::msgcat::mc "Transmission is not activated, you can't change anything"]"
  496.                 }
  497.                 ::crelay::save
  498.         }
  499.  
  500.         # proc setting of reception by msg
  501.         proc set:recv { nick host handle arg } {
  502.                 if { $::crelay::me(receive) == "y" } {
  503.                         if { $arg == "" } {
  504.                                 putquick "NOTICE $nick :[::msgcat::mc "You'd better try /msg %1\$s recv help" $::botnick]"
  505.                        }
  506.                        if { [lindex [split $arg] 0] == "help" } {
  507.                                putquick "NOTICE $nick :[::msgcat::mc "Usage is /msg %1\$s recv <setting> on|off" $::botnick]"
  508.                                putquick "NOTICE $nick :[::msgcat::mc "with <setting> in pub, act, nick, join, part, quit, topic, kick, mode, who"]"
  509.                                return 0
  510.                        } else {
  511.                                switch [lindex [split $arg] 0] {
  512.                                        "pub" -
  513.                                        "act" -
  514.                                        "nick" -
  515.                                        "join" -
  516.                                        "part" -
  517.                                        "quit" -
  518.                                        "topic" -
  519.                                        "kick" -
  520.                                        "mode" -
  521.                                        "who" { set type [lindex [split $arg] 0] }
  522.                                        default {
  523.                                                putquick "NOTICE $nick :[::msgcat::mc "Bad setting. Try /msg %1\$s recv help" $::botnick]"
  524.                                                return 0
  525.                                        }
  526.                                }
  527.                                set change ">$type"
  528.                                set proc_change "::crelay::recv:$type"
  529.                                set mod_change "::crelay::recv_$type"
  530.                                if { [lindex [split $arg] 1] eq "on" } {
  531.                                        bind bot - $change $proc_change
  532.                                        set ${mod_change} "y"
  533.                                        putserv "NOTICE $nick :[::msgcat::mc "Reception of %1\$s enabled" $type]"
  534.                                } elseif { [lindex [split $arg] 1] == "off" } {
  535.                                        unbind bot - $change $proc_change
  536.                                        set ${mod_change} "n"
  537.                                        putserv "NOTICE $nick :[::msgcat::mc "Reception of %1\$s disabled" $type]"
  538.                                } else {
  539.                                        putquick "NOTICE $nick :[::msgcat::mc "%1\$s is not a correct value, choose \002on\002 or \002off\002" [lindex [split $arg] 1]]"
  540.                                }
  541.                        }
  542.                } else {
  543.                        putquick "NOTICE $nick :[::msgcat::mc "Reception is not activated, you can't change anything"]"
  544.                 }
  545.                 ::crelay::save
  546.         }
  547.  
  548.         # Generates an user@network name
  549.         # based on nick and from bot using usermask setting
  550.         proc make:user { nick frm_bot } {
  551.                 if {[string length $::crelay::hlnick] > 0 } {
  552.                         set ehlnick [string index $::crelay::hlnick 0]
  553.                 } else {
  554.                         set ehlnick ""
  555.                 }
  556.                 set umask $::crelay::me(usermask)
  557.                 array set him $::crelay::regg($frm_bot)
  558.                 regsub -all %network% $umask $him(network) umask
  559.                 if {$nick == "*"} {
  560.                         regsub -all {(%nick%|@)} $umask "" umask
  561.                         set speaker [concat "$::crelay::hlnick$umask$ehlnick"]
  562.                 } else {
  563.                         regsub -all %nick% $umask $nick umask
  564.                         set speaker $::crelay::hlnick$umask$ehlnick
  565.                 }
  566.                 return $speaker
  567.         }
  568.  
  569.         # Logs virtual channel activity
  570.         proc cr:log { lev chan line } {
  571.                 if { $::crelay::me(log) == "y" } {
  572.                         putloglev $lev "$chan" "$line"
  573.                 }
  574.                 return 0
  575.         }
  576.  
  577.         # Global transmit procedure
  578.         proc trans:bot { usercmd chan usernick text } {
  579.                 if { $::crelay::debug == 1 } { dlog "Transmission $usercmd from $usernick / $chan" }
  580.                 if {[llength $::crelay::users_only]>0 && [lsearch -nocase $::crelay::users_only $usernick]==-1} {
  581.                         return 0
  582.                 }
  583.                 if {[llength $::crelay::users_excluded]>0 && [lsearch -nocase $::crelay::users_excluded $usernick]!=-1} {
  584.                         return 0
  585.                 }
  586.                 set transmsg [concat $usercmd $usernick $text]
  587.                 set ::crelay::eob 0
  588.                 if {[string tolower $chan] == [string tolower $::crelay::me(chan)]} {
  589.                         foreach bot [array names ::crelay::regg] {
  590.                                 if {$bot != $::username && [islinked $bot]} {
  591.                                         putbot $bot $transmsg
  592.                                         if { $::crelay::debug == 1 } { dlog "Sent to $bot : $transmsg" }
  593.                                         if {$usercmd == ">who" } { incr ::crelay::eob }
  594.                                 }
  595.                         }
  596.  
  597.                 } else {
  598.                         return 0
  599.                 }
  600.         }
  601.  
  602.         # proc transmission of pub (trans_pub = y)
  603.         proc trans:pub {nick uhost hand chan text} {
  604.                 if { [string tolower [lindex [split $text] 0]] eq "!who" } { return 0; }
  605.                 if { [string tolower [lindex [split $text] 0]] eq "@topic" } { return 0; }
  606.                 if { [string tolower [lindex [split $text] 0]] eq "@mode" } { return 0; }
  607.                 if { [string tolower [lindex [split $text] 0]] eq "@ban" } { return 0; }
  608.                 if { [string tolower [lindex [split $text] 0]] eq "@kick" } { return 0; }
  609.                 foreach splmsg [::crelay::split_line $text [expr {$::crelay::msglen - [::tcl::string::length [::crelay::make:user $nick $::username]]}]] {
  610.                         if { $::crelay::debug == 1 } { dlog "Prepare transmission : >pub $chan $nick $splmsg" }
  611.                         ::crelay::trans:bot ">pub" $chan $nick $splmsg
  612.                 }
  613.         }
  614.  
  615.         # proc transmission of action (trans_act = y)
  616.         proc trans:act {nick uhost hand chan key text} {
  617.                 set arg [concat $key $text]
  618.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >act $chan $nick $arg" }
  619.                 ::crelay::trans:bot ">act" $chan $nick $arg
  620.         }
  621.  
  622.         # proc transmission of nick changement
  623.         proc trans:nick {nick uhost hand chan newnick} {
  624.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >nick $chan $nick $newnick" }
  625.                 ::crelay::trans:bot ">nick" $chan $nick $newnick
  626.         }
  627.  
  628.         # proc transmission of join
  629.         proc trans:join {nick uhost hand chan} {
  630.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >join $chan $chan $nick" }
  631.                 ::crelay::trans:bot ">join" $chan $chan "$nick!$uhost"
  632.         }
  633.  
  634.         # proc transmission of part
  635.         proc trans:part {nick uhost hand chan text} {
  636.                 set arg [concat $chan $text]
  637.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >part $chan $nick $arg" }
  638.                 ::crelay::trans:bot ">part" $chan $nick $arg
  639.         }
  640.  
  641.         # proc transmission of quit
  642.         proc trans:quit {nick host hand chan text} {
  643.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >quit $chan $nick $text" }
  644.                 ::crelay::trans:bot ">quit" $chan $nick $text
  645.         }
  646.  
  647.         # Proc to get our self quit
  648.         proc trans:selfquit {type} {
  649.                 ::crelay::trans:bot ">quit" $::crelay::me(chan) $::botnick [::msgcat::mc "I don't know why but I left server"]
  650.         }
  651.  
  652.         # proc transmission of topic changement
  653.         proc trans:topic {nick uhost hand chan topic} {
  654.                 if {$::crelay::topicsynced == 1 && [string tolower $nick] eq [string tolower $::botnick]} { return 0 }
  655.                 set arg [concat $chan $topic]
  656.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >topic $chan $nick $arg" }
  657.                 ::crelay::trans:bot ">topic" $chan $nick $arg
  658.         }
  659.  
  660.         # proc transmission of kick
  661.         proc trans:kick {nick uhost hand chan victim reason} {
  662.                 set arg [concat $victim $chan $reason]
  663.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >kick $chan $nick $arg" }
  664.                 ::crelay::trans:bot ">kick" $chan $nick $arg
  665.         }
  666.  
  667.         # proc transmission of mode changement
  668.         proc trans:mode {from keyw text} {
  669.                 set nick [lindex [split $from !] 0]
  670.                 set chan [lindex [split $text] 0]
  671.                 set text [concat $nick $text]
  672.                 if { $::crelay::debug == 1 } { dlog "Prepare transmission : >mode $chan $nick $text" }
  673.                 ::crelay::trans:bot ">mode" $chan $nick $text
  674.         }
  675.  
  676.         # proc transmission of "who command"
  677.         proc trans:who {nick uhost handle chan args} {
  678.                 if { [join [lindex [split $args] 0]] != "" } {
  679.                         set netindex [lsearch -nocase $::crelay::networks [lindex [split $args] 0]]
  680.                         if { $netindex == -1 } {
  681.                                 putserv "PRIVMSG $nick :[::msgcat::mc "%1\$s is an unknown network" $args]";
  682.                                 return 0
  683.                         } else {
  684.                            set ::crelay::eol 0
  685.                            set ::crelay::bol 0
  686.                                         set ::crelay::eob 1
  687.                                 putbot [lindex $::crelay::eggdrops $netindex] ">who $nick"
  688.                         }
  689.                 } else {
  690.                         set ::crelay::eol 0
  691.                         set ::crelay::bol 0
  692.                         ::crelay::trans:bot ">who" $chan $nick ""
  693.                 }
  694.         }
  695.  
  696.         # Error reception
  697.         proc recv:error {frm_bot command arg} {
  698.                 # putlog "$command - $arg"
  699.                 return 0
  700.         }
  701.  
  702.         # proc reception of pub
  703.         proc recv:pub {frm_bot command arg} {
  704.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  705.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  706.                         set argl [split $arg]
  707.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  708.                         if { $::crelay::debug == 1 } { dlog "Sending pub [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  709.                         putchan $::crelay::me(chan) "$speaker [join [lrange $argl 1 end]]"
  710.                         ::crelay::cr:log p "$::crelay::me(chan)" "<[lindex $argl 0]> [join [lrange $argl 1 end]]"
  711.                 } else {
  712.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  713.                 }
  714.                 return 0
  715.         }
  716.  
  717.         # proc reception of action
  718.         proc recv:act {frm_bot command arg} {
  719.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  720.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  721.                         set argl [split $arg]
  722.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  723.                         if { $::crelay::debug == 1 } { dlog "Sending act [join [lrange $argl 2 end]] to $::crelay::me(chan)" }
  724.                         set text [::crelay::colorize "act" "* $speaker [join [lrange $argl 2 end]]"]
  725.                         putchan $::crelay::me(chan) $text
  726.                         ::crelay::cr:log p "$::crelay::me(chan)" "Action: [lindex $argl 0] [join [lrange $argl 2 end]]"
  727.                 } else {
  728.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  729.                 }
  730.                 return 0
  731.         }
  732.  
  733.         # proc reception of nick changement
  734.         proc recv:nick {frm_bot command arg} {
  735.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  736.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  737.                         set argl [split $arg]
  738.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  739.                         if { $::crelay::debug == 1 } { dlog "Sending nick [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  740.                         set text [::crelay::colorize "jpq" [::msgcat::mc "*** %1\$s is now known as %2\$s" $speaker [join [lrange $argl 1 end]]]]
  741.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  742.                         ::crelay::cr:log j "$::crelay::me(chan)" "Nick change: [lindex $argl 0] -> [join [lrange $argl 1 end]]"
  743.                 } else {
  744.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  745.                 }
  746.                 return 0
  747.         }
  748.  
  749.         # proc reception of join
  750.         proc recv:join {frm_bot command arg} {
  751.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  752.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  753.                         set argl [split $arg]
  754.                         set speaker [lindex $argl 1]
  755.                         if { $::crelay::debug == 1 } { dlog "Sending join [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  756.                         set text [::crelay::colorize "jpq" [::msgcat::mc "--> %1\$s has joined %2\$s@%3\$s" $speaker [lindex $argl 0] [lindex $::crelay::networks $him]]]
  757.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  758.                         ::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 1] joined $::crelay::me(chan)."
  759.                 } else {
  760.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  761.                 }
  762.                 return 0
  763.         }
  764.  
  765.         # proc reception of part
  766.         proc recv:part {frm_bot command arg} {
  767.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  768.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  769.                         set argl [split $arg]
  770.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  771.                         if { $::crelay::debug == 1 } { dlog "Sending part [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  772.                         if {[llength $argl]<4} {
  773.                                 set partmsg ""
  774.                         } else {
  775.                                 set partmsg " ([join [lrange $argl 2 end]])"
  776.                         }
  777.                         set text [::crelay::colorize "jpq" [::msgcat::mc "<-- %1\$s has left %2\$s%3\$s" $speaker [lindex $argl 1] $partmsg]]
  778.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  779.                         ::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 0] left $::crelay::me(chan) ([join [lrange $argl 2 end]])"
  780.                 } else {
  781.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  782.                 }
  783.                 return 0
  784.         }
  785.  
  786.         # proc reception of quit
  787.         proc recv:quit {frm_bot command arg} {
  788.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  789.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  790.                         set argl [split $arg]
  791.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  792.                         if {[llength $argl]<3} {
  793.                                 set quitmsg ""
  794.                         } else {
  795.                                 set quitmsg " ([join [lrange $argl 1 end]])"
  796.                         }
  797.                         if { $::crelay::debug == 1 } { dlog "Sending quit [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  798.                         set text [::crelay::colorize "jpq" [::msgcat::mc "-//- %1\$s has quit%2\$s" $speaker $quitmsg]]
  799.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  800.                         ::crelay::cr:log j "$::crelay::me(chan)" "[lindex $argl 0] left irc: ([join [lrange $argl 1 end]])"
  801.                 } else {
  802.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  803.                 }
  804.                 return 0
  805.         }
  806.  
  807.         # proc reception of topic changement
  808.         proc recv:topic {frm_bot command arg} {
  809.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  810.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  811.                         set argl [split $arg]
  812.                         set speaker [::crelay::make:user [lindex $argl 0] $frm_bot]
  813.                         if { $::crelay::debug == 1 } { dlog "Sending topic [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  814.                         if { $::crelay::me(syn_topic) == "y" } {
  815.                                 set ::crelay::topicsynced 1
  816.                                 utimer 10 [list set ::crelay::topicsynced 0]
  817.                                 putserv "TOPIC $::crelay::me(chan) :[join [lrange $argl 2 end]]"
  818.                         } else {
  819.                                 putchan $::crelay::me(chan) [::msgcat::mc "*** %1\$s changes topic of %2\$s to '%3\$s'" $speaker [lindex $argl 1] [join [lrange $argl 2 end]]]
  820.                         }
  821.                 } else {
  822.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  823.                 }
  824.                 return 0
  825.         }
  826.  
  827.         # proc reception of kick
  828.         proc recv:kick {frm_bot command arg} {
  829.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  830.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  831.                         set argl [split $arg]
  832.                         set speaker [::crelay::make:user [lindex $argl 1] $frm_bot]
  833.                         if { $::crelay::debug == 1 } { dlog "Sending kick [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  834.                         set text [::crelay::colorize "jpq" [::msgcat::mc "*** %1\$s has been kicked from %2\$s by %3\$s: %4\$s" $speaker [lindex $argl 2] [lindex $argl 0] [join [lrange $argl 3 end]]]]
  835.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  836.                         ::crelay::cr:log k "$::crelay::me(chan)" "[lindex $argl 1] kicked from $::crelay::me(chan) by [lindex $argl 0]:[join [lrange $argl 3 end]]"
  837.                 } else {
  838.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  839.                 }
  840.                 return 0
  841.         }
  842.  
  843.         # proc reception of mode changement
  844.         proc recv:mode {frm_bot command arg} {
  845.                 if { $::crelay::debug == 1 } { dlog "Received $command from $frm_bot" }
  846.                 if {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  847.                         set argl [split $arg]
  848.                         set speaker [::crelay::make:user [lindex $argl 1] $frm_bot]
  849.                         if { $::crelay::debug == 1 } { dlog "Sending mode [join [lrange $argl 1 end]] to $::crelay::me(chan)" }
  850.                         set text [::crelay::colorize "mode" [::msgcat::mc "*** %1\$s set mode %2\$s" $speaker [join [lrange $argl 2 end]]]]
  851.                         putquick "PRIVMSG $::crelay::me(chan) :$text"
  852.                 } else {
  853.                         if { $::crelay::debug == 1 } { dlog "$frm_bot is unknown" }
  854.                 }
  855.                 return 0
  856.         }
  857.  
  858.         # reception of !who command
  859.         proc recv:who {frm_bot command arg} {
  860.                 set nick $arg
  861.                 set ulist ""
  862.                 set cusr 0
  863.                 if {![botonchan $::crelay::me(chan)]} {
  864.                         putbot $frm_bot ">wholist $::crelay::me(chan) $nick eol"
  865.                         return 0
  866.                 }
  867.                 foreach user [chanlist $::crelay::me(chan)] {
  868.                         if { $user == $::botnick } { continue; }
  869.                         if { [isop $user $::crelay::me(chan)] == 1 } {
  870.                                 set st "@"
  871.                         } elseif { [ishalfop $user $::crelay::me(chan)] == 1 } {
  872.                                 set st "%"
  873.                         } elseif { [isvoice $user $::crelay::me(chan)] == 1 } {
  874.                                 set st "+"
  875.                         } else {
  876.                                 set st ""
  877.                         }
  878.                         incr cusr 1
  879.                         append ulist " $st$user"
  880.                         if { $cusr == 5 } {
  881.                                 putbot $frm_bot ">wholist $::crelay::me(chan) $nick $ulist"
  882.                                 set ulist ""
  883.                                 set cusr 0
  884.                         }
  885.                 }
  886.                 if { $ulist != "" } {
  887.                         putbot $frm_bot ">wholist $::crelay::me(chan) $nick $ulist"
  888.                 }
  889.                 putbot $frm_bot ">wholist $::crelay::me(chan) $nick eol"
  890.         }
  891.  
  892.         # Proc reception of a who list
  893.         proc recv:wholist {frm_bot command arg} {
  894.                 set nick [join [lindex [split $arg] 1]]
  895.                 set speaker [::crelay::make:user $frm_bot $frm_bot]
  896.                 if {$::crelay::bol == 0} {
  897.                         incr ::crelay::bol
  898.                         putserv "NOTICE $nick :*** [::msgcat::mc "Beginning of userlist"]"
  899.                 }
  900.                 if { [join [lrange [split $arg] 2 end]] == "eol"} {
  901.                         incr ::crelay::eol
  902.                         if {$::crelay::eol == $::crelay::eob} {
  903.                                 putserv "NOTICE $nick :*** [::msgcat::mc "End of userlist"]"
  904.                         }
  905.                 } else {
  906.                         putserv "NOTICE $nick :$speaker [join [lrange [split $arg] 2 end]]"
  907.                 }
  908.         }
  909.  
  910.         ######################################
  911.         # Operators commands
  912.         #
  913.         proc trans:otopic {nick uhost handle chan text} {
  914.                 if {[::crelay::isOper $::username]==0} {
  915.                         putserv "NOTICE $nick :[::msgcat::mc "Sorry but I'm not setted as oper in ChanRelay"]"
  916.                        return 0
  917.                }
  918.                set netindex [::crelay::checkDest [join [lindex [split $text] 0]]]
  919.                if { $netindex == -1 } {
  920.                        putserv "NOTICE $nick :[::msgcat::mc "Syntax is @topic <network|all> the new topic"]"
  921.                        return 0
  922.                }
  923.                set topic [join [lrange [split $text] 1 end]]
  924.                if { $netindex < 99 } {
  925.                        putbot [lindex $::crelay::eggdrops $netindex] ">otopic $nick $topic"
  926.                } else {
  927.                        ::crelay::trans:bot ">otopic" $chan $nick $topic
  928.                        putserv "TOPIC $::crelay::me(chan) :$topic"
  929.                }
  930.                return 0
  931.        }
  932.  
  933.        proc recv:otopic {frm_bot command arg} {
  934.                if { [::crelay::isOper $frm_bot] != 1 } { return 0 }
  935.                set nick [join [lindex [split $arg] 0]]
  936.                if { ![::crelay::hasRights $::crelay::me(chan)] } {
  937.                        putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  938.                        return 0
  939.                }
  940.                set ::crelay::topicsynced 1
  941.                utimer 10 [list set ::crelay::topicsynced 0]
  942.                putserv "TOPIC $::crelay::me(chan) :[join [lrange [split $arg] 1 end]]"
  943.                return 0
  944.        }
  945.  
  946.        proc trans:opercmd {nick chan net com vict} {
  947.                if {[::crelay::isOper $::username]==0} {
  948.                        putserv "NOTICE $nick :[::msgcat::mc "Sorry but I'm not setted as oper in ChanRelay"]"
  949.                         return 0
  950.                 }
  951.                 if {[::crelay::checkDest $net] == -1} {
  952.                         putserv "NOTICE $nick :[::msgcat::mc "%1\$s is an unknown network" $net]"
  953.                         return 0
  954.                 }
  955.                 ::crelay::trans:omode $nick $uhost $handle $chan "$net $com $vict"
  956.         }
  957.  
  958.         proc trans:ovoice {nick uhost handle chan text} {
  959.                 if {![regexp {(\+|-)([^@]+)@([^\s]+)} $text - mod vict net]} {
  960.                         putserv "NOTICE $nick :[::msgcat::mc "Syntax is @voice <+/->nick@<network|all>"]"
  961.                 }
  962.                 ::crelay::trans:opercmd $nick $chan $net ${mod}v $vict
  963.         }
  964.  
  965.         proc trans:ohop {nick uhost handle chan text} {
  966.                 if {![regexp {(\+|-)([^@]+)@([^\s]+)} $text - mod vict net]} {
  967.                         putserv "NOTICE $nick :[::msgcat::mc "Syntax is @hop <+/->nick@<network|all>"]"
  968.                 }
  969.                 ::crelay::trans:opercmd $nick $chan $net ${mod}h $vict
  970.         }
  971.  
  972.         proc trans:oop {nick uhost handle chan text} {
  973.                 if {![regexp {(\+|-)([^@]+)@([^\s]+)} $text - mod vict net]} {
  974.                         putserv "NOTICE $nick :[::msgcat::mc "Syntax is @op <+/->nick@<network|all>"]"
  975.                 }
  976.                 ::crelay::trans:opercmd $nick $chan $net ${mod}o $vict
  977.         }
  978.  
  979.         proc trans:omode {nick uhost handle chan text} {
  980.                 if {[::crelay::isOper $::username]==0} {
  981.                         putserv "NOTICE $nick :[::msgcat::mc "Sorry but I'm not setted as oper in ChanRelay"]"
  982.                        return 0
  983.                }
  984.                set netindex [::crelay::checkDest [join [lindex [split $text] 0]]]
  985.                if { $netindex == -1 } {
  986.                        putserv "NOTICE $nick :[::msgcat::mc "Syntax is @mode <network|all> <+/-mode> \[arg\]\[,<+/-mode> \[arg\]...\]"]"
  987.                        return 0
  988.                }
  989.                set mode [join [lrange [split $text] 1 end]]
  990.                if { $netindex < 99 } {
  991.                        putbot [lindex $::crelay::eggdrops $netindex] ">omode $nick $mode"
  992.                } else {
  993.                        ::crelay::trans:bot ">omode" $chan $nick $mode
  994.                        foreach m [split $mode ","] {
  995.                                pushmode $::crelay::me(chan) $m
  996.                        }
  997.                        flushmode $::crelay::me(chan)
  998.                }
  999.                return 0
  1000.        }
  1001.  
  1002.        proc recv:omode {frm_bot command arg} {
  1003.                if { [::crelay::isOper $frm_bot] != 1 } { return 0 }
  1004.                set nick [join [lindex [split $arg] 0]]
  1005.                if { ![::crelay::hasRights $::crelay::me(chan)] } {
  1006.                        putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  1007.                        return 0
  1008.                }
  1009.                foreach mode [split [join [lrange [split $arg] 1 end]] ","] {
  1010.                        catch { pushmode $::crelay::me(chan) $mode }
  1011.                }
  1012.                flushmode $::crelay::me(chan)
  1013.                return 0
  1014.        }
  1015.  
  1016.        proc trans:okick {nick uhost handle chan text} {
  1017.                if {[::crelay::isOper $::username]==0} {
  1018.                        putserv "NOTICE $nick :[::msgcat::mc "Sorry but I'm not setted as oper in ChanRelay"]"
  1019.                         return 0
  1020.                 }
  1021.                 if {![regexp {([^@]+)@([^\s]+)(\s(.+))?} $text - vict net - reason] } {
  1022.                         putserv "NOTICE $nick :[msgcat::mc "Syntax is @kick nick@<network|all> \[reason of kicking\]"]"
  1023.                         return 0
  1024.                 }
  1025.                 set netindex [::crelay::checkDest $net]
  1026.                 if { $vict eq "" || $netindex == -1 } {
  1027.                         putserv "NOTICE $nick :[::msgcat::mc "%1\$s is an unknown network" $net]"
  1028.                         return 0
  1029.                 }
  1030.                 if { $netindex < 99 } {
  1031.                         putbot [lindex $::crelay::eggdrops $netindex] ">okick $chan $nick $vict $reason"
  1032.                 } else {
  1033.                         ::crelay::trans:bot ">okick" $chan $nick [concat $vict $reason]
  1034.                 }
  1035.                 return 0
  1036.         }
  1037.  
  1038.         proc recv:okick {frm_bot command arg} {
  1039.                 if { [::crelay::isOper $frm_bot] != 1 } { return 0 }
  1040.                 set nick [join [lindex [split $arg] 1]]
  1041.                 if { ![::crelay::hasRights $::crelay::me(chan)] } {
  1042.                         putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  1043.                         return 0
  1044.                 }
  1045.                 set vict [join [lindex [split $arg] 2]]
  1046.                 if {![onchan $vict $::crelay::me(chan)]} {
  1047.                    putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  1048.                 }
  1049.                 set reason [join [lrange [split $arg] 2 end]]
  1050.                 if { $reason eq "" } { set reason [::msgcat::mc "You have been kicked by %1\$s" $nick] }
  1051.                 putkick $::crelay::me(chan) $vict $reason
  1052.            return 0
  1053.         }
  1054.  
  1055.         proc trans:oban {nick uhost handle chan text} {
  1056.                 if {[::crelay::isOper $::username]==0} {
  1057.                         putserv "NOTICE $nick :[::msgcat::mc "Sorry but I'm not setted as oper in ChanRelay"]"
  1058.                        return 0
  1059.                }
  1060.                if {![regexp {([^@]+)@([^\s]+)(\s(.+))?} $text - vict net - reason]} {
  1061.                        putserv "NOTICE $nick :[::msgcat::mc "Syntax is @ban nick@<network|all> \[reason of banning\]"]"
  1062.                        return 0
  1063.                }
  1064.                set netindex [::crelay::checkDest $net]
  1065.                if { $vict eq "" || $netindex == -1 } {
  1066.                        putserv "NOTICE $nick :[::msgcat::mc "%1\$s is an unknown network" $net]"
  1067.                        return 0
  1068.                }
  1069.                if { $netindex < 99 } {
  1070.                        putbot [lindex $::crelay::eggdrops $netindex] ">oban $chan $nick $vict $reason"
  1071.                } else {
  1072.                        ::crelay::trans:bot ">oban" $chan $nick [concat $vict $reason]
  1073.                }
  1074.                return 0
  1075.        }
  1076.  
  1077.        proc recv:oban {frm_bot command arg} {
  1078.                if { [::crelay::isOper $frm_bot] != 1 } { return 0 }
  1079.                set nick [join [lindex [split $arg] 1]]
  1080.                if { ![::crelay::hasRights $::crelay::me(chan)] } {
  1081.                        putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  1082.                        return 0
  1083.                }
  1084.                set vict [join [lindex [split $arg] 2]]
  1085.                if {![onchan $vict $::crelay::me(chan)]} {
  1086.                   putbot $frm_bot ">notop $::crelay::me(chan) $nick"
  1087.                }
  1088.                set reason [join [lrange [split $arg] 3 end]]
  1089.                if { $reason eq "" } { set reason [::msgcat::mc "You have been banned by %1\$s" $nick] }
  1090.                set bmask [::crelay::mask [getchanhost $vict $::crelay::me(chan)] $vict]
  1091.                pushmode $::crelay::me(chan) +b $bmask
  1092.                putkick $::crelay::me(chan) $vict $reason
  1093.                flushmode $::crelay::me(chan)
  1094.                return 0
  1095.        }
  1096.  
  1097.        # Special : botnet lost
  1098.        proc recv:disc {frm_bot} {
  1099.                if {$frm_bot == $::username} {
  1100.                        putchan $::crelay::me(chan) [::msgcat::mc "I'd left the relay"]
  1101.                } elseif {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  1102.                        set speaker [::crelay::make:user "*" $frm_bot]
  1103.                        putchan $::crelay::me(chan) [::msgcat::mc "*** We lose %1\$s (%2\$s leaves botnet)" $speaker $frm_bot]
  1104.                }
  1105.                return 0
  1106.        }
  1107.  
  1108.        # Special : botnet recover
  1109.        proc recv:link {frm_bot via} {
  1110.                if {$frm_bot == $::username} {
  1111.                        putchan $::crelay::me(chan) [::msgcat::mc "I'm back in the relay"]
  1112.                } elseif {[set him [lsearch $::crelay::eggdrops $frm_bot]] >= 0} {
  1113.                        set speaker [::crelay::make:user "*" $frm_bot]
  1114.                        putchan $::crelay::me(chan) [::msgcat::mc "*** %1\$s is back (%2\$s rejoined botnet)" $speaker $frm_bot]
  1115.                }
  1116.                return 0
  1117.        }
  1118.  
  1119.        ######################################
  1120.        # Private messaging
  1121.        #
  1122.  
  1123.        bind msg - "say" ::crelay::prv:say_send
  1124.        proc prv:say_send {nick uhost handle text} {
  1125.                set dest [join [lindex [split $text] 0]]
  1126.                set msg [join [lrange [split $text] 1 end]]
  1127.                set vict [join [lindex [split $dest @] 0]]
  1128.                set net [join [lindex [split $dest @] 1]]
  1129.                if { $vict == "" || $net == "" } {
  1130.                        putserv "PRIVMSG $nick :[::msgcat::mc "Use \002say nick@network your message to \037nick\037\002"]"
  1131.                        return 0
  1132.                }
  1133.                set him [lsearch -nocase $::crelay::networks $net]
  1134.                if { $him == -1 } {
  1135.                        putserv "PRIVMSG $nick :[::msgcat::mc "%1\$s is an unknown network." $net]";
  1136.                        putserv "PRIVMSG $nick :[::msgcat::mc "Available networks: %1\$s" [join [split $::crelay::networks]]]"
  1137.                        return 0
  1138.                }
  1139.                if { [string length $msg] == 0 } {
  1140.                        putserv "PRIVMSG $nick :[::msgcat::mc "Did you forget your message to %1\$s@%2\$s ?" $vict $net]"
  1141.                        return 0
  1142.                }
  1143.                putbot [lindex $::crelay::eggdrops $him] ">pvmsg $vict $nick@$::crelay::me(network) $msg"
  1144.        }
  1145.  
  1146.        bind bot - ">pvmsg" ::crelay::prv:say_get
  1147.        proc prv:say_get {frm_bot command arg} {
  1148.                set dest [join [lindex [split $arg] 0]]
  1149.                set from [join [lindex [split $arg] 1]]
  1150.                set msg [join [lrange [split $arg] 2 end]]
  1151.                if { [onchan $dest $::crelay::me(chan)] == 1 } {
  1152.                        putserv "PRIVMSG $dest :$from: $msg"
  1153.                }
  1154.        }
  1155.  
  1156.        proc putchan {chan msg} {
  1157.                if {[::tcl::string::match *c* [lindex [split [getchanmode $chan]] 0]]} {
  1158.                        regsub -all "\017" [stripcodes abcgru $msg] "" msg
  1159.                }
  1160.                putquick "PRIVMSG $chan :$msg"
  1161.        }
  1162.  
  1163.        ######################################
  1164.        # Small tools
  1165.        #
  1166.        proc checkDest { network } {
  1167.                if { $network eq "all" } { return 99 }
  1168.                set netindex [lsearch -nocase $::crelay::networks $network]
  1169.                if { $network ne "all" && $netindex == -1 } { return -1 }
  1170.                return $netindex
  1171.        }
  1172.  
  1173.        # Checks if eggdrop is @ or %
  1174.        proc hasRights { chan } {
  1175.                if { ![botisop $chan] && ![botishalfop $chan] } {
  1176.                        return 0
  1177.                }
  1178.                return 1
  1179.        }
  1180.  
  1181.        # Checks if bot is declared as oper
  1182.        proc isOper { bot } {
  1183.                if { [lsearch $::crelay::eggdrops $bot] == -1 } { return 0 }
  1184.                array set tmp $::crelay::regg($bot)
  1185.                if { [lsearch [array names tmp] "oper"] == -1 } { return 0 }
  1186.                if { $tmp(oper) ne "y" } { return 0 }
  1187.                return 1
  1188.        }
  1189.  
  1190.        # Generate a ban mask based on host and bantype
  1191.        proc mask {uhost nick} {
  1192.                switch -- $::crelay::bantype {
  1193.                        1 { set mask "*!*@[lindex [split $uhost @] 1]" }
  1194.                        2 { set mask "*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
  1195.                        3 { set mask "*!*$uhost" }
  1196.                        4 { set mask "*!*[lindex [split [maskhost $uhost] "!"] 1]" }
  1197.                        5 { set mask "*!*[lindex [split $uhost "@"] 0]*@[lindex [split $uhost "@"] 1]" }
  1198.                        6 { set mask "*$nick*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
  1199.                        7 { set mask "*$nick*!*@[lindex [split $uhost "@"] 1]" }
  1200.                        8 { set mask "$nick![lindex [split $uhost "@"] 0]@[lindex [split $uhost @] 1]" }
  1201.                        9 { set mask "$nick![lindex [split $uhost "@"] 0]@[lindex [split [maskhost $uhost] "@"] 1]" }
  1202.                        default { set mask "*!*@[lindex [split $uhost @] 1]" }
  1203.                }
  1204.                return $mask
  1205.        }
  1206.  
  1207.        # Split line function
  1208.        # based on MenzAgitat procedure
  1209.        # @see http://www.boulets.oqp.me/tcl/routines/tcl-toolbox-0014.html
  1210.        proc split_line {data limit} {
  1211.                incr limit -1
  1212.                if {$limit < 9} {
  1213.                        error "limit must be higher than 9"
  1214.                }
  1215.                if { [::tcl::string::bytelength $data] <= $limit } {
  1216.                        return [expr {$data eq "" ? [list ""] : [split $data "\n"]}]
  1217.                } else {
  1218.                        set middle_pos [expr round($limit / 2.0)]
  1219.                        set output ""
  1220.                        while {1} {
  1221.                                if { ([set cut_index [::tcl::string::first "\n" $data]] != -1) && ($cut_index <= $limit)} then {
  1222.                                } elseif {
  1223.                                        ([set cut_index [::tcl::string::last " " $data [expr {$limit + 1}]]] == -1)
  1224.                                        || ($cut_index < $middle_pos)
  1225.                                } then {
  1226.                                        set new_cut_index -1
  1227.                                        for {set i 0} {$i < 6} {incr i} {
  1228.                                                if {
  1229.                                                        ([::tcl::string::index $data [set test_cut_index [expr {$limit - $i}]]] eq "\003")
  1230.                                                        && ([regexp {^\003([0-9]{1,2}(,[0-9]{1,2})?)} [::tcl::string::range $data $test_cut_index end]])
  1231.                                                } then {
  1232.                                                        set new_cut_index [expr {$test_cut_index - 1}]
  1233.                                                }
  1234.                                        }
  1235.                                        set cut_index [expr {($new_cut_index == -1) ? ($limit) : ($new_cut_index)}]
  1236.                                }
  1237.                                set new_part [::tcl::string::range $data 0 $cut_index]
  1238.                                set data [::tcl::string::range $data $cut_index+1 end]
  1239.                                if { [::tcl::string::trim [::tcl::string::map [list \002 {} \037 {} \026 {} \017 {}] [regsub -all {\003([0-9]{0,2}(,[0-9]{0,2})?)?} $new_part {}]]] ne "" } {
  1240.                                        lappend output [::tcl::string::trimright $new_part]
  1241.                                }
  1242.                                if { [::tcl::string::trim [::tcl::string::map [list \002 {} \037 {} \026 {} \017 {}] [regsub -all {\003([0-9]{0,2}(,[0-9]{0,2})?)?} $data {}]]] eq "" } {
  1243.                                        break
  1244.                                }
  1245.                                set taglist [regexp -all -inline {\002|\003(?:[0-9]{0,2}(?:,[0-9]{0,2})?)?|\037|\026|\017} $new_part]
  1246.                                set bold 0 ; set underline 0 ; set italic 0 ; set foreground_color "-1" ; set background_color "-1"
  1247.                                foreach tag $taglist {
  1248.                                        if {$tag eq ""} {
  1249.                                                continue
  1250.                                        }
  1251.                                        switch -- $tag {
  1252.                                                "\002" { if { !$bold } { set bold 1 } { set bold 0 } }
  1253.                                                "\037" { if { !$underline } { set underline 1 } { set underline 0 } }
  1254.                                                "\026" { if { !$italic } { set italic 1 } { set italic 0 } }
  1255.                                                "\017" { set bold 0 ; set underline 0 ; set italic 0 ; set foreground_color "-1" ; set background_color "-1" }
  1256.                                                default {
  1257.                                                        lassign [split [regsub {\003([0-9]{0,2}(,[0-9]{0,2})?)?} $tag {\1}] ","] foreground_color background_color
  1258.                                                        if {$foreground_color eq ""} {
  1259.                                                                set foreground_color -1 ; set background_color -1
  1260.                                                        } elseif {($foreground_color < 10) && ([::tcl::string::index $foreground_color 0] ne "0")} {
  1261.                                                                set foreground_color 0$foreground_color
  1262.                                                        }
  1263.                                                        if {$background_color eq ""} {
  1264.                                                                set background_color -1
  1265.                                                        } elseif {
  1266.                                                                ($background_color < 10)
  1267.                                                                && ([::tcl::string::index $background_color 0] ne "0")
  1268.                                                        } then {
  1269.                                                                set background_color 0$background_color
  1270.                                                        }
  1271.                                                }
  1272.                                        }
  1273.                                }
  1274.                                set line_start ""
  1275.                                if {$bold} { append line_start \002 }
  1276.                                if {$underline} { append line_start \037 }
  1277.                                if {$italic} { append line_start \026 }
  1278.                                if {($foreground_color != -1) && ($background_color == -1)} { append line_start \003$foreground_color }
  1279.                                if {($foreground_color != -1) && ($background_color != -1)} { append line_start \003$foreground_color,$background_color }
  1280.                                set data ${line_start}${data}
  1281.                        }
  1282.                        return $output
  1283.                }
  1284.        }
  1285.  
  1286.        ######################################
  1287.        # proc for helping
  1288.        #
  1289.        # proc status
  1290.        proc help:status { nick host handle arg } {
  1291.                puthelp "PRIVMSG $nick :[::msgcat::mc "Chanrelay status for %1\$s@%2\$s" $::crelay::me(chan) $::crelay::me(network)]"
  1292.                puthelp "PRIVMSG $nick :[::msgcat::mc "\002 Global status\002"]"
  1293.                puthelp "PRIVMSG $nick :\037type\037   -- | trans -|- recept |"
  1294.                puthelp "PRIVMSG $nick :global -- | -- $::crelay::me(transmit) -- | -- $::crelay::me(receive) -- |"
  1295.                puthelp "PRIVMSG $nick :pub    -- | -- $::crelay::trans_pub -- | -- $::crelay::recv_pub -- |"
  1296.                puthelp "PRIVMSG $nick :act    -- | -- $::crelay::trans_act -- | -- $::crelay::recv_act -- |"
  1297.                puthelp "PRIVMSG $nick :nick   -- | -- $::crelay::trans_nick -- | -- $::crelay::recv_nick -- |"
  1298.                puthelp "PRIVMSG $nick :join   -- | -- $::crelay::trans_join -- | -- $::crelay::recv_join -- |"
  1299.                puthelp "PRIVMSG $nick :part   -- | -- $::crelay::trans_part -- | -- $::crelay::recv_part -- |"
  1300.                puthelp "PRIVMSG $nick :quit   -- | -- $::crelay::trans_quit -- | -- $::crelay::recv_quit -- |"
  1301.                puthelp "PRIVMSG $nick :topic  -- | -- $::crelay::trans_topic -- | -- $::crelay::recv_topic -- |"
  1302.                puthelp "PRIVMSG $nick :kick   -- | -- $::crelay::trans_kick -- | -- $::crelay::recv_kick -- |"
  1303.                puthelp "PRIVMSG $nick :mode   -- | -- $::crelay::trans_mode -- | -- $::crelay::recv_mode -- |"
  1304.                puthelp "PRIVMSG $nick :who    -- | -- $::crelay::trans_who -- | -- $::crelay::recv_who -- |"
  1305.                if { $::crelay::me(syn_topic) == "y"} {
  1306.                        puthelp "PRIVMSG $nick :[::msgcat::mc "Transmission of %1\$s enabled" "Topic"]"
  1307.                } else {
  1308.                        puthelp "PRIVMSG $nick :[::msgcat::mc "Transmission of %1\$s disabled" "Topic"]"
  1309.                }
  1310.                puthelp "PRIVMSG $nick :[::msgcat::mc "Nicks appears as %1\$s%2\$s%1\$s" $::crelay::hlnick $nick]"
  1311.                puthelp "PRIVMSG $nick :--- *** ---"
  1312.        }
  1313.  
  1314.        # proc help
  1315.        proc help:cmds { nick host handle arg } {
  1316.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s trans <type> on|off to change the transmissions" $::botnick]"
  1317.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s recv <type> on|off to change the receptions" $::botnick]"
  1318.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.status to see my actual status" $::botnick]"
  1319.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.help for this help" $::botnick]"
  1320.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.light <bo|un|gr|off> to bold, underline, gray or no higlight" $::botnick]"
  1321.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.net <yes|no> to (un)show the network" $::botnick]"
  1322.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.syntopic <yes|no> to disable/enable the topic synchronisation" $::botnick]"
  1323.                puthelp "NOTICE $nick :[::msgcat::mc "/msg %1\$s rc.debug \[<yes|no>\] to disable/enable the debug (no arg: display debug status)" $::botnick]"
  1324.        }
  1325.  
  1326.        # Debug log
  1327.        proc dlog {text} {
  1328.                set out [open ${::crelay::crpath}${::crelay::crlog} a]
  1329.                puts $out "\[[clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]\] <$::username> $text"
  1330.                close $out
  1331.        }
  1332. }
  1333.  
  1334. proc i18n {msgfile {lang {}} } {
  1335.   if {$lang == ""} {set lang [string range [::msgcat::mclocale] 0 1] }
  1336.   if { [catch {open $msgfile r} fmsg] } {
  1337.      putlog "\002ChanRelay\002 - Could not open $msgfile for reading\n$fmsg"
  1338.   } else {
  1339.      putlog "\002ChanRelay\002 - Loading $lang file from $msgfile"
  1340.      while {[gets $fmsg line] >= 0} {
  1341.         lappend ll $line
  1342.      }
  1343.      close $fmsg
  1344.      ::msgcat::mcmset $lang [join $ll]
  1345.      unset ll
  1346.   }
  1347.   ::msgcat::mclocale $lang
  1348.   # Hack for badly managed locales
  1349.   if { [::msgcat::mc GREGORIAN_CHANGE_DATE] == "GREGORIAN_CHANGE_DATE"} {
  1350.      ::msgcat::mcset [::msgcat::mclocale] GREGORIAN_CHANGE_DATE 2299527
  1351.   }
  1352. }
  1353.  
  1354. if {![catch {package require msgcat}]} {
  1355.        ::msgcat::mclocale en
  1356.        # Hack for badly managed locales
  1357.        if { [::msgcat::mc GREGORIAN_CHANGE_DATE] == "GREGORIAN_CHANGE_DATE"} {
  1358.                ::msgcat::mcset [::msgcat::mclocale] GREGORIAN_CHANGE_DATE 2299527
  1359.        }
  1360.        if {$::crelay::lang != "" && [string tolower $::crelay::lang] != "english"} {
  1361.                set lfile "${::crelay::crpath}chanrelay.[string tolower $::crelay::lang].msg"
  1362.                if {[file exists $lfile]} {
  1363.                        i18n $lfile [::tcl::string::map {"english" "en" "french" "fr" "spanish" "sp" "german" "de" "portuguese" "pt"} [string tolower $::crelay::lang]]
  1364.                }
  1365.        }
  1366. } else {
  1367.        # short hack if msgcat cannot be load
  1368.        namespace eval ::msgcat {
  1369.                proc mc {text {str ""} args} { return [format $text $str $args] }
  1370.        }
  1371. }
  1372.  
  1373. ::crelay::init
  1374.  
  1375. putlog "CHANRELAY $::crelay::version by \002$::crelay::author\002 loaded - https://www.eggdrop.fr"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement