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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
# Description: The following procedures and commands help you to
# manage lists of channel operators of certain channels.
# Please see the comments below!
#
# Date: 03.03.98
# Author: Andreas Gelhausen, atte@gecko.north.de
#
# Changes: 03.03.98 Now this script can automatically be loaded
# from tkirc (~.tkirc/autoload/) and you
# don't need to change your tkircrc!
# 06.10.97 Small changes to output-messages.
# 30.09.97 Command `/gad' was improved.
# 25.07.97 Command `/gad' was added.
# See also install-instructions!
#
# Install:
# 1. copy this file to `~/.tkirc/autoload/chops.tcl'
# 2. edit arrays `chop_file' and `chop_sources'
# (see the examples below)
# 3. reload your tkircrc or restart tkirc
# chop_file & chop_sources:
# For each of your preferred channels you can add an element to
# array `chop_file' and one to array `chop_sources'.
# If a user with a matching address to an element of
# `chop_sources(<channel>)' promotes someone else to channel
# operator, the address of this new channel operator will be
# logged to file `$chop_file(<channel>)'. Please see the examples
# below!
#
# NOTE: The indices of these arrays have to be lowercase!
#
global chop_file chop_sources
set chop_file(\#tkirc) "~/.tkirc/chops-tkirc"
set chop_sources(\#tkirc) {
"atte@gecko.north.de"
}
# on_join_chops: The saved list of known channel operators will
# automatically be loaded, when you join that certain
# channel.
proc on_join_chops { } {
global on_args chop_file choplist nickname
set lo "[string tolower "$on_args(channel)"]"
if {[strcmp "$nickname" "$on_args(nick)"] == 0} {
if {[info exists chop_file($lo)]} {
print2crap "+++ Loading choplist for channel $on_args(channel)..."
set choplist($lo) ""
set file "[OpenFile "$chop_file($lo)" r]"
if {[string length "$file"]} {
while {[gets $file line] >= 0} {
set line "[string trim "$line" " "]"
if {"$line" != "" && "[string index "$line" 0]" != "#"} {
lappend choplist($lo) "$line"
}
}
close $file
}
}
}
}
# on_modechange_chops: The list of known channel operators will
# automatically be extended when a member of
# `chan_sources(<channel>)' gives someone a `+o'.
proc on_modechange_chops { } {
global on_args chop_sources chop_file choplist ctcp_nooplist
set lo "[string tolower "$on_args(to)"]"
if {[strcmp "+o" "$on_args(mode)"] == 0 \
&& [info exists chop_sources($lo)] \
&& [info exists chop_file($lo)] \
&& [info exists choplist($lo)]} {
for {set i 0} {$i < [llength "$chop_sources($lo)"]} {incr i} {
if {[strmatch "[lindex "$chop_sources($lo)" $i]" "[StripAddressPrefix "$on_args(address)"]"]} {
set address "[AddressOfNick "$on_args(argument)"]"
if {[string length "$address"]} {
if {[info exists ctcp_nooplist] && [ctcp_nooptest "$address"]} {
return
}
set file "[OpenFile "$chop_file($lo)" a]"
if {[string length "$file"]} {
for {set i 0} {$i < [llength "$choplist($lo)"]} {incr i} {
if {[strmatch "[lindex "$choplist($lo)" $i]" "$address"]} {
close $file
return
}
}
print2crap "+++ New operator found ($address) for channel $on_args(to)"
lappend choplist($lo) "$address"
puts $file "# $on_args(nick)!$on_args(address) ([longdate])"
puts $file "$address"
close $file
return
}
}
}
}
}
}
# on_command_loadchoplist: When you've edited the choplist-file of a channel,
# you should execute this command (`/loadchoplist')
# to update the list in memory.
proc on_command_loadchoplist {window arguments} {
global on_args chop_sources chop_file choplist win
set len [lLength "$arguments"]
if {$len < 1} {
print2crap "+++ Usage: /loadchoplist <channel>"
return
}
set channel "[lIndex "$arguments" 0]"
if {"$channel" == "*"} {
set channel "$win($window,actual)"
}
set lo "[string tolower "$channel"]"
if {[info exists chop_file($lo)]} {
print2crap "+++ Loading choplist for channel $channel..."
set file "[OpenFile "$chop_file($lo)" r]"
if {[string length "$file"]} {
set choplist($lo) ""
while {[gets $file line] >= 0} {
set line "[string trim "$line" " "]"
if {"$line" != "" && "[string index "$line" 0]" != "#"} {
lappend choplist($lo) "$line"
}
}
close $file
}
} else {
print2crap "+++ No choplist-file found for channel $channel"
}
}
# on_command_chops: This command (`/chops') will show you known channel
# operators of a certain channel without `+o'.
proc on_command_chops {window arguments} {
global chan win choplist ctcp_nooplist
set len [lLength "$arguments"]
if {$len < 1} {
print2crap "+++ Usage: /chops <channel>"
return
}
set count 0
set channel "[lIndex "$arguments" 0]"
if {"$channel" == "*"} {
set channel "$win($window,actual)"
}
set lo "[string tolower "$channel"]"
set cnum [GetChannelNumber "$channel"]
if {$cnum != -1} {
if {[info exists choplist($lo)]} {
set len [llength "$chan($cnum,addresses)"]
for {set i 0} {$i < [llength "$choplist($lo)"]} {incr i} {
for {set j 0} {$j < $len} {incr j} {
if {[strmatch "[lindex "$choplist($lo)" $i]" "[lindex "$chan($cnum,addresses)" $j]"]} {
if {[info exists ctcp_nooplist] && [ctcp_nooptest "[lindex "$chan($cnum,addresses)" $j]"]} {
continue
}
if {[lindex "$chan($cnum,olist)" $j] == 0} {
if {$count == 0} {
print2crap "+++ Known CHOPs without @ on channel $channel:"
}
print2crap "+++ - [lindex "$chan($cnum,nicks)" $j] ([lindex "$choplist($lo)" $i])"
incr count
}
}
}
}
if {$count == 0} {
print2crap "+++ No known CHOPs without @ found on channel $channel"
}
} else {
print2crap "+++ No list of CHOPs available for channel $channel"
}
} else {
print2crap "+++ You are not on channel $channel"
}
}
# on_command_gad: tkirc automatically gets addresses of users when they join
# one of your channels or when you make a /whois on them.
# The command `/gad' will get the lacking user-addresses of
# a given channel (maybe of users which joined that channel
# before).
# Be careful, because on channels with many users this
# command will make a lot of traffic and could take a
# while!
proc on_command_gad {window arguments} {
global chan win choplist crapwindow
set len [lLength "$arguments"]
if {$len < 1} {
print2crap "+++ Usage: /gad <channel>"
return
}
set channel "[lIndex "$arguments" 0]"
if {"$channel" == "*"} {
set channel "$win($window,actual)"
}
set cnum [GetChannelNumber "$channel"]
if {[info exists chan($cnum,addresses)]} {
set len [llength "$chan($cnum,addresses)"]
for {set i 0} {$i < $len} {incr i} {
if {[string length "[lindex "$chan($cnum,addresses)" $i]"] == 0} {
AddToWhoQueue "$channel" "$crapwindow" "+++ gad: Trying to get the user-addresses of channel $channel..." "+++ gad: All user-addresses of channel [expand "$channel"] available"
return
}
}
print2crap "+++ gad: All user-addresses of channel $channel already available"
}
}
|