/[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.4 - (show annotations) (download) (as text)
Sat Oct 23 23:22:36 1999 UTC (20 years ago) by guppy
Branch: MAIN
Changes since 1.3: +95 -79 lines
File MIME type: application/x-tcl
patches and more patches

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23