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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23