Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace eval nickserv::identify {
- variable ni;
- # nickserv_identify.tcl --
- #
- ### Version:
- # 29.01.2024
- #
- ### Copyright:
- # CIRCLED C WITH OVERLAID BACKSLASH (c) 2023-2024 X-Anonymous-Y
- #
- ### License:
- # public domain (PD)
- #
- ### Contact:
- # irc.kn-v2.com #Eggdrop
- #
- ### Help:
- #
- ### Usage:
- #
- ### ToDo:
- #
- ### Changes:
- # 29.01.2024 (Bug fix) Fixed some small bugs (X-Anonymous-Y)
- # 28.01.2024 (Code cleaned) If clauses that are no longer needed have been deleted (X-Anonymous-Y)
- # 27.01.2024 (New feature) Added regex to check set variables (X-Anonymous-Y)
- # 25.01.2024 (Code changed) Added variable nsc [namespace current] and variable ni; for global usage. This makes the code a lot smaller and clearer (X-Anonymous-Y)
- # 22.01.2024 (Code changed) Changed comments and variables (X-Anonymous-Y)
- # 21.01.2024 (Code cleaned) Cleaned up comments and some code (X-Anonymous-Y)
- # 20.01.2024 (New feature) User modes change to ni(user:mode) after identifying with NickServ (X-Anonymous-Y)
- # 20.01.2024 (New feature) Added multiple send types /ID, /IDENTIFY, /NS, /NICKSERV (X-Anonymous-Y)
- # 01.01.2024 (Code cleaned) The code has been cleaned according to all possible best practices (X-Anonymous-Y)
- # ??.??.???? (Script created) Script functions considered and script created (Diamond85 - my old nick)
- #
- #
- #
- ### The configuration begins
- #
- #
- ##
- # Variable settings
- ##
- # Here you can specify the account that will be used for identification at NickServ.
- # Format: "account"
- # Examples: "The-Bot"
- set ni(account) "The-Bot"
- # Here you can specify the account password that will be used for identification at NickServ.
- # Format: "password"
- # Examples: "TopSecretNickPassword!"
- set ni(password) "TopSecretNickPassword!"
- # Set the nickname of NickServ here (correct capitalization). Incoming notices are checked for this.
- # Format: "nickname"
- # Examples: "NickServ" ...
- set ni(nickname) "NickServ"
- # Set the user@host of NickServ (/whois NickServ) here, as above with correct capitalization. Also used for checking.
- # Format: "ident@host"
- # Examples: "NickServ@kn-v2/services/nickserv" ...
- set ni(uhost) "NickServ@kn-v2/services/nickserv"
- # # These strings are set for the KN-V2-Network by default. Customize the notifications to which Nickserv sends! You will see it when you connect to the server.
- # Separate strings with | eg. {This nickname is registered*|...}, * replaces everything.
- # Format: "registered_string"
- # Examples:
- # Atheme-Services: This nickname is registered. Please choose a different nickname, or identify via /msg NickServ IDENTIFY Guest <password>
- # Anope: This nickname is registered and protected. If it is your nick, type /msg NickServ IDENTIFY password. Otherwise, please choose a different nick.
- # Anope2: This nickname is registered and protected. If it is your
- # nick, type /msg NickServ IDENTIFY password. Otherwise,
- # please choose a different nick.
- set ni(registered:string) "This nickname is registered.*|This nickname is registered and protected.*"
- # Format: "identified_strings"
- # Examples:
- # Atheme-Services: You are now identified for account_name.
- # Anope: Password accepted - you are now recognized.
- set ni(identified:string) "You are now identified for *.|Password accepted - you are now recognized."
- # Set here the user mods that should be set on the bot after identification.
- # Format: "+/-user_mode"
- # Examples: "+B", "+iB-w", "+i-B" ...
- # Set it to "0" so that no user modes are changed.
- #
- # All possible user modes for InspIRCd can be found here: (https://docs.inspircd.org/3/user-modes/)
- #
- # If your bot is used on a different server, first check which user modes the server supports!
- set ni(user:mode) "+iB-w"
- # Set the send type you want to use for identification here.
- # Format: number
- # Examples:
- # 0 /MSG NickServ IDENTIFY <Account> <Password>
- # 1 /NS IDENTIFY <Account> <Password>
- # 2 /NICKSERV IDENTIFY <Account> <Password>
- # 3 /ID <Account> <Password>
- # 4 /IDENTIFY <Account> <Password>
- set ni(send:type) 0
- #
- #
- ### End of configuration
- #
- #
- ###
- ### DO NOT EDIT ANYTHING BELOW HERE! UNLESS YOU KNOW WHAT YOU'RE DOING!
- ###
- ##
- # Various variables
- ##
- # [various:variables] :
- variable nsc [namespace current]
- set ni(logo:default) "\002\[Nickserv Identify\]\002"
- set ni(logo:color) "\002\[Nickserv Identify\]\002"
- set ni(logo:putlog) "\002*** \[Nickserv Identify\] ***\002"
- set ni(title:default) "\002\[Nickserv Identify\]\002"
- set ni(title:color) "\002\[Nickserv Identify\]\002"
- set ni(title:putlog) "\002*** \[Nickserv Identify\] ***\002"
- ##
- # Un/Binds | Init
- ##
- # [bind:evnt] :
- bind evnt - loaded ${nsc}::init
- bind evnt - prerehash ${nsc}::unbind:bindings
- bind evnt - prerestart ${nsc}::unbind:bindings
- bind evnt - rehash ${nsc}::init
- # [init] :
- proc init {args} {
- variable nsc;
- variable ni;
- if {[info exists ${nsc}::ni(account)] && ([string trim $ni(account)] eq "")} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(account) \"$ni(account)\"\002"
- return
- }
- if {[info exists ${nsc}::ni(password)] && ([string trim $ni(password)] eq "")} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(password) \"$ni(password)\"\002"
- return
- }
- if {[info exists ${nsc}::ni(nickname)] && ([string trim $ni(nickname)] eq "")} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(nickname) \"$ni(nickname)\"\002"
- return
- }
- if {[info exists ${nsc}::ni(uhost)] && ([string trim $ni(uhost)] eq "") || ([${nsc}::check:regex uhost $ni(uhost)])} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(uhost) \"$ni(uhost)\"\002"
- return
- }
- if {[info exists ${nsc}::ni(registered:string)] && ([string trim $ni(registered:string)] eq "") || ([${nsc}::check:regex registered:string $ni(registered:string)])} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(registered:string) \"$ni(registered:string)\"\002"
- return
- } else {
- foreach auth_strings [split $ni(registered:string) |] {
- bind notc -|- [string trim $auth_strings] ${nsc}::start:idenitfy
- }
- }
- if {[info exists ${nsc}::ni(identified:string)] && ([string trim $ni(identified:string)] eq "") || ([${nsc}::check:regex identified:string $ni(identified:string)])} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(identified:string) \"$ni(identified:string)\"\002"
- return
- } else {
- foreach identified_strings [split $ni(identified:string) |] {
- bind notc -|- [string trim $identified_strings] ${nsc}::user:mode
- }
- }
- if {[info exists ${nsc}::ni(user:mode)] && ([string trim $ni(user:mode)] eq "") || ([${nsc}::check:regex user:mode $ni(user:mode)])} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(user:mode) \"$ni(user:mode)\"\002"
- return
- }
- if {[info exists ${nsc}::ni(send:type)] && ([string trim $ni(send:type)] eq "") || ([${nsc}::check:regex send:type ${ni(send:type)}])} {
- putlog "$ni(title:putlog) \[Error\] Please check \002nickserv_identify.tcl\002 --> \002set ni(send:type) $ni(send:type)\002"
- return
- }
- bind ctcp -|- VERSION ${nsc}::version:reply
- }
- # [unbind:bindings] :
- proc unbind:bindings {args} {
- variable nsc;
- variable ni;
- foreach auth_strings [split $ni(registered:string) |] {
- unbind notc -|- [string trim $auth_strings] ${nsc}::start:idenitfy
- }
- foreach identified_strings [split $ni(identified:string) |] {
- unbind notc -|- [string trim $identified_strings] ${nsc}::user:mode
- }
- unbind ctcp -|- VERSION ${nsc}::version:reply
- }
- ##
- # Script information
- ##
- # [script:variables] :
- set ni(tcl:name) "nickserv_identify"
- set ni(tcl:project:name) "nidentify"
- set ni(tcl:author) "X-Anonymous-Y"
- set ni(tcl:contact) "irc.kn-v2.com #Eggdrop"
- set ni(tcl:copyright) "©"
- set ni(tcl:year) "2023-2024"
- set ni(tcl:version) "29.01.2024"
- set ni(tcl:website) "https://pastebin.com/VSXhUBbJ"
- ##
- # Actions
- ##
- # [start:idenitfy] :
- proc start:idenitfy {nick uhost hand text {dest ""}} {
- variable nsc;
- variable ni;
- if {[string match "$ni(nickname)" $nick] && [string match "$ni(uhost)" $uhost]} {
- ${nsc}::idenitfy $nick $uhost
- } else {
- putlog "$ni(title:putlog) \[Warning\] $nick ($uhost) tried to get account identify data. (With notice: \002$text\002)"
- return
- }
- }
- # [idenitfy] :
- proc idenitfy {nick uhost} {
- variable nsc;
- variable ni;
- if {$ni(send:type) == 0} {
- putquick "PRIVMSG $nick :IDENTIFY $ni(account) $ni(password)"
- putlog "$ni(title:putlog) \[Info\] Identify on $nick ($uhost) via /MSG NickServ IDENTIFY \002$ni(account)\002 <Password>"
- return
- } elseif {$ni(send:type) == 1} {
- putquick "NS :IDENTIFY $ni(account) $ni(password)"
- putlog "$ni(title:putlog) \[Info\] Identify on $nick ($uhost) via /NS IDENTIFY \002$ni(account)\002 <Password>"
- return
- } elseif {$ni(send:type) == 2} {
- putquick "NICKSERV :IDENTIFY $ni(account) $ni(password)"
- putlog "$ni(title:putlog) \[Info\] Identify on $nick ($uhost) via /NICKSERV IDENTIFY \002$ni(account)\002 <Password>"
- return
- } elseif {$ni(send:type) == 3} {
- putquick "ID $ni(account) $ni(password)"
- putlog "$ni(title:putlog) \[Info\] Identify on $nick ($uhost) via /ID \002$ni(account)\002 <Password>"
- return
- } elseif {$ni(send:type) == 4} {
- putquick "IDENTIFY $ni(account) $ni(password)"
- putlog "$ni(title:putlog) \[Info\] Identify on $nick ($uhost) via /IDENTIFY \002$ni(account)\002 <Password>"
- return
- }
- }
- # [user:mode] :
- proc user:mode {nick uhost hand text {dest ""}} {
- variable nsc;
- variable ni;
- if {[string match "$ni(nickname)" $nick] && [string match "$ni(uhost)" $uhost]} {
- putlog "$ni(title:putlog) \[Info\] Password accepted."
- if {([string trim $ni(user:mode)] == 0)} {
- return
- } else {
- global botnick
- putquick "MODE $botnick $ni(user:mode)"
- putlog "$ni(title:putlog) \[Info\] User modes changed to \002$ni(user:mode)\002"
- return
- }
- } else {
- putlog "$ni(title:putlog) \[Warning\] $nick ($uhost) tried to get account identify data. (With notice: \002$text\002)"
- return
- }
- }
- # [check:regex] : type arg
- proc check:regex {type arg} {
- if {($type eq "uhost")} {
- if {[regexp -- {^.*[@].*$} ${arg}]} {
- return 0
- } else {
- return 1
- }
- } elseif {($type eq "registered:string")} {
- if {[regexp -- {^(This.*nickname.*is.*registered.*)$} ${arg}]} {
- return 0
- } else {
- return 1
- }
- } elseif {($type eq "identified:string")} {
- if {[regexp -- {^(You.are.now.identified.*|Password.accepted.*)$} ${arg}]} {
- return 0
- } else {
- return 1
- }
- } elseif {($type eq "user:mode")} {
- if {[regexp -- {^[+-][ioswBcdDgGHhIkLNORrSTWxz]*(?:([+-][ioswBcdDgGHhIkLNORrSTWxz]*))*$} ${arg}]} {
- return 0
- } else {
- return 1
- }
- } elseif {($type eq "send:type")} {
- if {[regexp -- {^[0-4]$} $arg]} {
- return 0
- } else {
- return 1
- }
- }
- }
- ##
- # CTCP
- ##
- # [version:reply] :
- proc version:reply {nick uhost hand dest key arg} {
- variable ni;
- puthelp "NOTICE $nick :VERSION $ni(title:default) Name: \002$ni(tcl:name)\002 \| Projectname: \002$ni(tcl:project:name)\002 \| Version: \002$ni(tcl:version)\002 \| \002$ni(tcl:copyright)\002 \002$ni(tcl:year)\002 by \002$ni(tcl:author)\002 \| Contact: \002$ni(tcl:contact)\002 \| Website: \037\002$ni(tcl:website)\002\037"
- #putlog "$ni(title:putlog) \[Info\] CTCP version from $nick ($uhost)"
- return
- }
- }
- putlog "$nickserv::identify::ni(title:putlog) Name: \002$nickserv::identify::ni(tcl:name)\002 \| Projectname: \002$nickserv::identify::ni(tcl:project:name)\002 \| Version: \002$nickserv::identify::ni(tcl:version)\002 \| \002Loaded\002."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement