summaryrefslogtreecommitdiff
path: root/lib/hack_of_all_hacks
diff options
context:
space:
mode:
authorJoe <joe@joelightning.com>2011-11-10 11:31:23 +0000
committerJoe <joe@joelightning.com>2011-11-10 11:31:23 +0000
commitc40170cb03e41bd1efe775bbd430a50da6cdeea4 (patch)
tree0cc4c0f5cc41c502a0dff8fdca124cab2bd0dab5 /lib/hack_of_all_hacks
First commit, pbot-ng already works.
Diffstat (limited to 'lib/hack_of_all_hacks')
-rw-r--r--lib/hack_of_all_hacks54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/hack_of_all_hacks b/lib/hack_of_all_hacks
new file mode 100644
index 0000000..7d44292
--- /dev/null
+++ b/lib/hack_of_all_hacks
@@ -0,0 +1,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"
+}