/[cvs]/eggdrop1.6/scripts/notes2.tcl
ViewVC logotype

Contents of /eggdrop1.6/scripts/notes2.tcl

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


Revision 1.5 - (show annotations) (download) (as text)
Sat Mar 17 23:20:57 2001 UTC (19 years, 7 months ago) by guppy
Branch: MAIN
CVS Tags: eggdrop1_6_5, eggdrop1_6_6
Changes since 1.4: +2 -2 lines
File MIME type: application/x-tcl
typos fixed by eugene

1 #
2 # notes2.tcl - v2.1.1 - released by MHT <mht@mygale.org>
3 # - a bind apart script from #TSF
4 # - for eggdrop 1.3.15+
5 #
6 # $Id: notes2.tcl,v 1.4 2000/08/18 19:35:22 guppy Exp $
7 #
8 ####
9 #
10 # history:
11 # --------
12 # 2.0.0 - first release for 1.3.14+mht series
13 # (get notesat2.tcl for 1.1.5 series)
14 #
15 # 2.0.2 - Message bug corrected: "erased <m> notes; <n> left." is better.
16 # - Corrected weird switch tcl syntax, bug found by Islandic.
17 # It's so different from C (I hate tcl!).
18 # - Desactivated message "I don't know you", boring me !
19 # - No more logs for notes-indexing on join :-)
20 #
21 # 2.0.3 - Corrected invalid idx bug, if user quits before receiving
22 # his notes check.
23 #
24 # 2.1.0 - Improved protocol to avoid idx mistake for multiple connected users.
25 # Backward compatibility is kept, but price is that idx mistake occurs
26 # if a multiple connected user quits before receiving notes check.
27 # Generally never happens, except in case of 'Chriphil's syndrome' ;-p
28 # - Added missing 'You don't have that many messages.'
29 #
30 # 2.1.1 - fixed a couple of small bugs pertaining to $nick being used instead of
31 # $botnet-nick (found by takeda, fixed by guppy)
32 #
33 ####
34 # Check your notes on every shared bot of the hub.
35 #
36 # .notes [bot|all] index
37 # .notes [bot|all] read <#|all>
38 # .notes [bot|all] erase <#|all>
39 #
40 # # may be numbers and/or intervals separated by ;
41 # ex: .notes erase 2-4;8;16-
42 # .notes noBOTy read all
43 #
44
45
46 ########
47 unbind dcc - notes *dcc:notes
48 bind dcc - notes *dcc:notes2
49 bind chon - * *chon:notes2
50 bind bot - notes2: *bot:notes2
51 bind bot - notes2reply: *bot:notes2reply
52
53 ########
54 proc n2_notesindex {bot handle idx} {
55 global nick botnet-nick
56 switch "([notes $handle])" {
57 "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
58 #"-1" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
59 "(-1)" { return 0 }
60 "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
61 default {
62 putbot $bot "notes2reply: $handle ### You have the following notes waiting: $idx"
63 set index 0
64 foreach note [notes $handle "-"] {
65 if {($note != 0)} {
66 incr index
67 set sender [lindex $note 0]
68 set date [strftime "%b %d %H:%M" [lindex $note 1]]
69 putbot $bot "notes2reply: $handle %$index. $sender ($date) $idx"
70 }
71 }
72 putbot $bot "notes2reply: $handle ### Use '.notes ${botnet-nick} read' to read them. $idx"
73 }
74 }
75 return 1
76 }
77
78 ########
79 proc n2_notesread {bot handle idx numlist} {
80 if {($numlist == "")} { set numlist "-" }
81 switch "([notes $handle])" {
82 "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
83 #"(-1)" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
84 "(-1)" { return 0 }
85 "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
86 default {
87 set count 0
88 set list [listnotes $handle $numlist]
89 foreach note [notes $handle $numlist] {
90 if {($note != 0)} {
91 set index [lindex $list $count]
92 set sender [lindex $note 0]
93 set date [strftime "%b %d %H:%M" [lindex $note 1]]
94 set msg [lrange $note 2 end]
95 incr count
96 putbot $bot "notes2reply: $handle $index. $sender ($date): $msg $idx"
97 } else {
98 putbot $bot "notes2reply: $handle You don't have that many messages. $idx"
99 }
100 }
101 }
102 }
103 return 1
104 }
105
106 ########
107 proc n2_noteserase {bot handle idx numlist} {
108 switch [notes $handle] {
109 "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
110 #"(-1)" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
111 "(-1)" { return 0 }
112 "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
113 default {
114 set erased [erasenotes $handle $numlist]
115 set remaining [notes $handle]
116 if {($remaining == 0) && ($erased == 0)} {
117 putbot $bot "notes2reply: $handle You have no messages. $idx"
118 } elseif {($remaining == 0)} {
119 putbot $bot "notes2reply: $handle Erased all notes. $idx"
120 } elseif {($erased == 0)} {
121 putbot $bot "notes2reply: $handle You don't have that many messages. $idx"
122 } elseif {($erased == 1)} {
123 putbot $bot "notes2reply: $handle Erased 1 note, $remaining left. $idx"
124 } else {
125 putbot $bot "notes2reply: $handle Erased $erased notes, $remaining left. $idx"
126 }
127 }
128 }
129 return 1
130 }
131
132 ########
133 proc *bot:notes2 {handle idx arg} {
134 if {(![matchattr $handle s])} {
135 return
136 }
137 set nick [lindex $arg 0]
138 set cmd [lindex $arg 1]
139 set num [lindex $arg 2]
140 set idx [lindex $arg 3]
141 if {($num == "") || ($num == "all")} { set num "-" }
142 switch $cmd {
143 "silentindex" { set ret 0; n2_notesindex $handle $nick $idx }
144 "index" { set ret [n2_notesindex $handle $nick $idx] }
145 "read" { set ret [n2_notesread $handle $nick $idx $num] }
146 "erase" { set ret [n2_noteserase $handle $nick $idx $num] }
147 default { set ret 0 }
148 }
149 if {($num == "-")} { set num "" }
150 if {($ret == 1)} { putcmdlog "#$nick@$handle# notes $cmd $num" }
151 }
152
153 ########
154 proc *bot:notes2reply {handle idx arg} {
155 # verify that idx is valid (older scripts do not provide idx)
156 set idx [lindex $arg end]
157 if {([valididx $idx]) && ([idx2hand $idx] == [lindex $arg 0])} {
158 set reply [lrange $arg 1 [expr [llength $arg]-2]]
159 } else {
160 set idx [hand2idx [lindex $arg 0]]
161 set reply [lrange $arg 1 end]
162 }
163 if {($idx == -1)} { return }
164 if {([string range $reply 0 0] == "%")} {
165 set reply " [string range $reply 1 end]"
166 }
167 putidx $idx "($handle) $reply"
168 }
169
170 ########
171 proc *chon:notes2 {handle idx} {
172 putallbots "notes2: $handle silentindex $idx"
173 return 0
174 }
175
176 ########
177 proc *dcc:notes2 {handle idx arg} {
178 global nick botnet-nick
179 if {$arg == ""} {
180 putidx $idx "Usage: notes \[bot|all\] index"
181 putidx $idx " notes \[bot|all\] read <#|all>"
182 putidx $idx " notes \[bot|all\] erase <#|all>"
183 putidx $idx " # may be numbers and/or intervals separated by ;"
184 putidx $idx " ex: notes erase 2-4;8;16-"
185 putidx $idx " notes ${botnet-nick} read all"
186 } else {
187 set bot [string tolower [lindex $arg 0]]
188 set cmd [string tolower [lindex $arg 1]]
189 set numlog [string tolower [lindex $arg 2]]
190 set num $numlog
191 if {($num == "")} { set num "-" }
192 if {($bot != "all") && ([lsearch [string tolower [bots]] $bot] < 0)} {
193 if {($cmd != "index") && ($cmd != "read") && ($cmd != "erase")} {
194 if {($bot == [string tolower $nick])} {
195 return [*dcc:notes $handle $idx [lrange $arg 1 end]]
196 } else {
197 return [*dcc:notes $handle $idx $arg]
198 }
199 } else {
200 putidx $idx "I don't know anybot by that name."
201 return 0
202 }
203 } elseif {($cmd != "index") && ($cmd != "read") && ($cmd != "erase")} {
204 putdcc $idx "Function must be one of INDEX, READ, or ERASE."
205 } elseif {$bot == "all"} {
206 #*dcc:notes $handle $idx [lrange $arg 1 end]
207 putallbots "notes2: $handle $cmd $num $idx"
208 } else {
209 putbot $bot "notes2: $handle $cmd $num $idx"
210 }
211 putcmdlog "#$handle# notes@$bot $cmd $numlog"
212 }
213 }
214
215 ########
216 putlog "Notes 2.1.0 - Released by MHT <mht@mygale.org>"
217
218 ####

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23