# Title: nickserv.tcl # Author: El_Rico # Version: 2 - Fixed typo # - Added pattern to server bind # 1 - initial release # License: GPL 2 (http://www.gnu.org/licenses/gpl.html) # Contact: El_Rico in #sbnc on irc.quakenet.org # Purpose: Adding NickServ interacting capabilities to sBNC # Getting started: load the script in sBNC and type "/sbnc nickserv" in your IRC client internalbind command nickserv:command internalbind svrlogon nickserv:logon internalbind server nickserv:server PRIVMSG proc nickserv:command { client params } { if { [string equal -nocase [lindex $params 0] "help"] } { bncaddcommand nickserv User "provides access to nickserv.tcl functionality" "Syntax: nickserv \[parameters\]" } elseif { [string equal -nocase [lindex $params 0] "nickserv"] } { if { [llength $params] < 2 } { bncreply "nickserv.tcl enables sBNC to identify you with NickServ." bncreply "It features identify on server logon, on NickServ warning and auto-ghosting." bncreply "To get more detailed help and usage instructions use /sbnc nickserv help" haltoutput } elseif { [string equal -nocase [lindex $params 1] "set"] } { if { [llength $params] < 3 } { bncreply "nickserv.tcl settings:" if { [getbncuser $client tag nickserv.nick] == "" } { bncreply "Nick: not set." haltoutput } else { bncreply "Nick: [getbncuser $client tag nickserv.nick]" haltoutput } if { [getbncuser $client tag nickserv.password] == "" } { bncreply "Password: not set." haltoutput } else { bncreply "Password: set." haltoutput } if { [getbncuser $client delayjoin] == 0 } { bncreply "Delayjoin: off" haltoutput } else { bncreply "Delayjoin: on" haltoutput } if { [getbncuser $client tag nickserv.reply] == "" } { bncreply "NickServ reply: not set." haltoutput } else { bncreply "NickServ reply: [getbncuser $client tag nickserv.reply]" haltoutput } if { [getbncuser $client tag nickserv.warning] == "" } { bncreply "NickServ warning: not set." haltoutput } else { bncreply "NickServ warning: [getbncuser $client tag nickserv.warning]" haltoutput } } elseif { [llength $params] < 4 } { if { [string equal -nocase [lindex $params 2] "nick"] } { bncreply "No value given, to unset a setting use /sbnc nickserv unset nick" haltoutput } elseif { [string equal -nocase [lindex $params 2] "password"] } { bncreply "No value given, to unset a setting use /sbnc nickserv unset password" haltoutput } elseif { [string equal -nocase [lindex $params 2] delayjoin] } { bncreply "No value given, to unset a setting use /sbnc nickserv unset delayjoin" haltoutput } elseif { [string equal -nocase [lindex $params 2] "reply"] } { bncreply "No value given, to unset a setting use /sbnc nickserv unset reply" haltoutput } elseif { [string equal -nocase [lindex $params 2] "warning"] } { bncreply "No value given, to unset a setting use /sbnc nickserv unset warning" haltoutput } else { bncreply "Unkown setting." haltoutput } } elseif { [string equal -nocase [lindex $params 2] "nick"] } { setbncuser $client tag nickserv.nick [lindex $params 3] bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] "password"] } { setbncuser $client tag nickserv.password [lindex $params 3] bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] delayjoin] } { if { [string equal -nocase [lindex $params 3] "on"] } { setbncuser $client delayjoin 1 bncreply "Done." haltoutput } elseif { [lindex $params 3] == 1 } { setbncuser $client delayjoin 1 bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 3] "off"] } { setbncuser $client delayjoin 0 bncreply "Done." haltoutput } elseif { [lindex $params 3] == 0 } { setbncuser $client delayjoin 0 bncreply "Done." haltoutput } else { bncreply "Invalid value. Vaild values are on/off or 1/0." haltoutput } } elseif { [string equal -nocase [lindex $params 2] "reply"] } { set reply [lrange $params 3 end] setbncuser $client tag nickserv.reply $reply bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] "warning"] } { set warning [lrange $params 3 end] setbncuser $client tag nickserv.warning $warning bncreply "Done." haltoutput } else { bncreply "Unkown setting." haltoutput } } elseif { [string equal -nocase [lindex $params 1] "unset"] } { if { [string equal -nocase [lindex $params 2] "nick"] } { setbncuser $client tag nickserv.nick "" bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] "password"] } { setbncuser $client tag nickserv.password "" bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] "delayjoin"] } { setbncuser $client delayjoin 0 bncreply "Delayjoin can not be unset, disabling it instead." haltoutput } elseif { [string equal -nocase [lindex $params 2] "reply"] } { setbncuser $client tag nickserv.reply "" bncreply "Done." haltoutput } elseif { [string equal -nocase [lindex $params 2] "warning"] } { setbncuser $client tag nickserv.warning "" bncreply "Done." haltoutput } else { bncreply "Unkown setting." haltoutput } } elseif { [string equal -nocase [lindex $params 1] "help"] } { if { [string equal -nocase [lindex $params 2] "general"] } { bncreply "To use nickserv.tcl you have to set the \"reply\" and \"password\" settings, then nickserv.tcl will identify you one time when sBNC connects to the server." bncreply "To additionally enable identification when NickServ warns you that the nick you are using is registered, set \"warning\"." bncreply "To enable auto-ghosting set \"nick\"." bncreply "For more details on the settings and on how to set them see /sbnc nickserv help set" haltoutput } elseif { [string equal -nocase [lindex $params 2] "set"] } { bncreply "To set a setting use /sbnc nickserv set " bncreply "The following settings are available: nick, password, delayjoin, reply and warning." bncreply "-" bncreply "The \"nick\" setting defines the nick you want to use for the auto-ghost feature." bncreply "If that nick is already in use when sBNC logs onto the server, nickserv.tcl will attempt to ghostkill that nick and retake it." bncreply "If \"nick\" is not set, the auto-ghost feature is disabled." bncreply "-" bncreply "The \"password\" setting defines your NickServ password. Please note that the password is stored in plain text!" bncreply "The \"password\" settings is required, if not set, all nickserv.tcl functions will be disabled." bncreply "-" bncreply "The \"delayjoin\" setting defines whether delayjoin is enabled or not." bncreply "If enabled sBNC will wait 5 seconds before it joins your channels, to create a wider timeframe for identification and auto-ghosting." bncreply "Vaild values are \"on\", \"off\", \"1\" and \"0\"." bncreply "-" bncreply "The \"reply\" setting defines how nickserv.tcl will interact with NickServ." bncreply "Examples: if you interact with NickServ via \"/msg NickServ\" set \"reply\" to \"PRIVMSG NICKSERV\"," bncreply "if you are using \"/msg NickServ@services.net.tld\" set \"reply\" to \"PRIVMSG NickServ@services.net.tld\"," bncreply "if you are using \"/NickServ\" or \"/NS\" set \"reply\" to \"NickServ\" or \"NS\" respectively." bncreply "The \"reply\" settings is required, if not set, all nickserv.tcl functions will be disabled." bncreply "-" bncreply "The \"warning\" setting defines how NickServ warns you that the nick you are using is registered." bncreply "Example: usually NickServ will send the following warning to you:" bncreply "\"This nickname is registered and protected. If it is your\"" bncreply "\"nick, type /msg NickServ IDENTIFY password. Otherwise,\"" bncreply "\"please choose a different nick.\"" bncreply "\"If you do not change within one minute, I will change your nick.\"" bncreply "In this example you would set \"warning\" to one of those lines, the first one preferably:" bncreply "\"/sbnc nickserv set warning This nickname is registered and protected. If it is your\"" bncreply "If \"warning\" is not set, the identify on NickServ warning feature is disabled." haltoutput } elseif { [string equal -nocase [lindex $params 2] "unset"] } { bncreply "To unset a setting use /sbnc nickserv unset " bncreply "Vaild settings are: nick, password, reply and warning." bncreply "Due to sBNC restrictions delayjoin can not be unset, it can only be disabled." haltoutput } elseif { [string equal -nocase [lindex $params 2] "disable"] } { bncreply "To disable all nickserv.tcl functionality for this account unset either \"password\", \"reply\" or both." bncreply "To disable the auto-ghost feature unset \"nick\"." bncreply "To disable the identify on NickServ warning feature unset \"warning\"." haltoutput } elseif { [llength $params] < 3 } { bncreply "Help is available on the following topics:" bncreply "general (general usage instructions)" bncreply "set (description of the set command and the nickserv.tcl settings)" bncreply "unset (description of the unset command)" bncreply "disable (how to disable nickserv.tcl functions for this account)" bncreply "To get help on a topic use /sbnc nickserv help " haltoutput } else { bncreply "No help available on that topic." haltoutput } } } } proc nickserv:logon { client } { global botnick if { [getbncuser $client tag nickserv.password] == "" } { return } elseif { [getbncuser $client tag nickserv.reply] == "" } { return } else { if { $botnick != [getbncuser $client tag nickserv.nick] && [getbncuser $client tag nickserv.nick] != "" } { setctx $client putserv "[getbncuser $client tag nickserv.reply] ghost [getbncuser $client tag nickserv.nick] [getbncuser $client tag nickserv.password]" after 2000 putserv "NICK [getbncuser $client tag nickserv.nick]" } setctx $client putserv "[getbncuser $client tag nickserv.reply] identify [getbncuser $client tag nickserv.password]" } } proc nickserv:server { client params } { if { [string match -nocase *[join [getbncuser $client tag nickserv.warning] " "]* [join $params " "]] && [getbncuser $client tag nickserv.warning] != "" && [getbncuser $client tag nickserv.reply] != "" && [getbncuser $client tag nickserv.password] != "" } { setctx $client putserv "[getbncuser $client tag nickserv.reply] identify [getbncuser $client tag nickserv.password]" } else { return } } # addon for webinterface if {[lsearch -exact [info commands] "registerifacehandler"] != -1} { registerifacehandler nickserv nickserv:ifacecmd } proc nickserv:ifacecmd {command params account} { switch -- $command { "nssetuser" { setbncuser $account tag nickserv.nick [lindex $params 0] return 0 } "nssetpass" { setbncuser $account tag nickserv.password [lindex $params 0] return 0 } "nssetwarning" { setbncuser $account tag nickserv.warning [lrange $params 0 end] return 0 } "nsgetuser" { return [getbncuser $account tag nickserv.nick] } "nsgetwarning" { return [getbncuser $account tag nickserv.warning] } "nshaspass" { set pass [getbncuser $account tag nickserv.password] if {$pass == ""} { return 0 } else { return 1 } } "nsdelayjoin" { return [getbncuser $account delayjoin] } "nssetdelayjoin" { setbncuser $account delayjoin [lindex $params 0] return 0 } "nsgetreply" { return [getbncuser $account tag nickserv.reply] } "nssetreply" { set reply [lrange $params 0 end] setbncuser $account tag nickserv.reply $reply return 0 } } }