blob: 7d442923ccf4f52ddaa3f695d2680f67ed013188 (
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
|
#! /bin/bash
function l33t_codes
{
person="${sender%%!*}"
if [[ ${line} == *"error while loading shared libraries"* ]]
then
send_msg '#parabola' "${person}: please report a bug, specifying exact error message, package of the failing command and architecture"
fi
# If two different people say the same thing in a row then say it again
# for fun.
if [[ ${line} == ${lastline} ]] && [[ ${sender%%!*} != ${lastsender} ]]
then
send_msg '#parabola' "${line}"
fi
lastline="${line}"
lastsender="${sender%%!*}"
# Remove any forward slashes.
personoslash="${person//\/}"
# Make this person a folder if they don't already have one.
if ! [[ -d "announcements/people/${personoslash}" ]]
then
mkdir -p "announcements/people/${personoslash}"
touch "announcements/people/${personoslash}/phrases"
cat << EOF > "announcements/people/${personoslash}/settings"
enabled=yes
locked=no
EOF
fi
the_time_now=$(date +%s)
# If this person has announcements enabled and there is at least one phrase
# in their file and their seen log exists.
if grep 'enabled=yes' "announcements/people/${personoslash}/settings" &> /dev/null && (( $( wc -l "announcements/people/${personoslash}/phrases" | cut -d ' ' -f 1 ) )) && [[ -f announcements/people/${personoslash}/seen ]]
then
# Check if they were last present more than three hours ago.
if (( ( $( stat -c %Y announcements/people/${personoslash}/seen ) +
10800 ) < the_time_now ))
then
send_msg '#parabola' \
"$( shuf "announcements/people/${personoslash}/phrases" | head -1 )"
fi
fi
# Record that the person has been seen, and when.
touch "announcements/people/${personoslash}/seen"
}
|