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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Mon Oct 4 21:25:44 1999 UTC (20 years ago) by guppy
Branch: MAIN
Changes since 1.1: +104 -138 lines
File MIME type: application/x-tcl
ques5.tcl ... yay

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 # reversed some of these weird changes and more fixes by rtc 20Sep1999
11 # version for 1.3 bots only by rtc 24Sep1999
12
13 ########################################
14 # Descriptions of avaliable commands:
15 ## (removed from toolkit):
16 # newflag <flag> - REMOVED numeric flags are no longer supported in this way
17 #
18 ## (toolkit):
19 # putmsg <nick> <text>
20 # send a message to someone on irc
21 #
22 # putchan <channel> <text>
23 # send a public message to a channel
24 # technically identical to putmsg
25 #
26 # putnotc <nick/channel> <text>
27 # send a notice to a nick/channel
28 #
29 # putact <nick/channel> <text>
30 # send an action to a nick/channel
31 #
32 ## (toolbox):
33 # strlwr <string>
34 # string tolower
35 #
36 # strupr <string>
37 # string toupper
38 #
39 # strcmp <string1> <string2>
40 # string compare
41 #
42 # stricmp <string1> <string2>
43 # string compare (case insensitive)
44 #
45 # strlen <string>
46 # string length
47 #
48 # stridx <string> <index>
49 # string index
50 #
51 # iscommand <command>
52 # if the given command exists, return 1
53 # else return 0
54 #
55 # timerexists <command>
56 # if the given command is scheduled by a timer, return its timer id
57 # else return ""
58 #
59 # utimerexists <command>
60 # if the given command is scheduled by a utimer, return its utimer id
61 # else return ""
62 #
63 # inchain <bot>
64 # if the given bot is connected to the botnet, return 1
65 # else return 0
66 #
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 # returns nothing
73 #
74 # putdccbut <idx> <text>
75 # send the given text to all dcc users except for the given idx
76 # returns nothing
77 #
78 # killdccall
79 # kill all dcc user connections
80 # returns nothing
81 #
82 # killdccbut <idx>
83 # kill all dcc user connections except for the given idx
84 # returns nothing
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 # not specifying any format will return the current time
95 # in 12 hour format '1:15 am'
96 #
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 # else it returns what it gets.
104 #
105 ## other
106 # isnumber <string>
107 # returns 1 if 'string' is a number, 0 if not
108 #
109 ########################################
110
111 # So scripts can see if allt is loaded.
112 set alltools_loaded 1
113 set allt_version 205
114
115 # For backward comptibility.
116 set toolbox_revision 1007
117 set toolbox_loaded 1
118 set toolkit_loaded 1
119
120 # Procs.............
121 proc number_to_number {number} {
122 switch -- $number {
123 "0" {return "Zero"}
124 "1" {return "One"}
125 "2" {return "Two"}
126 "3" {return "Three"}
127 "4" {return "Four"}
128 "5" {return "Five"}
129 "6" {return "Six"}
130 "7" {return "Seven"}
131 "8" {return "Eight"}
132 "9" {return "Nine"}
133 "10" {return "Ten"}
134 "11" {return "Eleven"}
135 "12" {return "Twelve"}
136 "13" {return "Thirteen"}
137 "14" {return "Fourteen"}
138 "15" {return "Fifteen"}
139 default {return $number}
140 }
141 }
142
143 proc isnumber {string} {
144 return [expr {![regexp \[^0-9\] $string] && $string != ""}]
145 }
146
147 proc testip {address} {
148 set testhost [split $address "."]
149 if {[llength $testhost] != 4} {return 0}
150 foreach part $testhost {
151 # >= 0 is just for undertandability, not really needed.
152 if {[string length $part] > 3 || ![isnumber $part] || !($part >= 0 && $part <= 255)} {
153 return 0
154 }
155 }
156 return 1
157 }
158
159 proc realtime {{type ""}} {
160 switch -- $type {
161 time {
162 return [clock format [clock seconds] -format "%H:%M"]
163 }
164 date {
165 return [clock format [clock seconds] -format "%d %b %Y"]
166 }
167 "" {
168 return [clock format [clock seconds] -format "%I:%M %P"]
169 }
170 }
171 }
172
173 proc iso {nick chan} {
174 return [matchattr [nick2hand $nick $chan] o|o $chan]
175 }
176
177 proc putmsg {target text} {
178 putserv "PRIVMSG $target :$text"
179 }
180
181 proc putnotc {target text} {
182 putserv "NOTICE $target :$text"
183 }
184
185 proc putchan {target text} {
186 putserv "PRIVMSG $target :$text"
187 }
188
189 proc putact {target text} {
190 putserv "PRIVMSG $target :\001ACTION $text\001"
191 }
192
193 proc strlwr {string} {
194 return [string tolower $string]
195 }
196
197 proc strupr {string} {
198 return [string toupper $string]
199 }
200
201 proc strcmp {string1 string2} {
202 return [string compare $string1 $string2]
203 }
204
205 proc stricmp {string1 string2} {
206 return [string compare [string tolower $string1] [string tolower $string2]]
207 }
208
209 proc strlen {string} {
210 return [string length $string]
211 }
212
213 proc stridx {string index} {
214 return [string index $string $index]
215 }
216
217 proc iscommand {command} {
218 if {[info commands $command] == $command} {
219 return 1
220 }
221 return 0
222 }
223
224 proc timerexists {command} {
225 foreach i [timers] {
226 if {[lindex $i 1] == $command} {
227 return [lindex $i 2]
228 }
229 }
230 return ""
231 }
232
233 proc utimerexists {command} {
234 foreach i [utimers] {
235 if {[lindex $i 1] == $command} {
236 return [lindex $i 2]
237 }
238 }
239 return ""
240 }
241
242 proc inchain {bot} {
243 return [islinked $bot]
244 }
245
246 proc randstring {length} {
247 # [rtc] not for tcllib as rand is an eggdrop extension
248 set result ""
249 set chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
250 set count [string length $chars]
251 for {set i 0} {$i < $length} {incr i} {
252 append result [string index $chars [rand $count]]
253 }
254 return $result
255 }
256
257 proc putdccall {text} {
258 foreach i [dcclist CHAT] {
259 putdcc [lindex $i 0] $text
260 }
261 }
262
263 proc putdccbut {idx text} {
264 foreach i [dcclist CHAT] {
265 set j [lindex $i 0]
266 if {$j != $idx} {
267 putdcc $j $text
268 }
269 }
270 }
271
272 proc killdccall {} {
273 foreach i [dcclist CHAT] {
274 killdcc [lindex $i 0]
275 }
276 }
277
278 proc killdccbut {idx} {
279 foreach i [dcclist CHAT] {
280 set j [lindex $i 0]
281 if {$j != $idx} {
282 killdcc $j
283 }
284 }
285 }
286

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23