Code: Select all
# __ __ __
# /\ \ /\ \ __/\ \
# \ \ \ __ \ \ \/\ \ \ \
# \ \ \ __ /'__`\ \ \ \ \ \ \ \
# \ \ \_\ \/\ \_\ \_\ \ \_/ \_\ \
# \ \____/\ \__/ \_\\ `\___ ___/
# \/___/ \/__/\/_/ '\/__//__/
#
# sBNC Script by LaW.
#
# | author: LaW
# | version: 1.6
# | web: www.myGeeX.de
# | irc: #GeeX at Quakenet
# | contact: www.myGeeX.de/?page_id=17
#
# +-------------+
# | r e a d m e |
# +-------------+
#
# | upload this script via ftp and write:
# | - 'source url/to/script/sbnc.tcl'
# | into your eggdrop configuration.
# | After you have done this rehash or restart your eggdrop.
# | Type !sbnc help to see the help.
#
# +-------------------+
# | c h a n g e l o g |
# +-------------------+
#
# | - (03.05.06) v1.0: release
# | - (14.05.06) v1.1: added list command
# | - (26.05.06) v1.2: added modex command
# | - (05.06.06) v1.3: code review
# | - (12.06.06) v1.4: added add command
# | - (21.06.06) v1.5: more advanced code
# | - (18.07.06) v1.6: full sbnc management added
#
# +-------------------+
# | c o p y r i g h t |
# +-------------------+
#
# Copyright (C) 2006 Laurids 'GeeX' W.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Don't change anything.
# Report bugs to #GeeX at Quakenet.
# Manages your sbnc over irc
# configuration
# variables
set sbnc(trigger) "\!"
set sbnc(version) "1.6"
set sbnc(author) "Laurids 'GeeX' W. (#GeeX at Quakenet)"
set sbnc(chan) "#GeeX"
set sbnc(ident) "Ch"
set sbnc(ircserver) "irc.quakenet.org 6667"
set sbnc(server) "myGeeX.de"
set sbnc(port) "1337"
set sbnc(realname) "powered by #GeeX"
set sbnc(iface) "http://sbnc.myGeeX.de"
# bindings
bind PUB n|- $sbnc(trigger)sbnc sbnc:iface
bind NOTC | * sbnc:notice
# copyright
putlog "sBNC Script version $sbnc(version) scripted by $sbnc(author)"
# source (again DO NOT change anything if you are not 100% sure)
proc sbnc:iface { nick host hand chan arg } {
global sbnc
switch -exact -- [string tolower [lindex [split $arg] 0]] {
"add" {
set ident [lindex [split $arg] 1]
set password [expr {int(rand()*1000000) + 1}]
set realname [lindex [split $arg] 2]
if {$realname == ""} {
set realname $sbnc(realname)
}
putquick "SBNC ADDUSER $ident $password"
putquick "SBNC SIMUL $ident SBNC SET REALNAME $realname"
putquick "SBNC SIMUL $ident SBNC SET SERVER $sbnc(ircserver)"
utimer 60 [list putquick "SBNC SIMUL $ident JOIN $sbnc(chan)"]
putquick "NOTICE $nick :Done. New bnc added."
putquick "NOTICE $nick :Server: $sbnc(server), Port: $sbnc(port), Ident: $ident, Password: $password, Iface: $sbnc(iface)"
}
"del" {
set ident [lindex [split $arg] 1]
putquick "SBNC DELUSER $ident"
putquick "NOTICE $nick :Done. User ($ident) deleted."
}
"password" {
set ident [lindex [split $arg] 1]
set password [expr {int(rand()*1000000) + 1}]
putquick "SBNC RESETPASS $ident $password"
putquick "NOTICE $nick :Done. New password for user ($ident) created."
putquick "NOTICE $nick :Password: $password"
}
"admin" {
set ident [lindex [split $arg] 1]
if {$ident == "$sbnc(ident)"} {
putquick "NOTICE $nick :Error. This ident is already an admin."
return
} else {
putquick "SBNC ADMIN $ident"
putquick "NOTICE $nick :Done. User ($ident) has now admin rights."
}
}
"unadmin" {
set ident [lindex [split $arg] 1]
if {$ident == "$sbnc(ident)"} {
putquick "NOTICE $nick :Error. This ident needs admin rights."
return
} else {
putquick "SBNC UNADMIN $ident"
putquick "NOTICE $nick :Done. Admin rights for user ($ident) deleted."
}
}
"global" {
set arg [lindex [split $arg] 1]
putquick "SBNC GLOBAL $arg"
putquick "NOTICE $nick :Done. Global notice to all bouncer users transmitted."
}
"check" {
set sbnc(nick) $nick
putquick "SBNC WHO"
}
"help" {
putserv "NOTICE $nick :\037sBNC help\037:"
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc add 'ident' 'realname' to add a bouncer."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc del 'ident' to delete a bouncer."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc password 'ident' to generate a new password."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc admin 'ident' to give admin rights."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc unadmin 'ident' to remove admin rights."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc global 'message' to send a global notice to all bouncer users."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc check to check if all bouncer users are available at your channel."
putserv "NOTICE $nick :End of list."
}
"default" {
putserv "NOTICE $nick :Error. Use $sbnc(trigger)sbnc help to see a command overview."
}
}
}
proc sbnc:notice { nick host hand arg dest } {
global sbnc
if {$nick != "-sBNC"} {
return
} elseif {$arg == "No such user: *" || $arg == "Done."} {
return
} elseif {$arg == "End of USERS."} {
sbnc:notice:end $sbnc(nick)
} else {
set ident [lindex [split $arg ()] 0]
regsub -all {@} $ident { } ident
regsub -all {\*} $ident { } ident
append sbnc(db) " $ident"
}
}
proc sbnc:notice:end { nick } {
global sbnc
set sbnc(missing) ""
foreach user [chanlist $sbnc(chan)] {
set idents [lindex [split [getchanhost $user $sbnc(chan)] @] 0]
foreach ident [split $sbnc(db)] {
if {[string match "*$ident*" "$idents"]} {
lappend sbnc(missing) $idents
}
}
}
set sbnc(mlist) ""
foreach idents [split $sbnc(db)] {
if {![string match "*$idents*" "$sbnc(missing)"]} {
putserv "SBNC SIMUL $idents JOIN $sbnc(chan)"
}
}
unset sbnc(db)
putquick "NOTICE $sbnc(nick) :Done. All bouncer users should now be available at your channel."
}