community/pipermail-archives/sup-talk/2012-11.txt (20747B) - raw
1 From atann@alphasrv.net Thu Nov 22 14:54:08 2012
2 From: atann@alphasrv.net (Andre Tann)
3 Date: Thu, 22 Nov 2012 15:54:08 +0100
4 Subject: [sup-talk] Hooks - some examples appreciated
5 Message-ID: <201211221554.08990@inter.netz>
6
7 Hello everyone,
8
9 as this Website http://sup.rubyforge.org/wiki/wiki.pl?Hooks is not
10 really informative ;) ? does anybody here have some examples for sup
11 hooks?
12
13 I'm completely new to ruby, nearly completely new to sup, and I would
14 like to do some tagging in the after-poll.rb hook.
15
16 Thanks a lot!
17 Andre
18
19 --
20 Andre Tann
21
22
23 From jim@gonzul.net Thu Nov 22 21:35:54 2012
24 From: jim@gonzul.net (Jim Cheetham)
25 Date: Fri, 23 Nov 2012 10:35:54 +1300
26 Subject: [sup-talk] Hooks - some examples appreciated
27 In-Reply-To: <201211221554.08990@inter.netz>
28 References: <201211221554.08990@inter.netz>
29 Message-ID: <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
30
31 On Fri, Nov 23, 2012 at 3:54 AM, Andre Tann <atann at alphasrv.net> wrote:
32 > as this Website http://sup.rubyforge.org/wiki/wiki.pl?Hooks is not
33 > really informative ;) ? does anybody here have some examples for sup
34 > hooks?
35
36 Sadly the wiki has been almost completely spammed out of existance; it
37 doesn't store a long-enough revision history to get reverted correctly
38 any more.
39
40 You probably should be doing tagging in before-add.rb
41
42 In my before-add hook I was doing a lot of tagging, so much that I
43 built a small function to help me add and remove tags in one
44 invocation. A bunch of standard actions help.
45
46 First, extract the useful fields -- because a message can have
47 multiple recipients and I want to check any/all of them (To, Cc, Bcc).
48 Doing this means I don't have to check the array of recpipents every
49 time, I can just use string matching on a long flat list of
50 recipients.
51
52 ----
53 # Build up an array of recipients for this message
54 recipients=[]
55 message.recipients.each {|rp| recipients << rp.email }
56 recips = recipients.join(' ')
57 ----
58
59 Then I use a case statement to separate out all the different checks I
60 want to do:
61
62 ----
63 # Nest a set of mutually exclusive cases ...
64 case
65 # Nagios messages
66 when (message.from.email =~ /nagios at MYDOMAIN/ \
67 and recips =~ /MYDOMAIN/) :
68 tagit(message,"auto nagios -inbox")
69 # Logwatch messages
70 when (message.from.email =~ /^logwatch@/ \
71 and message.subj =~ /^Logwatch for/) :
72 tagit(message,"auto logwatch -inbox")
73 # Legato messages
74 when message.from.email =~ /^legato@/ :
75 tagit(message,"auto legato -inbox")
76 ----
77
78 Those three cases check the sender, adding the tags "auto" and
79 "nagios"/"logwatch"/"legato" as appropriate, and remove the inbox tag,
80 so I don't see them in my default view.
81
82 I'm using a function "tagit" to do this, it's just a helper function
83 to make the rules read a little easier. It's defined at the beginning
84 of my before-add.rb :-
85
86 ----
87 def tagit(message,labels)
88 actions=[]
89 labels.split(' ').each {|l|
90 # Check the first character of each label.
91 # If it starts with -, remove the label
92 # otherwise add it.
93 minus=l.match('^-(.*)$')
94 if minus
95 message.remove_label minus[1]
96 actions << "Del #{minus[1]}"
97 else
98 message.add_label l
99 actions << "Add #{l}"
100 end
101 }
102 log "Tagit: #{labels} -> #{message.id} : #{actions.join(',')}"
103 end
104 ----
105
106 Here are a few more tests that I do :-
107
108 ----
109 # EDUCAUSE Security
110 when message.raw_header =~ /^List-Owner:
111 <mailto:SECURITY-request at LISTSERV.EDUCAUSE.EDU>$/ :
112 tagit(message,"list educause -inbox")
113 # rss2email blog messages
114 when message.raw_header =~ /X-rss2email/ :
115 tagit(message,"blog -inbox")
116 log " blog from #{message.from.inspect}"
117 log " blog name #{message.from.name}"
118 case message.from.name
119 when /Shipping Container House/
120 tagit(message,"blog.marek")
121 when /cortesi/
122 tagit(message,"blog.cortesi")
123 when /RISKS/
124 tagit(message,"blog.risks")
125 when /WTF/
126 tagit(message,"blog.wtf")
127 when /Schneier on Security/
128 tagit(message,"blog.schneier")
129 when /Krebs/
130 tagit(message,"blog.krebs")
131 end
132 ----
133
134 So in general I'm looking at these fields :-
135 * sender address (message.from.email)
136 * sender name (message.from.name)
137 * recipient (handy when it's to a list address, using a copy of
138 message.recipients.each)
139 * subject (message.subj)
140 * unusual headers (message.raw_header)
141
142 and using decisions based on those to change the tags, using
143 message.add_label and message.remove_label -- but I'm doing those via
144 my helper function tagit()
145
146 Hope that helps :-)
147
148 -jim
149
150 From atann@alphasrv.net Fri Nov 23 11:16:36 2012
151 From: atann@alphasrv.net (Andre Tann)
152 Date: Fri, 23 Nov 2012 12:16:36 +0100
153 Subject: [sup-talk] Hooks - some examples appreciated
154 In-Reply-To: <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
155 References: <201211221554.08990@inter.netz>
156 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
157 Message-ID: <201211231216.36779@inter.netz>
158
159 Hi Jim,
160
161 Jim Cheetham, Donnerstag, 22. November 2012:
162
163 > Sadly the wiki has been almost completely spammed out of existance; it
164 > doesn't store a long-enough revision history to get reverted correctly
165 > any more.
166
167 ?and even more sadly, the sup-project is not so really alive at the
168 moment. As I found it has difficulties displaying utf8 messages. That's
169 really annoying?
170
171
172 > First, extract the useful fields -- because a message can have
173 > multiple recipients and I want to check any/all of them (To, Cc, Bcc).
174 > Doing this means I don't have to check the array of recpipents every
175 > time, I can just use string matching on a long flat list of
176 > recipients.
177 [?lots of code?]
178 > Hope that helps :-)
179
180 Yes, this helps very much, and I'll have to translate this into my
181 situation.
182
183
184 Another thing - I found nothing about dealing with different
185 personalities. On the website I read
186
187 Handle multiple accounts. Replying to email sent to a particular
188 account will use the correct SMTP server, signature, and from address.
189
190 But I see nothing about how this can be done. What is an account? How
191 do account and sender address, signature? stick together? How can I
192 choose the personality with which I reply in case sup guesses wrong?
193
194 Is there a site out there where I can read about this?
195
196
197 Thanks for your help!
198
199 --
200 Andre Tann
201
202
203 From ruthard.baudach@web.de Fri Nov 23 15:14:09 2012
204 From: ruthard.baudach@web.de (Ruthard Baudach)
205 Date: Fri, 23 Nov 2012 16:14:09 +0100
206 Subject: [sup-talk] Hooks - some examples appreciated
207 In-Reply-To: <201211231216.36779@inter.netz>
208 References: <201211221554.08990@inter.netz>
209 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
210 <201211231216.36779@inter.netz>
211 Message-ID: <1353683327-sup-1399@prxbdc.dyndns.org>
212
213 >== Ausz?ge aus der Nachricht von Andre Tann vom 2012-11-23 12:16:
214 > Hi Jim,
215 >
216 > Jim Cheetham, Donnerstag, 22. November 2012:
217 >
218 > > Sadly the wiki has been almost completely spammed out of existance; it
219 > > doesn't store a long-enough revision history to get reverted correctly
220 > > any more.
221 >
222 > ?and even more sadly, the sup-project is not so really alive at the
223 > moment. As I found it has difficulties displaying utf8 messages. That's
224 > really annoying?
225 That's not a problem of sup, but of the curses library. you must install
226 a ruby-nwcurses library instead of ncurses tu support utf-8.
227 Alas I forgot how to do this. There used to be three or four places on
228 the web describing this problem, I hope they can still be found.
229
230 Greetings,
231
232 Ruthard
233
234 From sdothum@gmail.com Fri Nov 23 18:49:52 2012
235 From: sdothum@gmail.com (Steven Hum)
236 Date: Fri, 23 Nov 2012 13:49:52 -0500
237 Subject: [sup-talk] Hooks - some examples appreciated
238 In-Reply-To: <1353683327-sup-1399@prxbdc.dyndns.org>
239 References: <201211221554.08990@inter.netz>
240 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
241 <201211231216.36779@inter.netz>
242 <1353683327-sup-1399@prxbdc.dyndns.org>
243 Message-ID: <1353696475-sup-5507@luna>
244
245 Does the ncursesw gem not address this which is loaded in place of the
246 standard ncurses library if available?
247
248 Steven
249
250 Excerpts from Ruthard Baudach's message of 2012-11-23 10:14:09 -0500:
251 > >== Ausz?ge aus der Nachricht von Andre Tann vom 2012-11-23 12:16:
252 > > Hi Jim,
253 > >
254 > > Jim Cheetham, Donnerstag, 22. November 2012:
255 > >
256 > > > Sadly the wiki has been almost completely spammed out of existance; it
257 > > > doesn't store a long-enough revision history to get reverted correctly
258 > > > any more.
259 > >
260 > > ?and even more sadly, the sup-project is not so really alive at the
261 > > moment. As I found it has difficulties displaying utf8 messages. That's
262 > > really annoying?
263 > That's not a problem of sup, but of the curses library. you must install
264 > a ruby-nwcurses library instead of ncurses tu support utf-8.
265 > Alas I forgot how to do this. There used to be three or four places on
266 > the web describing this problem, I hope they can still be found.
267 >
268 > Greetings,
269 >
270 > Ruthard
271 --
272 "Truth or die."
273
274 Steven Hum
275 5 - 28 Gilmour St
276 Ottawa, ON K2P 0N3
277 email sdothum at gmail.com
278 tel 613.237.9058
279
280 From atann@alphasrv.net Fri Nov 23 20:20:18 2012
281 From: atann@alphasrv.net (Andre Tann)
282 Date: Fri, 23 Nov 2012 21:20:18 +0100
283 Subject: [sup-talk] Hooks - some examples appreciated
284 In-Reply-To: <1353683327-sup-1399@prxbdc.dyndns.org>
285 References: <201211221554.08990@inter.netz> <201211231216.36779@inter.netz>
286 <1353683327-sup-1399@prxbdc.dyndns.org>
287 Message-ID: <201211232120.19098@inter.netz>
288
289 Ruthard Baudach, Freitag, 23. November 2012:
290
291 > That's not a problem of sup, but of the curses library. you must install
292 > a ruby-nwcurses library instead of ncurses tu support utf-8.
293 > Alas I forgot how to do this. There used to be three or four places on
294 > the web describing this problem, I hope they can still be found.
295
296 As we see here
297
298 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477366#52
299
300 it is not the cure just to install this library.
301
302 Googling around for a while now it seems that there is no way to make
303 sup work fine with utf8.
304
305 It's *really* a pity that this is a dead project (and I have no clue
306 about ruby).
307
308 --
309 Andre Tann
310
311
312 From atann@alphasrv.net Sat Nov 24 20:42:25 2012
313 From: atann@alphasrv.net (Andre Tann)
314 Date: Sat, 24 Nov 2012 21:42:25 +0100
315 Subject: [sup-talk] Hooks - some examples appreciated
316 In-Reply-To: <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
317 References: <201211221554.08990@inter.netz>
318 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
319 Message-ID: <201211242142.25559@inter.netz>
320
321 Hi Jim,
322
323 thanks again for your code-snippets. To feed google and for the files:
324 Here is a complete example how to label incoming mail:
325
326 ===snip
327 $ cat ~/.sup/hooks/before-add-message.rb
328
329 def tagit(message,labels)
330 actions=[]
331 labels.split(' ').each {|l|
332 # Check the first character of each label.
333 # If it starts with -, remove the label
334 # otherwise add it.
335 minus=l.match('^-(.*)$')
336 if minus
337 message.remove_label minus[1]
338 actions << "Del #{minus[1]}"
339 else
340 message.add_label l
341 actions << "Add #{l}"
342 end
343 }
344 log "Tagit: #{labels} -> #{message.id} : #{actions.join(',')}"
345 end
346
347
348 # Build up an array of recipients for this message
349 recipients=[]
350 message.recipients.each {|rp| recipients << rp.email }
351 recips = recipients.join(' ')
352
353 # Nest a set of mutually exclusive cases ?
354 case
355 # Label test messages
356 when (message.subj =~ /test/ ) :
357 tagit(message,"Testlabel")
358
359 end
360 ===snip
361
362
363 Still, I have no idea on how to deal with accounts. But that goes into
364 another thread ;)
365
366 Greetings,
367
368 --
369 Andre Tann
370
371
372 From jim@gonzul.net Sun Nov 25 21:09:57 2012
373 From: jim@gonzul.net (Jim Cheetham)
374 Date: Mon, 26 Nov 2012 10:09:57 +1300
375 Subject: [sup-talk] Hooks - some examples appreciated
376 In-Reply-To: <201211231216.36779@inter.netz>
377 References: <201211221554.08990@inter.netz>
378 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
379 <201211231216.36779@inter.netz>
380 Message-ID: <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
381
382 Glad that helped. It was a bit of a code-dump because I'm not using
383 sup any more.
384
385 The abandon-ness of sup is sad; it was probably the best mail client
386 I've used (except for mh, about 20 years ago). Unfortunately as my
387 underlying OS libraries changed, sup didn't keep up with API changes,
388 and now it can't handle GPG. For a while I was running a chroot Ubuntu
389 11.04 just for sup, but I stopped doing that a while ago. As others
390 have mentioned, nwcurses is the solution to utf8 but applying it isn't
391 straightforward. And I didn't ever try multiple personalities (as I
392 keep my personalities in separate areas/servers and try hard not to
393 mix them in the same UI; too much chance of data leakage otherwise and
394 that's not a good thing in my line of work)
395
396 I'm currently trying to keep heliotrope/turnsole running, but it seems
397 to be only halfway useable; the basics work but the more advanced
398 things are not present. I'm not a developer and can't wade in to @wm's
399 code to help there. It does keep my daily mailbox running though.
400
401 I'd go back to mh again, possibly combined with some tmux invocations
402 to keep the asynchronous nature, except I've grown to like the use of
403 a tagging interface rather than the traditional Maildir/IMAP folder
404 system. However, notmuchfs is a tempting general-purpose solution to
405 that.
406
407
408 -jim
409
410 From matthieu.rakotojaona@gmail.com Tue Nov 27 12:54:46 2012
411 From: matthieu.rakotojaona@gmail.com (Matthieu Rakotojaona)
412 Date: Tue, 27 Nov 2012 13:54:46 +0100
413 Subject: [sup-talk] Hooks - some examples appreciated
414 In-Reply-To: <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
415 References: <201211221554.08990@inter.netz>
416 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
417 <201211231216.36779@inter.netz>
418 <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
419 Message-ID: <CAMiZLn25NOtA1evXysuObdHUi_j3WVRueB2GFWkPn4=ibZk_xw@mail.gmail.com>
420
421 On Sun, Nov 25, 2012 at 10:09 PM, Jim Cheetham <jim at gonzul.net> wrote:
422
423 > I'm currently trying to keep heliotrope/turnsole running, but it seems
424 > to be only halfway useable; the basics work but the more advanced
425 > things are not present. I'm not a developer and can't wade in to @wm's
426 > code to help there. It does keep my daily mailbox running though.
427 >
428
429 What about tackling heliotrope, then ? I already did some heavy changes to
430 make it work the way I wanted, but unfortunately I'm a bit alone here. I
431 got basic functionalities working too, and, most importantly, I have added
432 an IMAP endpoint for OfflineIMAP to synchronize heliotrope with some
433 external maildir/IMAP system, albeit not totally complete yet.
434
435 Heliotrope is in a quite usable state for me now, but there are some
436 functionalities in turnsole I'd like to work on. On the other hand, notmuch
437 has more development going on, so it seems to be a reasonable way to go if
438 you don't have time to spend on fiddling with the code.
439
440 --
441 Matthieu RAKOTOJAONA
442 -------------- next part --------------
443 An HTML attachment was scrubbed...
444 URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20121127/e5933842/attachment-0001.html>
445
446 From ruthard.baudach@web.de Tue Nov 27 15:13:07 2012
447 From: ruthard.baudach@web.de (Ruthard Baudach)
448 Date: Tue, 27 Nov 2012 16:13:07 +0100
449 Subject: [sup-talk] Hooks - some examples appreciated
450 In-Reply-To: <CAMiZLn25NOtA1evXysuObdHUi_j3WVRueB2GFWkPn4=ibZk_xw@mail.gmail.com>
451 References: <201211221554.08990@inter.netz>
452 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
453 <201211231216.36779@inter.netz>
454 <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
455 <CAMiZLn25NOtA1evXysuObdHUi_j3WVRueB2GFWkPn4=ibZk_xw@mail.gmail.com>
456 Message-ID: <1354029005-sup-779@prxbdc.dyndns.org>
457
458
459 I never got heliotrope/turnsole running for me, but it would be great,
460 if this family of projects (sup and heliotrope/turnsole) could be
461 better maintained/developed.
462
463 A first important point would be a central source of information like
464 the sup-wiki, but with spam-protection.
465
466 Yours,
467
468 Ruthard Baudach
469 >== Ausz?ge aus der Nachricht von Matthieu Rakotojaona vom 2012-11-27 13:54:
470 > On Sun, Nov 25, 2012 at 10:09 PM, Jim Cheetham <jim at gonzul.net> wrote:
471 >
472 > > I'm currently trying to keep heliotrope/turnsole running, but it seems
473 > > to be only halfway useable; the basics work but the more advanced
474 > > things are not present. I'm not a developer and can't wade in to @wm's
475 > > code to help there. It does keep my daily mailbox running though.
476 > >
477 >
478 > What about tackling heliotrope, then ? I already did some heavy changes to
479 > make it work the way I wanted, but unfortunately I'm a bit alone here. I
480 > got basic functionalities working too, and, most importantly, I have added
481 > an IMAP endpoint for OfflineIMAP to synchronize heliotrope with some
482 > external maildir/IMAP system, albeit not totally complete yet.
483 >
484 > Heliotrope is in a quite usable state for me now, but there are some
485 > functionalities in turnsole I'd like to work on. On the other hand, notmuch
486 > has more development going on, so it seems to be a reasonable way to go if
487 > you don't have time to spend on fiddling with the code.
488 >
489
490 From matthieu.rakotojaona@gmail.com Tue Nov 27 17:48:56 2012
491 From: matthieu.rakotojaona@gmail.com (Matthieu Rakotojaona)
492 Date: Tue, 27 Nov 2012 18:48:56 +0100
493 Subject: [sup-talk] Hooks - some examples appreciated
494 In-Reply-To: <1354029005-sup-779@prxbdc.dyndns.org>
495 References: <201211221554.08990@inter.netz>
496 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
497 <201211231216.36779@inter.netz>
498 <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
499 <CAMiZLn25NOtA1evXysuObdHUi_j3WVRueB2GFWkPn4=ibZk_xw@mail.gmail.com>
500 <1354029005-sup-779@prxbdc.dyndns.org>
501 Message-ID: <CAMiZLn19MB=DMY_e7NMqMapzStLuq7vUV-jxy1J7iAiTLwAN3w@mail.gmail.com>
502
503 On Tue, Nov 27, 2012 at 4:13 PM, Ruthard Baudach <ruthard.baudach at web.de>wrote:
504
505 > A first important point would be a central source of information like
506 > the sup-wiki, but with spam-protection.
507 >
508
509 I started a brief API overview on my github branch :
510 https://github.com/rakoo/heliotrope/wiki
511
512 You need to have a github account to edit it, so I guess we can say it's
513 relatively well spam-free. Plus, it's all Markdown in git, so it's easily
514 exportable.
515 --
516 Matthieu RAKOTOJAONA
517 -------------- next part --------------
518 An HTML attachment was scrubbed...
519 URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20121127/38ba3410/attachment.html>
520
521 From ruthard.baudach@web.de Fri Nov 30 08:49:34 2012
522 From: ruthard.baudach@web.de (Ruthard Baudach)
523 Date: Fri, 30 Nov 2012 09:49:34 +0100
524 Subject: [sup-talk] Hooks - some examples appreciated
525 In-Reply-To: <CAMiZLn19MB=DMY_e7NMqMapzStLuq7vUV-jxy1J7iAiTLwAN3w@mail.gmail.com>
526 References: <201211221554.08990@inter.netz>
527 <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
528 <201211231216.36779@inter.netz>
529 <CA+2knqsvExn2c679Qg98waoqckROH_S4HbR0Og+ws6GKDmJhHw@mail.gmail.com>
530 <CAMiZLn25NOtA1evXysuObdHUi_j3WVRueB2GFWkPn4=ibZk_xw@mail.gmail.com>
531 <1354029005-sup-779@prxbdc.dyndns.org>
532 <CAMiZLn19MB=DMY_e7NMqMapzStLuq7vUV-jxy1J7iAiTLwAN3w@mail.gmail.com>
533 Message-ID: <1354264971-sup-7791@prxbdc.dyndns.org>
534
535 >== Ausz?ge aus der Nachricht von Matthieu Rakotojaona vom 2012-11-27 18:48:
536 > On Tue, Nov 27, 2012 at 4:13 PM, Ruthard Baudach <ruthard.baudach at web.de>wrote:
537 >
538 > > A first important point would be a central source of information like
539 > > the sup-wiki, but with spam-protection.
540 > >
541 >
542 > I started a brief API overview on my github branch :
543 > https://github.com/rakoo/heliotrope/wiki
544 Good work, -- but necessary for developers, not for users.
545
546 This is the main problem with heliotrope/turnsole -- it's yet not
547 suitable for (advanced) users. I know enough ruby to adapt hook scripts
548 for my needs, but do not have time to learn ruby by heart, or to
549 participate in the development of heliotrope/turnsole. I tried to
550 install it two or three times, but didn't manage to.
551
552 Regards
553
554 Ruthard
555