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

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

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


Revision 1.2 - (hide annotations) (download) (as text)
Tue Dec 21 17:35:08 1999 UTC (20 years, 10 months ago) by fabian
Branch: MAIN
CVS Tags: eggdrop105020, eggdrop10503, eggdrop10403
Changes since 1.1: +2 -0 lines
File MIME type: application/x-tcl
Tothwolf's id-header

1 segfault 1.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 fabian 1.2 # $Id$
7     #
8 segfault 1.1 ####
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     ####
31     # Check your notes on every shared bot of the hub.
32     #
33     # .notes [bot|all] index
34     # .notes [bot|all] read <#|all>
35     # .notes [bot|all] erase <#|all>
36     #
37     # # may be numbers and/or intervals separated by ;
38     # ex: .notes erase 2-4;8;16-
39     # .notes noBOTy read all
40     #
41    
42    
43     ########
44     unbind dcc - notes *dcc:notes
45     bind dcc - notes *dcc:notes2
46     bind chon - * *chon:notes2
47     bind bot - notes2: *bot:notes2
48     bind bot - notes2reply: *bot:notes2reply
49    
50     ########
51     proc n2_notesindex {bot handle idx} {
52     global nick
53     switch "([notes $handle])" {
54     "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
55     #"-1" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
56     "(-1)" { return 0 }
57     "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
58     default {
59     putbot $bot "notes2reply: $handle ### You have the following notes waiting: $idx"
60     set index 0
61     foreach note [notes $handle "-"] {
62     if {($note != 0)} {
63     incr index
64     set sender [lindex $note 0]
65     set date [strftime "%b %d %H:%M" [lindex $note 1]]
66     putbot $bot "notes2reply: $handle %$index. $sender ($date) $idx"
67     }
68     }
69     putbot $bot "notes2reply: $handle ### Use '.notes $nick read' to read them. $idx"
70     }
71     }
72     return 1
73     }
74    
75     ########
76     proc n2_notesread {bot handle idx numlist} {
77     if {($numlist == "")} { set numlist "-" }
78     switch "([notes $handle])" {
79     "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
80     #"(-1)" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
81     "(-1)" { return 0 }
82     "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
83     default {
84     set count 0
85     set list [listnotes $handle $numlist]
86     foreach note [notes $handle $numlist] {
87     if {($note != 0)} {
88     set index [lindex $list $count]
89     set sender [lindex $note 0]
90     set date [strftime "%b %d %H:%M" [lindex $note 1]]
91     set msg [lrange $note 2 end]
92     incr count
93     putbot $bot "notes2reply: $handle $index. $sender ($date): $msg $idx"
94     } else {
95     putbot $bot "notes2reply: $handle You don't have that many messages. $idx"
96     }
97     }
98     }
99     }
100     return 1
101     }
102    
103     ########
104     proc n2_noteserase {bot handle idx numlist} {
105     switch [notes $handle] {
106     "(-2)" { putbot $bot "notes2reply: $handle Notefile failure. $idx" }
107     #"(-1)" { putbot $bot "notes2reply: $handle I don't know you. $idx" }
108     "(-1)" { return 0 }
109     "(0)" { putbot $bot "notes2reply: $handle You have no messages. $idx" }
110     default {
111     set erased [erasenotes $handle $numlist]
112     set remaining [notes $handle]
113     if {($remaining == 0) && ($erased == 0)} {
114     putbot $bot "notes2reply: $handle You have no messages. $idx"
115     } elseif {($remaining == 0)} {
116     putbot $bot "notes2reply: $handle Erased all notes. $idx"
117     } elseif {($erased == 0)} {
118     putbot $bot "notes2reply: $handle You don't have that many messages. $idx"
119     } elseif {($erased == 1)} {
120     putbot $bot "notes2reply: $handle Erased 1 note, $remaining left. $idx"
121     } else {
122     putbot $bot "notes2reply: $handle Erased $erased notes, $remaining left. $idx"
123     }
124     }
125     }
126     return 1
127     }
128    
129     ########
130     proc *bot:notes2 {handle idx arg} {
131     if {(![matchattr $handle s])} {
132     return
133     }
134     set nick [lindex $arg 0]
135     set cmd [lindex $arg 1]
136     set num [lindex $arg 2]
137     set idx [lindex $arg 3]
138     if {($num == "") || ($num == "all")} { set num "-" }
139     switch $cmd {
140     "silentindex" { set ret 0; n2_notesindex $handle $nick $idx }
141     "index" { set ret [n2_notesindex $handle $nick $idx] }
142     "read" { set ret [n2_notesread $handle $nick $idx $num] }
143     "erase" { set ret [n2_noteserase $handle $nick $idx $num] }
144     default { set ret 0 }
145     }
146     if {($num == "-")} { set num "" }
147     if {($ret == 1)} { putcmdlog "#$nick@$handle# notes $cmd $num" }
148     }
149    
150     ########
151     proc *bot:notes2reply {handle idx arg} {
152     # verify that idx is valid (older scripts does not provide idx)
153     set idx [lindex $arg end]
154     if {([valididx $idx]) && ([idx2hand $idx] == [lindex $arg 0])} {
155     set reply [lrange $arg 1 [expr [llength $arg]-2]]
156     } else {
157     set idx [hand2idx [lindex $arg 0]]
158     set reply [lrange $arg 1 end]
159     }
160     if {($idx == -1)} { return }
161     if {([string range $reply 0 0] == "%")} {
162     set reply " [string range $reply 1 end]"
163     }
164     putidx $idx "($handle) $reply"
165     }
166    
167     ########
168     proc *chon:notes2 {handle idx} {
169     putallbots "notes2: $handle silentindex $idx"
170     return 0
171     }
172    
173     ########
174     proc *dcc:notes2 {handle idx arg} {
175     global nick
176     if {$arg == ""} {
177     putidx $idx "Usage: notes \[bot|all\] index"
178     putidx $idx " notes \[bot|all\] read <#|all>"
179     putidx $idx " notes \[bot|all\] erase <#|all>"
180     putidx $idx " # may be numbers and/or intervals separated by ;"
181     putidx $idx " ex: notes erase 2-4;8;16-"
182     putidx $idx " notes $nick read all"
183     } else {
184     set bot [string tolower [lindex $arg 0]]
185     set cmd [string tolower [lindex $arg 1]]
186     set numlog [string tolower [lindex $arg 2]]
187     set num $numlog
188     if {($num == "")} { set num "-" }
189     if {($bot != "all") && ([lsearch [string tolower [bots]] $bot] < 0)} {
190     if {($cmd != "index") && ($cmd != "read") && ($cmd != "erase")} {
191     if {($bot == [string tolower $nick])} {
192     return [*dcc:notes $handle $idx [lrange $arg 1 end]]
193     } else {
194     return [*dcc:notes $handle $idx $arg]
195     }
196     } else {
197     putidx $idx "I don't know anybot by that name."
198     return 0
199     }
200     } elseif {($cmd != "index") && ($cmd != "read") && ($cmd != "erase")} {
201     putdcc $idx "Function must be one of INDEX, READ, or ERASE."
202     } elseif {$bot == "all"} {
203     #*dcc:notes $handle $idx [lrange $arg 1 end]
204     putallbots "notes2: $handle $cmd $num $idx"
205     } else {
206     putbot $bot "notes2: $handle $cmd $num $idx"
207     }
208     putcmdlog "#$handle# notes@$bot $cmd $numlog"
209     }
210     }
211    
212     ########
213     putlog "Notes 2.1.0 - Released by MHT <mht@mygale.org>"
214    
215     ####

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23