blob: 804b4037710f4b69750a178494e7f007470f9271 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#! /bin/bash
source ./bot_settings.sh
source ./lib/send.sh
source ./transport/transport_plus_ipc.sh.inc
if ! which inotifywait &> /dev/null
then
echo '[LABS]: inotify is a dep. fail'
exit
fi
if [[ -d "${IPC_NOTICE_CHANNEL}" ]]
then
echo '[LABS]: no such file set in IPC_NOTICE_CHANNEL: '${IPC_NOTICE_CHANNEL}'. fail'
exit
fi
if [[ -d "${BOT_MAIL_DIR}" ]]
then
echo '[LABS]: no such directory set in BOT_MAIL_DIR: '${BOT_MAIL_DIR}'. fail'
exit
fi
if [[ -d "${IPC_STORE_FILE}" ]]
then
echo '[LABS]: no such file set in IPC_STORE_FILE: '${IPC_STORE_FILE}'. fail'
exit
fi
shopt -s extglob
next_line_is_url=0
inotifywait -m --format '%w%f' -e create "${BOT_MAIL_DIR}" 2>/dev/null |
while read email
do
while read line
do
case "${line}" in
'Subject: ['* )
lp1="${line#Subject: [}"
lp="${lp1%% - *}"
echo -n "${lp}"
;;
'Issue #'* )
echo -n " - ${line}"
;;
*' #'+([[:digit:]])': '* )
echo -n " (${line#'Bug #'+([[:digit:]])': '})"
next_line_is_url=1
;;
'https://labs.parabola.nu/issues/'* )
(( next_line_is_url )) && echo -n " ${line}"
break
;;
esac
done < "${email}"
echo
done |
while read message
do
send_ipc_msg '0' "${message}"
done
|