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

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

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


Revision 1.7 - (hide 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 guppy 1.5 #
2 segfault 1.1 # All-Tools TCL, includes toolbox.tcl, toolkit.tcl and moretools.tcl
3 guppy 1.4 # 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 guppy 1.6 # krbb 09Jun2000: added missing return to randstring
16 guppy 1.7 # Tothwolf 18Jun2000: added ispermowner
17 guppy 1.5 #
18 guppy 1.7 # $Id: alltools.tcl,v 1.6 2000/06/10 07:03:31 guppy Exp $
19 guppy 1.4 #
20 segfault 1.1 ########################################
21     # Descriptions of avaliable commands:
22     ## (toolkit):
23 arthur2 1.3 # putmsg <nick/chan> <text>
24 guppy 1.4 # send a privmsg to the given nick or channel
25 segfault 1.1 #
26 arthur2 1.3 # putchan <nick/chan> <text>
27 guppy 1.4 # send a privmsg to the given nick or channel
28     # (for compat only, this is the same as 'putmsg' above)
29 segfault 1.1 #
30 arthur2 1.3 # putnotc <nick/chan> <text>
31 guppy 1.4 # send a notice to the given nick or channel
32 segfault 1.1 #
33 arthur2 1.3 # putact <nick/chan> <text>
34 guppy 1.4 # send an action to the given nick or channel
35 segfault 1.1 #
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 guppy 1.4 # else return empty string
62 segfault 1.1 #
63     # utimerexists <command>
64     # if the given command is scheduled by a utimer, return its utimer id
65 guppy 1.4 # else return empty string
66 segfault 1.1 #
67     # inchain <bot>
68     # if the given bot is connected to the botnet, return 1
69     # else return 0
70 guppy 1.4 # (for compat only, same as 'islinked')
71 segfault 1.1 #
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 guppy 1.4 # not specifying any format will return the current time in
96     # 12 hour format '1:15 am'
97 segfault 1.1 #
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 guppy 1.4 # 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 segfault 1.1 #
111 guppy 1.7 # ispermowner <handle>
112     # if the given handle is a permanent owner, return 1
113     # else return 0
114     #
115 segfault 1.1 ########################################
116    
117     # So scripts can see if allt is loaded.
118     set alltools_loaded 1
119 guppy 1.4 set allt_version 204
120 segfault 1.1
121     # For backward comptibility.
122     set toolbox_revision 1007
123     set toolbox_loaded 1
124     set toolkit_loaded 1
125    
126 guppy 1.4 #
127     # toolbox:
128     #
129    
130     proc putmsg {dest text} {
131     puthelp "PRIVMSG $dest :$text"
132 segfault 1.1 }
133    
134 guppy 1.4 proc putchan {dest text} {
135     puthelp "PRIVMSG $dest :$text"
136 segfault 1.1 }
137    
138 guppy 1.4 proc putnotc {dest text} {
139     puthelp "NOTICE $dest :$text"
140 segfault 1.1 }
141    
142 guppy 1.4 proc putact {dest text} {
143     puthelp "PRIVMSG $dest :\001ACTION $text\001"
144 segfault 1.1 }
145    
146 guppy 1.4 #
147     # toolkit:
148     #
149    
150 segfault 1.1 proc strlwr {string} {
151 guppy 1.4 string tolower $string
152 segfault 1.1 }
153    
154     proc strupr {string} {
155 guppy 1.4 string toupper $string
156 segfault 1.1 }
157    
158     proc strcmp {string1 string2} {
159 guppy 1.4 string compare $string1 $string2
160 segfault 1.1 }
161    
162     proc stricmp {string1 string2} {
163 guppy 1.4 string compare [string tolower $string1] [string tolower $string2]
164 segfault 1.1 }
165    
166     proc strlen {string} {
167 guppy 1.4 string length $string
168 segfault 1.1 }
169    
170     proc stridx {string index} {
171 guppy 1.4 string index $string $index
172 segfault 1.1 }
173    
174     proc iscommand {command} {
175 guppy 1.4 if {[string compare [info commands $command] ""]} then {
176 segfault 1.1 return 1
177     }
178     return 0
179     }
180    
181     proc timerexists {command} {
182     foreach i [timers] {
183 guppy 1.4 if {[string compare $command [lindex $i 1]] == 0} then {
184 segfault 1.1 return [lindex $i 2]
185     }
186     }
187 arthur2 1.3 return
188 segfault 1.1 }
189    
190     proc utimerexists {command} {
191     foreach i [utimers] {
192 guppy 1.4 if {[string compare $command [lindex $i 1]] == 0} then {
193 segfault 1.1 return [lindex $i 2]
194     }
195     }
196 arthur2 1.3 return
197 segfault 1.1 }
198    
199     proc inchain {bot} {
200 guppy 1.4 islinked $bot
201 segfault 1.1 }
202    
203     proc randstring {length} {
204     set chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
205     set count [string length $chars]
206 guppy 1.4 for {set i 0} {$i < $length} {incr i} {
207     append result [string index $chars [rand $count]]
208 segfault 1.1 }
209 guppy 1.6 return $result
210 segfault 1.1 }
211    
212     proc putdccall {text} {
213 guppy 1.4 foreach i [dcclist CHAT] {
214     putdcc [lindex $i 0] $text
215 segfault 1.1 }
216     }
217    
218     proc putdccbut {idx text} {
219 guppy 1.4 foreach i [dcclist CHAT] {
220 segfault 1.1 set j [lindex $i 0]
221 guppy 1.4 if {$j != $idx} then {
222 segfault 1.1 putdcc $j $text
223     }
224     }
225     }
226    
227     proc killdccall {} {
228 guppy 1.4 foreach i [dcclist CHAT] {
229     killdcc [lindex $i 0]
230 segfault 1.1 }
231     }
232    
233     proc killdccbut {idx} {
234 guppy 1.4 foreach i [dcclist CHAT] {
235 segfault 1.1 set j [lindex $i 0]
236 guppy 1.4 if {$j != $idx} then {
237 segfault 1.1 killdcc $j
238     }
239     }
240     }
241    
242 guppy 1.4 #
243     # moretools:
244     #
245    
246 arthur2 1.3 proc iso {nick chan} {
247 guppy 1.4 matchattr [nick2hand $nick $chan] o|o $chan
248 arthur2 1.3 }
249    
250     proc realtime {args} {
251 guppy 1.4 switch -exact -- $args {
252 arthur2 1.3 time {
253 guppy 1.4 strftime "%H:%M"
254 arthur2 1.3 }
255     date {
256 guppy 1.4 strftime "%d %b %Y"
257 arthur2 1.3 }
258     default {
259 guppy 1.4 strftime "%I:%M %P"
260 arthur2 1.3 }
261     }
262     }
263    
264     proc testip {ip} {
265     set tmp [split $ip .]
266 guppy 1.4 if {[llength $tmp] != 4} then {
267 arthur2 1.3 return 0
268     }
269     set index 0
270     foreach i $tmp {
271 guppy 1.4 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 arthur2 1.3 return 0
275     }
276 guppy 1.4 incr index
277 arthur2 1.3 }
278     return 1
279     }
280    
281     proc number_to_number {number} {
282 guppy 1.4 switch -exact -- $number {
283 arthur2 1.3 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 guppy 1.4 default {
332     return $number
333     }
334 arthur2 1.3 }
335 guppy 1.4 }
336    
337     #
338     # other commands:
339     #
340    
341     proc isnumber {string} {
342     if {([string compare $string ""]) && (![regexp \[^0-9\] $string])} then {
343 guppy 1.7 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 guppy 1.4 return 1
355     }
356     return 0
357 arthur2 1.3 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23