/[cvs]/eggdrop1.4/scripts/alltools.tcl
ViewVC logotype

Contents of /eggdrop1.4/scripts/alltools.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Thu Jun 22 03:45:05 2000 UTC (19 years, 4 months ago) by guppy
Branch: MAIN
CVS Tags: eggdrop10404, HEAD
Changes since 1.6: +17 -1 lines
File MIME type: application/x-tcl
put all patches in the queue into 1.4

1 #
2 # All-Tools TCL, includes toolbox.tcl, toolkit.tcl and moretools.tcl
3 # toolbox was authored by cmwagner@sodre.net
4 # toolkit was authored by (Someone claim this)[unknown]
5 # moretools was authored by David Sesno(walker@shell.pcrealm.net)
6 #
7 # TG ?????????: modified for 1.3.0 bots
8 # Tothwolf 02May1999: rewritten and updated
9 # guppy 02May1999: updated even more
10 # Tothwolf 02May1999: fixed what guppy broke and updated again
11 # Tothwolf 24/25May1999: more changes
12 # rtc 20Sep1999: added isnumber, changes
13 # dw 20Sep1999: use regexp for isnumber checking
14 # Tothwolf 06Oct1999: optimized completely
15 # krbb 09Jun2000: added missing return to randstring
16 # Tothwolf 18Jun2000: added ispermowner
17 #
18 # $Id: alltools.tcl,v 1.6 2000/06/10 07:03:31 guppy Exp $
19 #
20 ########################################
21 # Descriptions of avaliable commands:
22 ## (toolkit):
23 # putmsg <nick/chan> <text>
24 # send a privmsg to the given nick or channel
25 #
26 # putchan <nick/chan> <text>
27 # send a privmsg to the given nick or channel
28 # (for compat only, this is the same as 'putmsg' above)
29 #
30 # putnotc <nick/chan> <text>
31 # send a notice to the given nick or channel
32 #
33 # putact <nick/chan> <text>
34 # send an action to the given nick or channel
35 #
36 ## (toolbox):
37 # strlwr <string>
38 # string tolower
39 #
40 # strupr <string>
41 # string toupper
42 #
43 # strcmp <string1> <string2>
44 # string compare
45 #
46 # stricmp <string1> <string2>
47 # string compare (case insensitive)
48 #
49 # strlen <string>
50 # string length
51 #
52 # stridx <string> <index>
53 # string index
54 #
55 # iscommand <command>
56 # if the given command exists, return 1
57 # else return 0
58 #
59 # timerexists <command>
60 # if the given command is scheduled by a timer, return its timer id
61 # else return empty string
62 #
63 # utimerexists <command>
64 # if the given command is scheduled by a utimer, return its utimer id
65 # else return empty string
66 #
67 # inchain <bot>
68 # if the given bot is connected to the botnet, return 1
69 # else return 0
70 # (for compat only, same as 'islinked')
71 #
72 # randstring <length>
73 # returns a random string of the given length
74 #
75 # putdccall <text>
76 # send the given text to all dcc users
77 #
78 # putdccbut <idx> <text>
79 # send the given text to all dcc users except for the given idx
80 #
81 # killdccall
82 # kill all dcc user connections
83 #
84 # killdccbut <idx>
85 # kill all dcc user connections except for the given idx
86 #
87 ## (moretools):
88 # iso <nick> <channel>
89 # if the given nick has +o access on the given channel, return 1
90 # else return 0
91 #
92 # realtime [format]
93 # 'time' returns the current time in 24 hour format '14:15'
94 # 'date' returns the current date in the format '21 Dec 1994'
95 # not specifying any format will return the current time in
96 # 12 hour format '1:15 am'
97 #
98 # testip <ip>
99 # if the given ip is valid, return 1
100 # else return 0
101 #
102 # number_to_number <number>
103 # if the given number is between 1 and 15, return its analog representation
104 # else return the number given
105 #
106 ## (other commands):
107 # isnumber <string>
108 # if the given string is a valid number, return 1
109 # else return 0
110 #
111 # ispermowner <handle>
112 # if the given handle is a permanent owner, return 1
113 # else return 0
114 #
115 ########################################
116
117 # So scripts can see if allt is loaded.
118 set alltools_loaded 1
119 set allt_version 204
120
121 # For backward comptibility.
122 set toolbox_revision 1007
123 set toolbox_loaded 1
124 set toolkit_loaded 1
125
126 #
127 # toolbox:
128 #
129
130 proc putmsg {dest text} {
131 puthelp "PRIVMSG $dest :$text"
132 }
133
134 proc putchan {dest text} {
135 puthelp "PRIVMSG $dest :$text"
136 }
137
138 proc putnotc {dest text} {
139 puthelp "NOTICE $dest :$text"
140 }
141
142 proc putact {dest text} {
143 puthelp "PRIVMSG $dest :\001ACTION $text\001"
144 }
145
146 #
147 # toolkit:
148 #
149
150 proc strlwr {string} {
151 string tolower $string
152 }
153
154 proc strupr {string} {
155 string toupper $string
156 }
157
158 proc strcmp {string1 string2} {
159 string compare $string1 $string2
160 }
161
162 proc stricmp {string1 string2} {
163 string compare [string tolower $string1] [string tolower $string2]
164 }
165
166 proc strlen {string} {
167 string length $string
168 }
169
170 proc stridx {string index} {
171 string index $string $index
172 }
173
174 proc iscommand {command} {
175 if {[string compare [info commands $command] ""]} then {
176 return 1
177 }
178 return 0
179 }
180
181 proc timerexists {command} {
182 foreach i [timers] {
183 if {[string compare $command [lindex $i 1]] == 0} then {
184 return [lindex $i 2]
185 }
186 }
187 return
188 }
189
190 proc utimerexists {command} {
191 foreach i [utimers] {
192 if {[string compare $command [lindex $i 1]] == 0} then {
193 return [lindex $i 2]
194 }
195 }
196 return
197 }
198
199 proc inchain {bot} {
200 islinked $bot
201 }
202
203 proc randstring {length} {
204 set chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
205 set count [string length $chars]
206 for {set i 0} {$i < $length} {incr i} {
207 append result [string index $chars [rand $count]]
208 }
209 return $result
210 }
211
212 proc putdccall {text} {
213 foreach i [dcclist CHAT] {
214 putdcc [lindex $i 0] $text
215 }
216 }
217
218 proc putdccbut {idx text} {
219 foreach i [dcclist CHAT] {
220 set j [lindex $i 0]
221 if {$j != $idx} then {
222 putdcc $j $text
223 }
224 }
225 }
226
227 proc killdccall {} {
228 foreach i [dcclist CHAT] {
229 killdcc [lindex $i 0]
230 }
231 }
232
233 proc killdccbut {idx} {
234 foreach i [dcclist CHAT] {
235 set j [lindex $i 0]
236 if {$j != $idx} then {
237 killdcc $j
238 }
239 }
240 }
241
242 #
243 # moretools:
244 #
245
246 proc iso {nick chan} {
247 matchattr [nick2hand $nick $chan] o|o $chan
248 }
249
250 proc realtime {args} {
251 switch -exact -- $args {
252 time {
253 strftime "%H:%M"
254 }
255 date {
256 strftime "%d %b %Y"
257 }
258 default {
259 strftime "%I:%M %P"
260 }
261 }
262 }
263
264 proc testip {ip} {
265 set tmp [split $ip .]
266 if {[llength $tmp] != 4} then {
267 return 0
268 }
269 set index 0
270 foreach i $tmp {
271 if {((![regexp \[^0-9\] $i]) || ([string length $i] > 3) ||
272 (($index == 3) && (($i > 254) || ($i < 1))) ||
273 (($index <= 2) && (($i > 255) || ($i < 0))))} then {
274 return 0
275 }
276 incr index
277 }
278 return 1
279 }
280
281 proc number_to_number {number} {
282 switch -exact -- $number {
283 0 {
284 return Zero
285 }
286 1 {
287 return One
288 }
289 2 {
290 return Two
291 }
292 3 {
293 return Three
294 }
295 4 {
296 return Four
297 }
298 5 {
299 return Five
300 }
301 6 {
302 return Six
303 }
304 7 {
305 return Seven
306 }
307 8 {
308 return Eight
309 }
310 9 {
311 return Nine
312 }
313 10 {
314 return Ten
315 }
316 11 {
317 return Eleven
318 }
319 12 {
320 return Twelve
321 }
322 13 {
323 return Thirteen
324 }
325 14 {
326 return Fourteen
327 }
328 15 {
329 return Fifteen
330 }
331 default {
332 return $number
333 }
334 }
335 }
336
337 #
338 # other commands:
339 #
340
341 proc isnumber {string} {
342 if {([string compare $string ""]) && (![regexp \[^0-9\] $string])} then {
343 return 1
344 }
345 return 0
346 }
347
348 proc ispermowner {hand} {
349 global owner
350
351 regsub -all -- , [string tolower $owner] "" owners
352 if {([matchattr $hand n]) && \
353 ([lsearch -exact $owners [string tolower $hand]] != -1)} then {
354 return 1
355 }
356 return 0
357 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23