/usr/share/sbnc/scripts/defaultsettings.tcl is in sbnc-tcl 1.3.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | # shroudBNC - an object-oriented framework for IRC
# Copyright (C) 2010 Christoph Wiese
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
set ::defaultsettings_settings [list default-server default-ssl default-serverpass default-realname default-awaynick default-away default-awaymessage default-usequitasaway default-automodes default-dropmodes default-autobacklog]
internalbind usrcreate defaultsettings:applydefaultsettings
internalbind command defaultsettings:command
proc defaultsettings:applydefaultsettings {user} {
if {![getbncuser $user admin]} {
foreach defaultsetting $::defaultsettings_settings {
if {[bncgetglobaltag $defaultsetting] != ""} {
regsub "default-" $defaultsetting "" setting
set value [bncgetglobaltag $defaultsetting]
if {$setting == "server"} {
set value [split $value " "]
setbncuser $user server [lindex $value 0]
setbncuser $user port [lindex $value 1]
} elseif {($setting == "ssl" || $setting == "usequitasaway") && $value == "on" } {
setbncuser $user $setting 1
} elseif {($setting == "ssl" || $setting == "usequitasaway") && $value == "off" } {
setbncuser $user $setting 0
} else {
setbncuser $user $setting $value
}
}
}
}
}
proc defaultsettings:command {client params} {
set command [string tolower [lindex $params 0]]
if {$command == "resetsettings" && [getbncuser $client admin]} {
if {[llength $params] == "1"} {
bncreply "Syntax: \"/sbnc resetsettings <target>\", where <target> is either a valid non-admin user or \"-all\" to target all users but the admins."
haltoutput
return
}
set target [string tolower [lindex $params 1]]
if {[bncvaliduser $target] && ![getbncuser $target admin]} {
defaultsettings:applydefaultsettings $target
bncreply "Done."
} elseif {$target == "-all"} {
foreach user [bncuserlist] {
defaultsettings:applydefaultsettings $user
}
bncreply "Done."
} else {
bncreply "\"$target\" is not a valid target."
}
haltoutput
return
}
if {$command == "help" && [getbncuser $client admin]} {
bncaddcommand resetsettings Admin "applys defaultsettings to a target" "/sbnc resetsettings <target> \nApplies the default-settings to <target>, which is either a valid non-admin user or \"-all\" to target all users but the admins."
return
}
if {$command == "globalset" && [getbncuser $client admin]} {
if {[llength $params] < 3} {
foreach defaultsetting $::defaultsettings_settings {
if {[bncgetglobaltag $defaultsetting] != ""} {
set reply [bncgetglobaltag $defaultsetting]
} else {
set reply "Not set"
}
internaltimer 0 0 bncreply "$defaultsetting - $reply"
}
return
}
set setting [string tolower [lindex $params 1]]
set value [join [lrange $params 2 end] " "]
if {[lsearch -exact $::defaultsettings_settings $setting] > -1} {
if {![defaultsettings:setdefaults $setting $value]} {
if {$setting == "default-server"} {
bncreply "Setting \"default-server\" needs to be in the form of \"<server> <port>\"."
} else {
bncreply "Setting \"$setting\" needs to be either \"on\" or \"off\"."
}
} else {
bncreply "Done."
}
haltoutput
}
}
}
proc defaultsettings:setdefaults {setting value} {
set setting [string tolower $setting]
switch $setting {
default-server {
if {[regexp {(^$|^.*[[:blank:]][[:digit:]]+$)} $value]} {
bncsetglobaltag default-server $value
return "1"
} else {
return "0"
}
}
default-ssl {
if {[regexp -nocase {(^$|^on$|^off$)} $value]} {
bncsetglobaltag default-ssl [string tolower $value]
return "1"
} else {
return "0"
}
}
default-usequitasaway {
if {[regexp -nocase {(^$|^on$|^off$)} $value]} {
bncsetglobaltag default-usequitasaway [string tolower $value]
return "1"
} else {
return "0"
}
}
default {
bncsetglobaltag $setting $value
return "1"
}
}
}
proc defaultsettings:iface_resetsettings {target} {
set target [string tolower $target]
if {[bncvaliduser $target] && ![getbncuser $target admin]} {
defaultsettings:applydefaultsettings $target
} elseif {$target == "-all"} {
foreach user [bncuserlist] {
defaultsettings:applydefaultsettings $user
}
} else {
return -code error "Invalid target."
}
return ""
}
if {[info commands "registerifacecmd"] != ""} {
registerifacecmd "defaultsettings" "resetsettings" "defaultsettings:iface_resetsettings" access:admin
}
proc defaultsettings:iface_setdefaults {setting value} {
set setting [string tolower $setting]
if {[lsearch -exact $::defaultsettings_settings $setting] > -1} {
if {![defaultsettings:setdefaults $setting $value]} {
if {$setting == "default-server"} {
return -code error "default-server needs to be in the form of \"<server> <port>\""
} else {
return -code error "$setting needs to be either \"on\" or \"off\""
}
} else {
return ""
}
} else {
return -code error "Invalid setting."
}
}
if {[info commands "registerifacecmd"] != ""} {
registerifacecmd "defaultsettings" "setdefaults" "defaultsettings:iface_setdefaults" access:admin
}
|