Procházet zdrojové kódy

Finish notifirc integration with newer notifirc version via stdin

Alois Mahdal před 9 roky
rodič
revize
f1c07531ad
1 změnil soubory, kde provedl 9 přidání a 4 odebrání
  1. 9
    4
      dotfiles/imapfilter/common/functions.lua

+ 9
- 4
dotfiles/imapfilter/common/functions.lua Zobrazit soubor

11
     return mbox.FILTER_QUEUE:is_newer(84)
11
     return mbox.FILTER_QUEUE:is_newer(84)
12
 end
12
 end
13
 
13
 
14
-function _notifirc1(structure)
14
+function _notifirc1(subj, from, body)
15
     --notify about message using (pre-configured) notifirc
15
     --notify about message using (pre-configured) notifirc
16
-    os.execute('notifirc "A funny message arrived!"; notifirc "too bad we are SO WEAK"')
16
+    local fd = assert(io.popen('notifirc -f - "message preview:"', "w"))
17
+    local fmt = "> Subject: %s\n> From: %s\n> Body: %s"
18
+    fd:write(fmt:format(subj, from, body))
19
+    fd:close()
17
 end
20
 end
18
 
21
 
19
 function notifirc_all(seq)
22
 function notifirc_all(seq)
20
     for _, mesg in ipairs(seq) do
23
     for _, mesg in ipairs(seq) do
21
         mbox, uid = table.unpack(mesg)
24
         mbox, uid = table.unpack(mesg)
22
-        structure = mbox[uid]:fetch_structure()
23
-        _notifirc1(structure)
25
+        subj = mbox[uid]:fetch_field('Subject')
26
+        from = mbox[uid]:fetch_field('From')
27
+        body = mbox[uid]:fetch_body()
28
+        _notifirc1(subj, from, body)
24
     end
29
     end
25
 end
30
 end
26
 
31