Advertisement
X-Anonymous-Y

oper_identify.tcl

Jan 21st, 2024 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 6.65 KB | Source Code | 0 0
  1. namespace eval oper::identify {
  2.   variable oi;
  3.   # oper_identify.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.  
  14.   ### License:
  15.   # public domain (PD)
  16.   #
  17.  
  18.   ### Contact:
  19.   # irc.kn-v2.com #Eggdrop
  20.   #
  21.  
  22.   ### Help:
  23.   #
  24.  
  25.   ### Usage:
  26.   #
  27.  
  28.   ### ToDo:
  29.   #
  30.  
  31.   ### Changes:
  32.   # 29.01.2024 (Bug fix) Fixed some small bugs (X-Anonymous-Y)
  33.   # 28.01.2024 (Code cleaned) If clauses that are no longer needed have been deleted (X-Anonymous-Y)
  34.   # 28.01.2024 (New feature) Added regex to check set variables (X-Anonymous-Y)
  35.   # 25.01.2024 (Code changed) Added variable nsc [namespace current] and variable oi; for global usage. This makes the code a lot smaller and clearer (X-Anonymous-Y)
  36.   # 22.01.2024 (Code changed) Changed comments and variables (X-Anonymous-Y)
  37.   # 21.01.2024 (Code cleaned) Cleaned up comments and some code (X-Anonymous-Y)
  38.   # 20.01.2024 (New feature) User modes change to oi(user:mode) after RAW 381 server notification (X-Anonymous-Y)
  39.   # 01.01.2024 (Code cleaned) The code has been cleaned according to all possible best practices (X-Anonymous-Y)
  40.   # 25.11.2016 (Script created) Script functions considered and script created (Diamond85 - my old nick)
  41.   #
  42.  
  43.  
  44.   #
  45.   #
  46.   ### The configuration begins
  47.   #
  48.   #
  49.  
  50.  
  51.   ##
  52.   # Variable settings
  53.   ##
  54.   # Set the name you want to use for the operator here.
  55.   # Format: "name"
  56.   # Examples: "The-Oper"
  57.   set oi(name) "The-Oper"
  58.  
  59.   # Set the password you want to use for the operator here.
  60.   # Format: "password"
  61.   # Examples: "TopSecretOperPassword!"
  62.   set oi(password) "TopSecretOperPassword!"
  63.  
  64.   # Set the network you want to connect to here.
  65.   # Format: "network"
  66.   # Examples: "KN-V2-Network"
  67.   set oi(network) "KN-V2-Network"
  68.  
  69.   # Set here the user mods that should be set on the bot after the operator identification.
  70.   # Format: "+/-user_mode"
  71.   # Examples: "+B", "+iB-w", "+IBs +cCqQ" ...
  72.   # Set it to "0" so that no user modes are changed.
  73.   #
  74.   # All possible user modes for InspIRCd can be found here: (https://docs.inspircd.org/3/user-modes/)
  75.   # and server snomasks for InspIRCd user mode (+/-s) here: (https://docs.inspircd.org/3/snomasks/)
  76.   #
  77.   # If your bot is used on a different server, first check which user modes the server supports!
  78.   set oi(user:mode) "+ITW-s"
  79.  
  80.  
  81.   #
  82.   #
  83.   ### End of configuration
  84.   #
  85.   #
  86.  
  87.  
  88.   ###
  89.   ### DO NOT EDIT ANYTHING BELOW HERE! UNLESS YOU KNOW WHAT YOU'RE DOING!
  90.   ###
  91.  
  92.  
  93.   ##
  94.   # Various variables
  95.   ##
  96.   # [various:variables] :
  97.   variable nsc [namespace current]
  98.   set oi(logo:default) "\002\[Oper Identify\]\002"
  99.   set oi(logo:color) "\002\[Oper Identify\]\002"
  100.   set oi(logo:putlog) "\002*** \[Oper Identify\] ***\002"
  101.   set oi(title:default) "\002\[Oper Identify\]\002"
  102.   set oi(title:color) "\002\[Oper Identify\]\002"
  103.   set oi(title:putlog) "\002*** \[Oper Identify\] ***\002"
  104.  
  105.  
  106.   ##
  107.   # Un/Binds | Init
  108.   ##
  109.   # [bind:evnt] :
  110.   bind evnt - loaded ${nsc}::init
  111.   bind evnt - prerehash ${nsc}::unbind:bindings
  112.   bind evnt - prerestart ${nsc}::unbind:bindings
  113.   bind evnt - rehash ${nsc}::init
  114.   bind evnt - init-server ${nsc}::start:oper
  115.  
  116.   # [init] :
  117.   proc init {args} {
  118.     variable nsc;
  119.     variable oi;
  120.     if {[info exists ${nsc}::oi(name)] && ([string trim $oi(name)] eq "")} {
  121.       putlog "$oi(title:putlog) \[Error\] Please check \002oper_identify.tcl\002 --> \002set oi(name) \"$oi(name)\"\002"
  122.       return
  123.     }
  124.     if {[info exists ${nsc}::oi(password)] && ([string trim $oi(password)] eq "")} {
  125.       putlog "$oi(title:putlog) \[Error\] Please check \002oper_identify.tcl\002 --> \002set oi(password) \"$oi(password)\"\002"
  126.       return
  127.     }
  128.     if {[info exists ${nsc}::oi(network)] && ([string trim $oi(network)] eq "")} {
  129.       putlog "$oi(title:putlog) \[Error\] Please check \002oper_identify.tcl\002 --> \002set oi(network) \"$oi(network)\"\002"
  130.       return
  131.     }
  132.     if {[info exists ${nsc}::oi(user:mode)] && ([string trim $oi(user:mode)] eq "") || ([${nsc}::check:regex user:mode:oper $oi(user:mode)])} {
  133.       putlog "$oi(title:putlog) \[Error\] Please check \002oper_identify.tcl\002 --> \002set oi(user:mode) \"$oi(user:mode)\"\002"
  134.       return
  135.     }
  136.     bind raw - 381 ${nsc}::user:mode
  137.     bind ctcp -|- VERSION ${nsc}::version:reply
  138.   }
  139.  
  140.   # [unbind:bindings] :
  141.   proc unbind:bindings {args} {
  142.     variable nsc;
  143.     unbind raw - 381 ${nsc}::user:mode
  144.     unbind ctcp -|- VERSION ${nsc}::version:reply
  145.   }
  146.  
  147.  
  148.   ##
  149.   # Script information
  150.   ##
  151.   # [script:variables] :
  152.   set oi(tcl:name) "oper_identify"
  153.   set oi(tcl:project:name) "oidentify"
  154.   set oi(tcl:author) "X-Anonymous-Y"
  155.   set oi(tcl:contact) "irc.kn-v2.com #Eggdrop"
  156.   set oi(tcl:copyright) "©"
  157.   set oi(tcl:year) "2023-2024"
  158.   set oi(tcl:version) "29.01.2024"
  159.   set oi(tcl:website) "https://pastebin.com/UXdBNmfD"
  160.  
  161.  
  162.   ##
  163.   # Actions
  164.   ##
  165.   # [start:oper] :
  166.   proc start:oper {type} {
  167.     variable oi;
  168.     putquick "OPER $oi(name) $oi(password)"
  169.     putlog "$oi(title:putlog) \[Info\] Identify as operator with \002$oi(name)\002 on \002$oi(network)\002"
  170.     return
  171.   }
  172.  
  173.   # [user:modes] :
  174.   proc user:mode {from keyword args} {
  175.     variable nsc;
  176.     variable oi;
  177.     putlog "$oi(title:putlog) \[Info\] Successfully identified as operator."
  178.     if {([string trim $oi(user:mode)] == 0)} {
  179.       return
  180.     } else {
  181.       global botnick
  182.       putquick "MODE $botnick $oi(user:mode)"
  183.       putlog "$oi(title:putlog) \[Info\] User modes changed to \002$oi(user:mode)\002"
  184.       return
  185.     }
  186.   }
  187.  
  188.   # [check:regex] : type arg
  189.   proc check:regex {type arg} {
  190.     if {($type eq "user:mode:oper")} {
  191.       if {[regexp -- {^[+-][ioswBcdDgGHhIkLNORrSTWxz]*(?:([+-][ioswBcdDgGHhIkLNORrSTWxz]*(?:(\s)[+-][aAcCkKoOqQtxXdDfFgGjJlLnNrRvVwW]*(?:([+-][aAcCkKoOqQtxXdDfFgGjJlLnNrRvVwW]*)))*))$} ${arg}]} {
  192.         return 0
  193.       } else {
  194.         return 1
  195.       }
  196.     }
  197.   }
  198.  
  199.  
  200.   ##
  201.   # CTCP
  202.   ##
  203.   # [version:reply] :
  204.   proc version:reply {nick uhost hand dest key arg} {
  205.     variable oi;
  206.     puthelp "NOTICE $nick :VERSION $oi(title:default) Name: \002$oi(tcl:name)\002 \| Projectname: \002$oi(tcl:project:name)\002 \| Version: \002$oi(tcl:version)\002 \| \002$oi(tcl:copyright)\002 \002$oi(tcl:year)\002 by \002$oi(tcl:author)\002 \| Contact: \002$oi(tcl:contact)\002 \| Website: \037\002$oi(tcl:website)\002\037"
  207.     #putlog "$oi(title:putlog) \[Info\] CTCP version from $nick ($uhost)"
  208.     return
  209.   }
  210. }
  211.  
  212. putlog "$oper::identify::oi(title:putlog) Name: \002$oper::identify::oi(tcl:name)\002 \| Projectname: \002$oper::identify::oi(tcl:project:name)\002 \| Version: \002$oper::identify::oi(tcl:version)\002 \| \002Loaded\002."
  213.  
Tags: TCL eggdrop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement