/[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.6 - (show annotations) (download) (as text)
Sat Jun 10 07:03:31 2000 UTC (19 years, 4 months ago) by guppy
Branch: MAIN
Changes since 1.5: +3 -1 lines
File MIME type: application/x-tcl
yay patches 1.4.4 looking close?

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23