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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23