]> git.madduck.net Git - etc/mailfilter.git/blob - procmail/tickle

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

make tickle processing more robust
[etc/mailfilter.git] / procmail / tickle
1 :0
2 * ORIGINAL_TO ?? ^.+@tickle\.madduck\.net$
3 * ORIGINAL_TO ?? ^\/[^@]+
4 {
5   BIN_DATE=/bin/date
6   DELIVERY_TIME=04:20
7   STAMP
8
9   :0
10   * MATCH ?? ^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
11   { STAMP="$MATCH (`$BIN_DATE -d @$MATCH +%c`)" }
12
13   :0 E
14   * MATCH ?? ^[0-9]+h$
15   * MATCH ?? ^\/[^h]+
16   { DATESTR="$DATE + $MATCH hours" }
17
18   JUST_DATE="`$BIN_DATE -d \"$DATE\" +%x`"
19
20   :0 E
21   * MATCH ?? ^[0-9]+m$
22   * MATCH ?? ^\/[^m]+
23   { DATESTR="$JUST_DATE + $MATCH months $DELIVERY_TIME" }
24
25   :0 E
26   * MATCH ?? ^[0-9]+w$
27   * MATCH ?? ^\/[^w]+
28   { DATESTR="$JUST_DATE + $MATCH weeks $DELIVERY_TIME" }
29
30   :0 E
31   * MATCH ?? ^[0-9]+d?$
32   * MATCH ?? ^\/[^d]+
33   { DATESTR="$JUST_DATE + $MATCH days $DELIVERY_TIME" }
34
35   JUST_DATE
36   DELIVERY_TIME
37
38   :0 E
39   {
40     LOG="tickle:      invalid date string: $MATCH$NL"
41     EXITCODE=69
42     HOST
43   }
44
45   :0
46   * ! STAMP ?? .
47   { STAMP=`$BIN_DATE +'%s (%c)' -d "$DATESTR"` }
48
49   :0
50   * ! STAMP ?? ^[0-9]+ \([A-Za-z ]+ [0-9 :]+\)$
51   {
52     LOG="tickle:      error creating timestamp ($STAMP), using \$now$NL"
53     STAMP="`$BIN_DATE +%s` (ERROR: original stamp '$STAMP' invalid)"
54   }
55
56   :0 E
57   { LOG="tickle:      stamping message $MSGID with $STAMP$NL" }
58
59   :0 fw
60   |$FORMAIL -i "X-Tickle: $STAMP"
61
62   :0
63   $BASE/.tickler/
64
65   BIN_DATE
66 }