소스 검색

Finish notifirc integration with newer notifirc version via stdin

Alois Mahdal 9 년 전
부모
커밋
f1c07531ad
1개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. 9
    4
      dotfiles/imapfilter/common/functions.lua

+ 9
- 4
dotfiles/imapfilter/common/functions.lua 파일 보기

@@ -11,16 +11,21 @@ function get_queue(mbox)
11 11
     return mbox.FILTER_QUEUE:is_newer(84)
12 12
 end
13 13
 
14
-function _notifirc1(structure)
14
+function _notifirc1(subj, from, body)
15 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 20
 end
18 21
 
19 22
 function notifirc_all(seq)
20 23
     for _, mesg in ipairs(seq) do
21 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 29
     end
25 30
 end
26 31