Advertisement
X-Anonymous-Y

oper_join.tcl

Jan 28th, 2024 (edited)
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 32.55 KB | None | 0 0
  1. namespace eval oper::join {
  2.   variable oj;
  3.   # oper_join.tcl --
  4.   #
  5.  
  6.   ### Version:
  7.   # 29.01.2024
  8.   #
  9.  
  10.   ### Copyright:
  11.   # CIRCLED C WITH OVERLAID BACKSLASH (c) 2023-2024 X-Anonymous-Y
  12.   #
  13.   ## Code sections copied and, if necessary, adapted to my wishes.
  14.   # (c) BLaCkShaDoW
  15.   #
  16.  
  17.   ### License:
  18.   # public domain (PD)
  19.   #
  20.  
  21.   ### Contact:
  22.   # irc.kn-v2.com #Eggdrop
  23.   #
  24.  
  25.   ### Help:
  26.   # Channel: .ojoin help
  27.   #
  28.  
  29.   ### Usage:
  30.   # To enable or disable oper join
  31.   # DCC: .chanset #channel +ojoin/-ojoin
  32.   # Channel: .ojoin set on/off
  33.   #
  34.  
  35.   ### ToDo:
  36.   # Add - .commands on dcc and private
  37.   # Add - Channel (+q) owner allways has access - on: --> Bot (+n) owner and channel (+o) operator allways has access
  38.   # Add - <protect> and <owner> - on: --> Available channel access options at the moment: <op>, <halfop> and <voice>
  39.   #
  40.  
  41.   ### Changes:
  42.   # 29.01.2024 (New feature) Added .ojoin (#channel) (X-Anonymous-Y)
  43.   # 29.01.2024 (Bug fix) Fixed some small bugs (X-Anonymous-Y)
  44.   # 28.01.2024 (Code cleaned) If clauses that are no longer needed have been deleted (X-Anonymous-Y)
  45.   # 28.01.2024 (New feature) Added regex to check set variables (X-Anonymous-Y)
  46.   # 25.01.2024 (Code changed) Added variable nsc [namespace current] and variable oj; for global usage. This makes the code a lot smaller and clearer (X-Anonymous-Y)
  47.   # 22.01.2024 (Code changed) Changed comments and variables (X-Anonymous-Y)
  48.   # 21.01.2024 (Code cleaned) Cleaned up comments and some code (X-Anonymous-Y)
  49.   # 14.01.2024 (New feature) Added pub .ojoin set <setting> support for channel (X-Anonymous-Y)
  50.   # 13.01.2024 (New feature) Added help, version output and ctcp version reply (X-Anonymous-Y)
  51.   # 11.01.2024 (New feature) Added access check (for bot flags and channel access) for commands (X-Anonymous-Y)
  52.   # 10.01.2024 (New feature) Copied and added multi language from BLaCkShaDoW for outputs (X-Anonymous-Y)
  53.   # 01.01.2024 (Code cleaned) The code has been cleaned according to all possible best practices (X-Anonymous-Y)
  54.   # 29.12.2023 (New feature) Added channel specific settings (X-Anonymous-Y)
  55.   # 28.12.2023 (New feature) Added multi channel support (X-Anonymous-Y)
  56.   # 25.11.2016 (Script created) Script functions considered and script created (Diamond85 - my old nick)
  57.   #
  58.  
  59.  
  60.   #
  61.   #
  62.   ### The configuration begins
  63.   #
  64.   #
  65.  
  66.  
  67.   ##
  68.   # Variable settings
  69.   ##
  70.   # Set the character you want to use for commands here.
  71.   # Format: "character"
  72.   # Examples: ".", "!", "^" ...
  73.   set oj(command:character) "."
  74.  
  75.   # Set here which command word you want to use.
  76.   # Format: "word"
  77.   # Examples: "oper_join", "ojoin", "oj" ...
  78.   set oj(command:word) "ojoin"
  79.  
  80.   # Set the default access here.
  81.   # These are the accesses required to enable/disable or change script settings.
  82.   # Bot (+n) owner and channel (+o) operator allways has access
  83.   # Format: "<channel_access_name> <+/-global_flags(|+/-channel_flags #channel)>"
  84.   # Examples: "halfop +mo|+mo #channel", "voice +mo|-", "op +o|-fm #chanel" ...
  85.   # "0 0" To allow everyone to use the commands. [I recommend not set this to "0 0"! But you can set it to "op 0" or "0 +n", for example]
  86.   #
  87.   # You can find all possible (Eggdrop) user flags here https://docs.eggheads.org/using/users.html
  88.   # Available channel access options at the moment: op, halfop and voice
  89.   #
  90.   # Usage: To change the access
  91.   # DCC: .chanset #channel ojoin-access halfop +o|-fm
  92.   # Channel: .ojoin set access halfop +o|-fm
  93.   set oj(access) "0 +n|+n"
  94.  
  95.   # Set the default language here.
  96.   # Format: "language"
  97.   # Available options: "en", English
  98.   #                    "de", Deutsch
  99.   #
  100.   # Usage: To change the language
  101.   # DCC: .chanset #channel ojoin-language de
  102.   # Channel: .ojoin set language de
  103.   set oj(language) "en"
  104.  
  105.   # Set here whether the replies in the channels should be sent in color by default.
  106.   # Format: "word"
  107.   # Available options: "on", "off"
  108.   #
  109.   # Usage: To enable or disable output color
  110.   # DCC: .chanset #channel ojoin-output_color off
  111.   # Channel: .ojoin set output color off
  112.   set oj(output:color) "on"
  113.  
  114.   # Set here whether the replies in the channels should be sent in length by default.
  115.   # Format: "word"
  116.   # Available options: "default", "long", "short"
  117.   #
  118.   # Usage: To change the output length
  119.   # DCC: .chanset #channel ojoin-output_length short
  120.   # Channel: .ojoin set output length short
  121.   set oj(output:length) "long"
  122.  
  123.  
  124.   #
  125.   #
  126.   ### End of configuration
  127.   #
  128.   #
  129.  
  130.  
  131.   ###
  132.   ### DO NOT EDIT ANYTHING BELOW HERE! UNLESS YOU KNOW WHAT YOU'RE DOING!
  133.   ###
  134.  
  135.  
  136.   ##
  137.   # Various variables
  138.   ##
  139.   # [various:variables] :
  140.   variable nsc [namespace current]
  141.   set oj(logo:default) "\002\[Oper Join\]\002"
  142.   set oj(logo:color) "\002\[Oper Join\]\002"
  143.   set oj(logo:putlog) "\002*** \[Oper Join\] ***\002"
  144.   set oj(title:default) "\002\[Oper Join\]\002"
  145.   set oj(title:color) "\002\[Oper Join\]\002"
  146.   set oj(title:putlog) "\002*** \[Oper Join\] ***\002"
  147.  
  148.  
  149.   ##
  150.   # Setudef
  151.   ##
  152.   # [setudef] :
  153.   setudef flag ojoin
  154.   setudef str ojoin-access
  155.   setudef str ojoin-language
  156.   setudef str ojoin-output_color
  157.   setudef str ojoin-output_length
  158.  
  159.  
  160.   ##
  161.   # Un/Binds | Init | Channel settings
  162.   ##
  163.   # [bind:evnt] :
  164.   bind evnt - loaded ${nsc}::init
  165.   bind evnt - prerehash ${nsc}::unbind:bindings
  166.   bind evnt - prerestart ${nsc}::unbind:bindings
  167.   bind evnt - rehash ${nsc}::init
  168.  
  169.   # [init] :
  170.   proc init {args} {
  171.     variable nsc;
  172.     variable oj;
  173.     foreach chan [channels] {
  174.       if {[info exists ${nsc}::oj(access)] && ([string trim $oj(access)] eq "")} {
  175.         putlog "$oj(title:putlog) \[Error\] Please check \002oper_join.tcl\002 --> \002set oj(access) \"$oj(access)\"\002"
  176.         return
  177.       } else {
  178.         if {([channel get $chan ojoin-access] eq "")} {
  179.           channel set $chan ojoin-access $oj(access)
  180.         }
  181.       }
  182.       if {[info exists ${nsc}::oj(language)] && ([string trim $oj(language)] eq "")} {
  183.         putlog "$oj(title:putlog) \[Error\] Please check \002oper_join.tcl\002 --> \002set oj(language) \"$oj(language)\"\002"
  184.         return
  185.       } else {
  186.         if {([channel get $chan ojoin-language] eq "")} {
  187.           channel set $chan ojoin-language $oj(language)
  188.         }
  189.       }
  190.       if {[info exists ${nsc}::oj(output:color)] && ([string trim $oj(output:color)] eq "")} {
  191.         putlog "$oj(title:putlog) \[Error\] Please check \002oper_join.tcl\002 --> \002set oj(output:color) \"$oj(output:color)\"\002"
  192.         return
  193.       } else {
  194.         if {([channel get $chan ojoin-output_color] eq "")} {
  195.           channel set $chan ojoin-output_color $oj(output:color)
  196.         }
  197.       }
  198.       if {[info exists ${nsc}::oj(output:length)] && ([string trim $oj(output:length)] eq "")} {
  199.         putlog "$oj(title:putlog) \[Error\] Please check \002oper_join.tcl\002 --> \002set oj(output:length) \"$oj(output:length)\"\002"
  200.         return
  201.       } else {
  202.         if {([channel get $chan ojoin-output_length] eq "")} {
  203.           channel set $chan ojoin-output_length $oj(output:length)
  204.         }
  205.       }
  206.     }
  207.     #global botnick
  208.     #bind pub -|- ${botnick} ${nsc}::pub:commands
  209.     bind pub -|- $oj(command:character)$oj(command:word) ${nsc}::pub:commands
  210.     bind join -|- * ${nsc}::add:channel:settings:on:bot:join
  211.     bind join -|- * ${nsc}::oper:join
  212.     bind ctcp -|- VERSION ${nsc}::version:reply
  213.   }
  214.  
  215.   # [unbind:bindings] :
  216.   proc unbind:bindings {args} {
  217.     variable nsc;
  218.     variable oj;
  219.     #global botnick
  220.     #unbind pub -|- ${botnick} ${nsc}::pub:commands
  221.     unbind pub -|- $oj(command:character)$oj(command:word) ${nsc}::pub:commands
  222.     unbind join -|- * ${nsc}::add:channel:settings:on:bot:join
  223.     unbind join -|- * ${nsc}::oper:join
  224.     unbind ctcp -|- VERSION ${nsc}::version:reply
  225.   }
  226.  
  227.   # [add:channel:settings:on:bot:join] :
  228.   proc add:channel:settings:on:bot:join {nick uhost hand chan} {
  229.     variable oj;
  230.     if {![isbotnick $nick]} {
  231.       return
  232.     } else {
  233.       if {([channel get $chan ojoin-access] eq "")} {
  234.         channel set $chan ojoin-access $oj(access)
  235.       }
  236.       if {([channel get $chan ojoin-language] eq "")} {
  237.         channel set $chan ojoin-language $oj(language)
  238.       }
  239.       if {([channel get $chan ojoin-output_color] eq "")} {
  240.         channel set $chan ojoin-output_color $oj(output:color)
  241.       }
  242.       if {([channel get $chan ojoin-output_length] eq "")} {
  243.         channel set $chan ojoin-output_length $oj(output:length)
  244.       }
  245.     }
  246.   }
  247.  
  248.  
  249.   ##
  250.   # Script information
  251.   ##
  252.   # [script:variables] :
  253.   set oj(tcl:name) "oper_join"
  254.   set oj(tcl:project:name) "ojoin"
  255.   set oj(tcl:author) "X-Anonymous-Y"
  256.   set oj(tcl:contact) "irc.kn-v2.com #Eggdrop"
  257.   set oj(tcl:copyright) "©"
  258.   set oj(tcl:year) "2023-2024"
  259.   set oj(tcl:version) "29.01.2024"
  260.   set oj(tcl:website) "https://pastebin.com/nbhTVsRb"
  261.  
  262.  
  263.   ##
  264.   # Commands
  265.   ##
  266.   # [pub:commands] :
  267.   proc pub:commands {nick uhost hand chan arg} {
  268.     variable nsc;
  269.     variable oj;
  270.     if {([lindex $arg 0] eq "$oj(command:word)")} {
  271.       set arg [join [lrange [split $arg] 1 end]]
  272.     } else {
  273.       set arg [join [lrange [split $arg] 0 end]]
  274.     }
  275.     if {[${nsc}::check:access 0 $hand $chan flags 0] || [${nsc}::check:access $nick 0 $chan channel_access 0] || [matchattr $hand "+n|+n"] || [isop $nick $chan]} {
  276.       if {[lindex $arg 0] eq "help"} {
  277.         ${nsc}::pub:help $nick $uhost $hand $chan $arg
  278.         return
  279.       } elseif {[lindex $arg 0] eq "set"} {
  280.         ${nsc}::pub:set $nick $uhost $hand $chan $arg
  281.         return
  282.       } elseif {[lindex $arg 0] eq "version"} {
  283.         ${nsc}::pub:version $nick $uhost $hand $chan $arg
  284.         return
  285.       } elseif {[lindex $arg 0] eq "stop"} {
  286.         ${nsc}::pub:stop:oper:join $nick $chan $arg
  287.         return
  288.       } else {
  289.         ${nsc}::pub:oper:join $nick $chan $arg
  290.         return
  291.       }
  292.     } else {
  293.       return
  294.     }
  295.   }
  296.  
  297.   # [pub:help] :
  298.   proc pub:help {nick uhost hand chan arg} {
  299.     variable nsc;
  300.     variable oj;
  301.     set trigger $oj(command:character)$oj(command:word)
  302.     set arg [join [lrange [split $arg] 1 end]]
  303.     set color [channel get $chan ojoin-output_color]
  304.     set length [channel get $chan ojoin-output_length]
  305.     if {[${nsc}::check:access 0 $hand $chan flags 0] || [${nsc}::check:access $nick 0 $chan channel_access 0] || [matchattr $hand "+n|+n"] || [isop $nick $chan]} {
  306.       if {[channel get $chan ojoin]} {
  307.         if {([lindex $arg 0] eq "")} {
  308.           ${nsc}::send:output $nick $chan notice slow help:optional $color $length none
  309.           ${nsc}::send:output $nick $chan notice slow help:help:nickname $color $length $trigger
  310.           ${nsc}::send:output $nick $chan notice slow help:help:set $color $length $trigger
  311.           ${nsc}::send:output $nick $chan notice slow help:help:set:examples $color $length $trigger
  312.           ${nsc}::send:output $nick $chan notice slow help:help:oper:join $color $length $trigger
  313.           ${nsc}::send:output $nick $chan notice slow help:version:nickname $color $length $trigger
  314.           #putlog "$oj(title:putlog) \[Info\] help from $nick ($uhost) on $chan"
  315.         } elseif {([lindex $arg 0] eq "set")} {
  316.           if {([lindex $arg 1] eq "language")} {
  317.             ${nsc}::send:output $nick $chan notice slow help:set:available:languages $color $length none
  318.             ${nsc}::send:output $nick $chan notice slow help:set:language:en:de $color $length none
  319.             #putlog "$oj(title:putlog) \[Info\] help set language from $nick ($uhost) on $chan"
  320.           } else {
  321.             ${nsc}::send:output $nick $chan notice slow help:set:required $color $length none
  322.             ${nsc}::send:output $nick $chan notice slow help:set:off $color $length $trigger
  323.             ${nsc}::send:output $nick $chan notice slow help:set:access $color $length $trigger
  324.             ${nsc}::send:output $nick $chan notice slow help:set:language $color $length $trigger
  325.             ${nsc}::send:output $nick $chan notice slow help:set:output:color $color $length $trigger
  326.             ${nsc}::send:output $nick $chan notice slow help:set:output:length $color $length $trigger
  327.             #putlog "$oj(title:putlog) \[Info\] help set from $nick ($uhost) on $chan"
  328.           }
  329.         } else {
  330.           if {[onchan [lindex $arg 0] $chan]} {
  331.             if {[${nsc}::check:access 0 0 $chan channel_access [lindex $arg 0]]} {
  332.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:full $color $length none
  333.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:help:nickname $color $length $trigger
  334.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:help:set $color $length $trigger
  335.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:help:set:examples $color $length $trigger
  336.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:help:oper:join $color $length $trigger
  337.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:version:nickname $color $length $trigger
  338.               #putlog "$oj(title:putlog) \[Info\] help for VIP [lindex $arg 0] from $nick ($uhost) on $chan"
  339.             } else {
  340.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help $color $length none
  341.               ${nsc}::send:output [lindex $arg 0] $chan notice slow help:version $color $length $trigger
  342.               #putlog "$oj(title:putlog) \[Info\] help for [lindex $arg 0] from $nick ($uhost) on $chan"
  343.             }
  344.           } else {
  345.             ${nsc}::send:output $nick $chan notice slow error:no:nick $color $length [list [lindex $arg 0] $chan]
  346.           }
  347.         }
  348.       } else {
  349.         ${nsc}::send:output $nick $chan notice slow help:optional $color $length none
  350.         ${nsc}::send:output $nick $chan notice slow help:set:on $color $length $trigger
  351.         ${nsc}::send:output $nick $chan notice slow help:version:nickname $color $length $trigger
  352.         #putlog "$oj(title:putlog) \[Info\] help from $nick ($uhost) on $chan"
  353.       }
  354.     } else {
  355.       if {[channel get $chan ojoin]} {
  356.         if {([lindex $arg 0] eq "")} {
  357.           ${nsc}::send:output $nick $chan notice slow help $color $length none
  358.           ${nsc}::send:output $nick $chan notice slow help:version $color $length $trigger
  359.           #putlog "$oj(title:putlog) \[Info\] help from $nick ($uhost) on $chan"
  360.         }
  361.       }
  362.     }
  363.   }
  364.  
  365.   # [pub:set] :
  366.   proc pub:set {nick uhost hand chan arg} {
  367.     global botnick
  368.     variable nsc;
  369.     variable oj;
  370.     set trigger $oj(command:character)$oj(command:word)
  371.     set arg [join [lrange [split $arg] 1 end]]
  372.     set color [channel get $chan ojoin-output_color]
  373.     set length [channel get $chan ojoin-output_length]
  374.     if {[channel get $chan ojoin]} {
  375.       if {([lindex $arg 0] eq "off")} {
  376.         channel set $chan -ojoin
  377.         putquick "SAMODE $chan -Yo ${botnick} ${botnick}"
  378.         ${nsc}::send:output $nick $chan notice slow info:is:now:arg $color $length [lindex $arg 0]
  379.         putlog "$oj(title:putlog) \[Info\] set off from $nick ($uhost) on $chan"
  380.       } elseif {([lindex $arg 0] eq "access")} {
  381.         if {([lindex $arg 1] eq "")} {
  382.           ${nsc}::send:output $nick $chan notice slow error:set:access $color $length $trigger
  383.         } else {
  384.           if {([lindex $arg 2] eq "")} {
  385.             ${nsc}::send:output $nick $chan notice slow error:set:access $color $length $trigger
  386.           } else {
  387.             channel set $chan ojoin-access [list [lindex $arg 1] [lindex $arg 2]]
  388.             ${nsc}::send:output $nick $chan notice slow info:set:access $color $length [list [lindex $arg 1] [lindex $arg 2]]
  389.             putlog "$oj(title:putlog) \[Info\] set access [lindex $arg 1] [lindex $arg 2] from $nick ($uhost) on $chan"
  390.           }
  391.         }
  392.       } elseif {([lindex $arg 0] eq "language")} {
  393.         if {([lindex $arg 1] eq "en") || ([lindex $arg 1] eq "english") || ([lindex $arg 1] eq "de") || ([lindex $arg 1] eq "german")} {
  394.           channel set $chan ojoin-language [lindex $arg 1]
  395.           ${nsc}::send:output $nick $chan notice slow info:set:language $color $length [lindex $arg 1]
  396.           putlog "$oj(title:putlog) \[Info\] set language [lindex $arg 1] from $nick ($uhost) on $chan"
  397.         } elseif {([lindex $arg 1] ne "en") && ([lindex $arg 1] ne "english") && ([lindex $arg 1] ne "de") && ([lindex $arg 1] ne "german") || ([lindex $arg 1] eq "")} {
  398.           ${nsc}::send:output $nick $chan notice slow error:set:language $color $length $trigger
  399.           ${nsc}::send:output $nick $chan notice slow help:set:required $color $length none
  400.           ${nsc}::send:output $nick $chan notice slow help:set:available:languages $color $length none
  401.           ${nsc}::send:output $nick $chan notice slow help:set:language:en:de $color $length none
  402.           #putlog "$oj(title:putlog) \[Info\] set language [lindex $arg 1 end] from $nick ($uhost) on $chan"
  403.         }
  404.       } elseif {([lindex $arg 0] eq "output")} {
  405.         if {([lindex $arg 1] eq "color")} {
  406.           if {([lindex $arg 2] eq "")} {
  407.             ${nsc}::send:output $nick $chan notice slow error:set:output:color $color $length $trigger
  408.           } else {
  409.             channel set $chan ojoin-output_color [lindex $arg 2]
  410.             ${nsc}::send:output $nick $chan notice slow info:set:output:color $color $length [lindex $arg 2]
  411.             putlog "$oj(title:putlog) \[Info\] set output color [lindex $arg 2] from $nick ($uhost) on $chan"
  412.           }
  413.         } elseif {([lindex $arg 1] eq "length")} {
  414.           if {([lindex $arg 2] eq "")} {
  415.             ${nsc}::send:output $nick $chan notice slow error:set:output:length $color $length $trigger
  416.           } else {
  417.             channel set $chan ojoin-output_length [lindex $arg 2]
  418.             ${nsc}::send:output $nick $chan notice slow info:set:output:length $color $length [lindex $arg 2]
  419.             putlog "$oj(title:putlog) \[Info\] set output length [lindex $arg 2] from $nick ($uhost) on $chan"
  420.           }
  421.         }
  422.       } elseif {([lindex $arg 0] eq "")} {
  423.         ${nsc}::send:output $nick $chan notice slow error:help:set $color $length $trigger
  424.       }
  425.     } else {
  426.       if {([lindex $arg 0] eq "on")} {
  427.         channel set $chan +ojoin
  428.         putquick "OJOIN $chan"
  429.         ${nsc}::send:output $nick $chan notice slow info:is:now:arg $color $length [lindex $arg 0]
  430.         putlog "$oj(title:putlog) \[Info\] set on from $nick ($uhost) on $chan"
  431.       } else {
  432.         ${nsc}::send:output $nick $chan notice slow error:is:off $color $length $trigger
  433.       }
  434.     }
  435.   }
  436.  
  437.   # [pub:version] :
  438.   proc pub:version {nick uhost hand chan arg} {
  439.     variable nsc;
  440.     variable oj;
  441.     set arg [join [lrange [split $arg] 1 end]]
  442.     set color [channel get $chan ojoin-output_color]
  443.     set length [channel get $chan ojoin-output_length]
  444.     if {[${nsc}::check:access 0 $hand $chan flags 0] || [${nsc}::check:access $nick 0 $chan channel_access 0] || [matchattr $hand "+n|+n"] || [isop $nick $chan]} {
  445.       if {[channel get $chan ojoin]} {
  446.         if {([lindex $arg 0] eq "")} {
  447.           ${nsc}::send:output $nick $chan notice slow info:version:arg $color $length [list $oj(tcl:name) $oj(tcl:project:name) $oj(tcl:version) $oj(tcl:copyright) $oj(tcl:year) $oj(tcl:author) $oj(tcl:contact) $oj(tcl:website) on]
  448.           #putlog "$oj(title:putlog) \[Info\] version from $nick ($uhost) on $chan"
  449.         } else {
  450.           if {[onchan [lindex $arg 0] $chan]} {
  451.             ${nsc}::send:output [lindex $arg 0] $chan notice slow info:version:arg $color $length [list $oj(tcl:name) $oj(tcl:project:name) $oj(tcl:version) $oj(tcl:copyright) $oj(tcl:year) $oj(tcl:author) $oj(tcl:contact) $oj(tcl:website) on]
  452.             #putlog "$oj(title:putlog) \[Info\] version [lindex $arg 0] from $nick ($uhost) on $chan"
  453.           } else {
  454.             ${nsc}::send:output $nick $chan notice slow error:no:nick $color $length [list [lindex $arg 0] $chan]
  455.           }
  456.         }
  457.       } else {
  458.         if {([lindex $arg 0] eq "")} {
  459.           ${nsc}::send:output $nick $chan notice slow info:version:arg $color $length [list $oj(tcl:name) $oj(tcl:project:name) $oj(tcl:version) $oj(tcl:copyright) $oj(tcl:year) $oj(tcl:author) $oj(tcl:contact) $oj(tcl:website) off]
  460.           #putlog "$oj(title:putlog) \[Info\] version from $nick ($uhost) on $chan"
  461.         } else {
  462.           if {[onchan [lindex $arg 0] $chan]} {
  463.             ${nsc}::send:output [lindex $arg 0] $chan notice slow info:version:arg $color $length [list $oj(tcl:name) $oj(tcl:project:name) $oj(tcl:version) $oj(tcl:copyright) $oj(tcl:year) $oj(tcl:author) $oj(tcl:contact) $oj(tcl:website) off]
  464.             #putlog "$oj(title:putlog) \[Info\] version [lindex $arg 0] from $nick ($uhost) on $chan"
  465.           } else {
  466.             ${nsc}::send:output $nick $chan notice slow error:no:nick $color $length [list [lindex $arg 0] $chan]
  467.           }
  468.         }
  469.       }
  470.     } else {
  471.       if {[channel get $chan ojoin]} {
  472.         ${nsc}::send:output $nick $chan notice slow info:version:arg $color $length [list $oj(tcl:name) $oj(tcl:project:name) $oj(tcl:version) $oj(tcl:copyright) $oj(tcl:year) $oj(tcl:author) $oj(tcl:contact) $oj(tcl:website) off]
  473.         #putlog "$oj(title:putlog) \[Info\] version from $nick ($uhost) on $chan"
  474.       }
  475.     }
  476.   }
  477.  
  478.   # [pub:oper:join] :
  479.   proc pub:oper:join {nick chan arg} {
  480.     variable nsc;
  481.     set color [channel get $chan ojoin-output_color]
  482.     set length [channel get $chan ojoin-output_length]
  483.     if {($arg eq "")} {
  484.       set chan $chan
  485.     } else {
  486.       set chan $arg
  487.     }
  488.     if {[validchan $chan]} {
  489.       if {[botonchan $chan]} {
  490.         putquick "OJOIN $chan"
  491.       } else {
  492.         ${nsc}::send:output $nick $chan notice slow error:not:on:chan $color $length $chan
  493.       }
  494.     } else {
  495.       ${nsc}::send:output $nick $chan notice slow error:chan:not:valid $color $length $chan
  496.     }
  497.   }
  498.  
  499.   # [pub:stop:oper:join] :
  500.   proc pub:stop:oper:join {nick chan arg} {
  501.     global botnick
  502.     variable nsc;
  503.     set arg [join [lrange [split $arg] 1 end]]
  504.     set color [channel get $chan ojoin-output_color]
  505.     set length [channel get $chan ojoin-output_length]
  506.     if {($arg eq "")} {
  507.       set chan $chan
  508.     } else {
  509.       set chan $arg
  510.     }
  511.     if {[validchan $chan]} {
  512.       if {[botonchan $chan]} {
  513.         putquick "SAMODE $chan -Y ${botnick}"
  514.       } else {
  515.         ${nsc}::send:output $nick $chan notice slow error:not:on:chan $color $length $chan
  516.       }
  517.     } else {
  518.       ${nsc}::send:output $nick $chan notice slow error:chan:not:valid $color $length $chan
  519.     }
  520.   }
  521.  
  522.  
  523.   ##
  524.   # Actions
  525.   ##
  526.   # [oper:join] :
  527.   proc oper:join {nick uhost hand chan} {
  528.     if {[isbotnick $nick]} {
  529.       if {[channel get $chan ojoin]} {
  530.         putquick "ojoin $chan"
  531.         putlog "$oj(title:putlog) \[Info\] Using oper join on $chan"
  532.       }
  533.     }
  534.   }
  535.  
  536.  
  537.   ##
  538.   # Access
  539.   ##
  540.   # [check:access] : for nick or arg
  541.   proc check:access {nick hand chan type arg} {
  542.     if {([channel get $chan ojoin-access] eq "0 0")} {
  543.       return 1
  544.     }
  545.     set get_channel_access [lindex [channel get $chan ojoin-access] 0]
  546.     set get_user_flags [lindex [channel get $chan ojoin-access] 1 end]
  547.     if {($type eq "flags")} {
  548.       if {($get_user_flags ne "0")} {
  549.         if {($hand eq "0")} {
  550.           return 0
  551.         } elseif {($hand eq "\*")} {
  552.           return 0
  553.         } else {
  554.           set hand $hand
  555.         }
  556.         if {[matchattr $hand $get_user_flags]} {
  557.           return 1
  558.         } else {
  559.           return 0
  560.         }
  561.       } else {
  562.         return 0
  563.       }
  564.     } elseif {($type eq "channel_access")} {
  565.       if {($get_channel_access ne "0")} {
  566.         if {($nick ne "0")} {
  567.           set user $nick
  568.         }
  569.         if {($arg ne "0")} {
  570.           set user $arg
  571.         }
  572.         if {($chan ne "0")} {
  573.           set chan $chan
  574.         }
  575.         if {($get_channel_access eq "op") || ($get_channel_access eq "halfop") || ($get_channel_access eq "voice")} {
  576.           if {[is$get_channel_access $user $chan]} {
  577.             return 1
  578.           } else {
  579.             return 0
  580.           }
  581.         }
  582.       } else {
  583.         return 0
  584.       }
  585.     }
  586.   }
  587.  
  588.  
  589.   ##
  590.   # Output
  591.   ##
  592.   # [send:output] : notice nick | message chan
  593.   proc send:output {nick chan type speed line color length args} {
  594.     variable nsc;
  595.     variable oj;
  596.     set inc 0
  597.     foreach s [join $args] {
  598.       set inc [expr $inc + 1]
  599.       set replace(%msg.$inc%) $s
  600.     }
  601.     set get_language [${nsc}::get:language $chan $line]
  602.     if {($type eq "notice")} {
  603.       if {($color eq "on")} {
  604.         if {$length eq "long"} {
  605.           set extended_line "$line:color:long"
  606.         } elseif {($length eq "short")} {
  607.           set extended_line "$line:color:short"
  608.         } else {
  609.           set extended_line "$line:color"
  610.         }
  611.       } elseif {($color eq "off")} {
  612.         if {$length eq "long"} {
  613.           set extended_line "$line:long"
  614.         } elseif {($length eq "short")} {
  615.           set extended_line "$line:short"
  616.         } else {
  617.           set extended_line "$line"
  618.         }
  619.       }
  620.       if {[info exists ${nsc}::oj($get_language:${extended_line})]} {
  621.         set reply [string map [array get replace] $oj($get_language:${extended_line})]
  622.       } else {
  623.         #putlog "$oj(title:putlog) \[Error\] oj($get_language:${extended_line}) does not exist! using oj($get_language:$line) insted"
  624.         set reply [string map [array get replace] $oj($get_language:$line)]
  625.       }
  626.       if {($speed eq "fast")} {
  627.         putquick "NOTICE $nick :$reply"
  628.       } elseif {($speed eq "normal")} {
  629.         putserv "NOTICE $nick :$reply"
  630.       } else {
  631.         puthelp "NOTICE $nick :$reply"
  632.       }
  633.     } elseif {($type eq "message")} {
  634.       if {($color eq "on")} {
  635.         if {$length eq "long"} {
  636.           set extended_line "$line:color:long"
  637.         } elseif {($length eq "short")} {
  638.           set extended_line "$line:color:short"
  639.         } else {
  640.           set extended_line "$line:color"
  641.         }
  642.       } elseif {($color eq "off")} {
  643.         if {$length eq "long"} {
  644.           set extended_line "$line:long"
  645.         } elseif {($length eq "short")} {
  646.           set extended_line "$line:short"
  647.         } else {
  648.           set extended_line "$line"
  649.         }
  650.       }
  651.       if {[info exists ${nsc}::oj($get_language:${extended_line})]} {
  652.         set reply [string map [array get replace] $oj($get_language:${extended_line})]
  653.       } else {
  654.         #putlog "$oj(title:putlog) \[Error\] $oj($get_language:${extended_line}) does not exist! using $oj($get_language:$line) insted"
  655.         set reply [string map [array get replace] $oj($get_language:$line)]
  656.       }
  657.       if {($speed eq "fast")} {
  658.         if {($nick == 0)} {
  659.           putquick "PRIVMSG $chan :$reply"
  660.         } else {
  661.           putquick "PRIVMSG $nick :$reply"
  662.         }
  663.       } elseif {($speed eq "normal")} {
  664.         if {($nick == 0)} {
  665.           putserv "PRIVMSG $chan :$reply"
  666.         } else {
  667.           putserv "PRIVMSG $nick :$reply"
  668.         }
  669.       } else {
  670.         if {($nick == 0)} {
  671.           puthelp "PRIVMSG $chan :$reply"
  672.         } else {
  673.           puthelp "PRIVMSG $nick :$reply"
  674.         }
  675.       }
  676.     }
  677.   }
  678.  
  679.  
  680.   ##
  681.   # Languages
  682.   ##
  683.   # [get:language] :
  684.   proc get:language {chan line} {
  685.     variable nsc;
  686.     set get_language [string tolower [channel get $chan ojoin-language]]
  687.     if {($get_language eq "")} {
  688.       set language en
  689.     } else {
  690.       if {($get_language eq "en") || ($get_language eq "english")} {
  691.         set get_language "en"
  692.       } elseif {($get_language eq"de") || ($get_language eq "german")} {
  693.         set get_language "de"
  694.       } else {
  695.         set get_language "en"
  696.       }
  697.       if {[info exists ${nsc}::oj($get_language:$line)]} {
  698.         set language $get_language
  699.       } else {
  700.         set language en
  701.       }
  702.     }
  703.     return [string tolower $language]
  704.   }
  705.  
  706.   ##
  707.   # English
  708.   ##
  709.   # [error:lines] :
  710.   set oj(en:error:is:off) "$oj(title:default) is \002Off\002! Please use \002%msg.1% set on\002"
  711.   set oj(en:error:no:nick) "$oj(title:default) \[Error\] \002%msg.1%\002 is not on \002%msg.2%\002"
  712.   set oj(en:error:chan:not:valid) "$oj(title:default) \[Error\] \002%msg.1%\002 is not a valid channel"
  713.   set oj(en:error:not:on:chan) "$oj(title:default) \[Error\] Im not on \002%msg.1%\002"
  714.   set oj(en:error:help) "$oj(title:default) \[Error\] Please use %msg.1% \002help\002"
  715.   set oj(en:error:set:access) "$oj(title:default) \[Error\] Please use %msg.1% set access <\002channel_access\002> <\002flags\002>"
  716.   set oj(en:error:set:language) "$oj(title:default) \[Error\] Please use %msg.1% set language <\002language\002>"
  717.   set oj(en:error:set:output:color) "$oj(title:default) \[Error\] Please use %msg.1% set output color <\002on/off\002>"
  718.   set oj(en:error:set:output:length) "$oj(title:default) \[Error\] Please use %msg.1% set output length <\002default/long/short\002>"
  719.   # [info:lines] :
  720.   set oj(en:info:coming:soon) "$oj(title:default) \[Info\] \002Coming soon.\002"
  721.   set oj(en:info:already:off) "$oj(title:default) Is already \002off\002."
  722.   set oj(en:info:already:on) "$oj(title:default) Is already \002on\002."
  723.   set oj(en:info:no:permission:command) "$oj(title:default) \[No Permission\] \002%msg.1%\002: you can not use this command!"
  724.   set oj(en:info:is:now:arg) "$oj(title:default) Is now \002%msg.1%\002."
  725.   set oj(en:info:set:access) "$oj(title:default) Access has been changed to \002%msg.1%\002 \002%msg.2%\002."
  726.   set oj(en:info:set:language) "$oj(title:default) Language has been changed to \002%msg.1%\002."
  727.   set oj(en:info:set:output:color) "$oj(title:default) Output color has been changed to \002%msg.1%\002."
  728.   set oj(en:info:set:output:length) "$oj(title:default) Output length has been changed to \002%msg.1%\002."
  729.   set oj(en:info:version:arg) "$oj(title:default) Name: \002%msg.1%\002 \| Projectname: \002%msg.2%\002 \| Version: \002%msg.3%\002 \| Copyright: \002%msg.4%\002 - \002%msg.5%\002 by \002%msg.6%\002 \| Contact: \002%msg.7%\002 \| Homepage: \037\002%msg.8%\002\037 (Status: \002%msg.9%\002)"
  730.   # [help:lines] :
  731.   set oj(en:help) "$oj(title:default) Help:"
  732.   set oj(en:help:optional) "$oj(title:default) Help: The entrie in the (\002placeholder\002) brackets is optional"
  733.   set oj(en:help:required) "$oj(title:default) Help: The entrie in the <\002placeholder\002> brackets is required."
  734.   set oj(en:help:full) "$oj(title:default) Help: The entrie in the (\002placeholder\002) brackets is optional, and the entrie in the <\002placeholder\002> brackets is required."
  735.   set oj(en:help:help:nickname) "%msg.1% help (nickname)"
  736.   set oj(en:help:help:set) "%msg.1% help set"
  737.   set oj(en:help:help:set:examples) "%msg.1% help set examples"
  738.   set oj(en:help:help:oper:join) "%msg.1% (#channel)"
  739.   set oj(en:help:version) "%msg.1% version"
  740.   set oj(en:help:version:nickname) "%msg.1% version (nickname)"
  741.   # [help:set:lines] :
  742.   set oj(en:help:set) "$oj(title:default) Help set:"
  743.   set oj(en:help:set:optional) "$oj(title:default) Help set: The entrie in the (\002placeholder\002) brackets is optional"
  744.   set oj(en:help:set:required) "$oj(title:default) Help set: The entrie in the <\002placeholder\002> brackets is required."
  745.   set oj(en:help:set:full) "$oj(title:default) Help set: The entrie in the (\002placeholder\002) brackets is optional, and the entrie in the <\002placeholder\002> brackets is required."
  746.   set oj(en:help:set:available:languages) "$oj(title:default) Available languages:"
  747.   set oj(en:help:set:language:en:de) "\002en\002, \002de\002"
  748.   set oj(en:help:set:on) "%msg.1% set <on>"
  749.   set oj(en:help:set:off) "%msg.1% set <off>"
  750.   set oj(en:help:set:on:off) "%msg.1% set <on/off>"
  751.   set oj(en:help:set:access) "%msg.1% set access <access_name> <flags>"
  752.   set oj(en:help:set:language) "%msg.1% set language <language>"
  753.   set oj(en:help:set:output:color) "%msg.1% set output color <on/off>"
  754.   set oj(en:help:set:output:length) "%msg.1% set output length <default/long/short>"
  755.   # [various:lines] :
  756.  
  757.   ##
  758.   # Deutsch
  759.   ##
  760.   # [error:lines] :
  761.   # [info:lines] :
  762.   # [help:lines] :
  763.   # [help:set:lines] :
  764.   # [various:lines] :
  765.  
  766.  
  767.   ##
  768.   # CTCP
  769.   ##
  770.   # [version:reply] :
  771.   proc version:reply {nick uhost hand dest key arg} {
  772.     variable oj;
  773.     puthelp "NOTICE $nick :VERSION $oj(logo:default) Name: \002$oj(tcl:name)\002 \| Projectname: \002$oj(tcl:project:name)\002 \| Version: \002$oj(tcl:version)\002 \| \002$oj(tcl:copyright)\002 \002$oj(tcl:year)\002 by \002$oj(tcl:author)\002 \| Contact: \002$oj(tcl:contact)\002 \| Website: \037\002$oj(tcl:website)\002\037"
  774.     #putlog "$oj(title:putlog) \[Info\] CTCP version from $nick ($uhost)"
  775.     return
  776.   }
  777. }
  778.  
  779. putlog "$oper::join::oj(title:putlog) Name: \002$oper::join::oj(tcl:name)\002 \| Projectname: \002$oper::join::oj(tcl:project:name)\002 \| Version: \002$oper::join::oj(tcl:version)\002 \| \002Loaded\002."
Tags: TCL eggdrop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement