/[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.3 - (hide annotations) (download) (as text)
Thu Oct 7 13:45:33 1999 UTC (20 years ago) by arthur2
Branch: MAIN
Changes since 1.2: +138 -104 lines
File MIME type: application/x-tcl
patch reversed till rtc/Toth find an agreement about it

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23