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

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23