/[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.5 - (show annotations) (download) (as text)
Wed Dec 15 02:32:57 1999 UTC (19 years, 10 months ago) by guppy
Branch: MAIN
CVS Tags: eggdrop104030RC2, eggdrop10403RC1, eggdrop10402RC1, eggdrop10403, eggdrop10402
Changes since 1.4: +3 -0 lines
File MIME type: application/x-tcl
id-header patch, finally, we have id tags for each file

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23