/[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.1 - (show annotations) (download) (as text)
Mon Sep 13 14:36:18 1999 UTC (21 years, 1 month ago) by segfault
Branch: MAIN
File MIME type: application/x-tcl
Initial commit based off of .29 cvs

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23