# __ _ __ ______ _ __ _ __
# / / ____ ___ _______(_)___/ /____ / ____/__ ___ | |/ / | | / /
# / / / __ `/ / / / ___/ / __ / ___/ / / __/ _ \/ _ \| / | | /| / /
# / /___/ /_/ / /_/ / / / / /_/ (__ ) / /_/ / __/ __/ | | |/ |/ /_
# /_____/\__,_/\__,_/_/ /_/\__,_/____/ \____/\___/\___/_/|_| |__/|__/(_)
#
# sBNC Script by GeeX.
#
# | author: GeeX
# | version: 2.0
# | web: www.myGeeX.de
# | irc: #GeeX at Quakenet
# | contact: www.myGeeX.de/?page_id=13
#
# +-------------+
# | 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
# | - (20.08.06) v1.7: code review
# | - (20.09.06) v1.8: little bug fix
# | - (24.09.06) v1.9: bind change (notice -> msgm)
# | - (02.05.07) v2.0: check function deleted
# | added join and part function
# | removed declaration of realname while adding a sbnc
# | added declaration of bncuser to autmatically submit the sbnc data
#
# +-------------------+
# | 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) "2.0"
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
# 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 bncuser [lindex [split $arg] 2]
if {$ident == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc add 'ident' ?nick?."
return
}
putquick "SBNC ADDUSER $ident $password"
putquick "SBNC SIMUL $ident SBNC SET REALNAME $sbnc(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)"
if {$bncuser == ""} {
return
} elseif {[onchan $bncuser $chan]} {
putserv "PRIVMSG $bncuser :Your BNC data, $bncuser:"
putserv "PRIVMSG $bncuser :Server: $sbnc(server), Port: $sbnc(port), Ident: $ident, Password: $password, Iface: $sbnc(iface)"
putserv "PRIVMSG $bncuser :If you need help, just join $sbnc(chan)."
} else {
putserv "NOTICE $nick :Error. $bncuser is not on $chan."
return
}
}
"del" {
set ident [lindex [split $arg] 1]
if {$ident == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc del 'ident'."
return
} else {
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}]
if {$ident == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc password 'ident'."
return
} else {
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
} elseif {$ident == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc admin 'ident'."
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
} elseif {$ident == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc unadmin 'ident'."
return
} else {
putquick "SBNC UNADMIN $ident"
putquick "NOTICE $nick :Done. Admin rights for user ($ident) deleted."
}
}
"global" {
set arg [lrange [split $arg] 1 end]
if {$arg == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc global 'message'."
return
} else {
putquick "SBNC GLOBAL $arg"
putquick "NOTICE $nick :Done. Global notice to all bouncer users transmitted."
}
}
"join" {
set sbnc(joinchan) "[lindex [split $arg] 1]"
if {$sbnc(joinchan) == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc join 'channel'."
return
} elseif {[string first # $sbnc(joinchan)] != 0} {
putserv "NOTICE $nick :Error. The channel has to start with '#'."
return
} else {
putserv "SBNC tcl :foreach sbnc(user) \[bncuserlist\] {setctx \$sbnc(user) ; channel add $sbnc(joinchan)}"
putserv "NOTICE $nick :Done. All sBNC users joined $sbnc(joinchan)."
return
}
}
"part" {
set sbnc(partchan) "[lindex [split $arg] 1]"
if {$sbnc(partchan) == ""} {
putserv "NOTICE $nick :Error. Wrong syntax. Use $sbnc(trigger)sbnc part 'channel'."
return
} elseif {[string first # $sbnc(partchan)] != 0} {
putserv "NOTICE $nick :Error. The channel has to start with a '#'."
return
} else {
putserv "SBNC tcl :foreach sbnc(user) \[bncuserlist\] {setctx \$sbnc(user) ; channel remove $sbnc(partchan)}"
putserv "NOTICE $nick :Done. All sBNC users parted $sbnc(partchan)."
return
}
}
"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 join 'chan' to join all sBNC user a specific channel."
putserv "NOTICE $nick :Use $sbnc(trigger)sbnc part 'chan' to part all sBNC user a specific channel."
putserv "NOTICE $nick :End of list."
}
"default" {
putserv "NOTICE $nick :Error. Use $sbnc(trigger)sbnc help to see a command overview."
}
}
}