summaryrefslogtreecommitdiff
path: root/hack_of_all_hacks
diff options
context:
space:
mode:
authorJoe <joe@joelightning.com>2012-03-23 13:23:58 +0000
committerJoe <joe@joelightning.com>2012-03-23 13:23:58 +0000
commit1a56661e06b238b334e4b70dc58493ea9c8514e4 (patch)
tree65a508b27e23b91155b154b7712a1a616047a7c9 /hack_of_all_hacks
parent489e7e8ca6609f2c72a0f4fc00459ec19a5d9038 (diff)
Injected data should not be treated like it came from a person.
Diffstat (limited to 'hack_of_all_hacks')
-rw-r--r--hack_of_all_hacks291
1 files changed, 146 insertions, 145 deletions
diff --git a/hack_of_all_hacks b/hack_of_all_hacks
index 5a044c9..99d4d7f 100644
--- a/hack_of_all_hacks
+++ b/hack_of_all_hacks
@@ -15,190 +15,191 @@ function l33t_codes
person="${sender%%!*}"
- ##########################
- # Shared libraries error #
- ##########################
+ ######################
+ # Echo injected data #
+ ######################
+
+ # Should send a message like: echo 'This is the message' > /tmp/un-provoked-message-store
+
+ injected_data=0
- the_time_now=$(date +%s)
+ line_half_filtered="${line##*PRIVMSG}"
+ line_filtered=${line_half_filtered##* :}
- # If someone complains about error while loading shared libraries error
- # then recomend them to the bug tracker.
- if [[ ${line} == *"error while loading shared libraries"* ]]
+ if [[ ${personoslash} == tlCJ99mfZl ]]
then
- yepyep=1
+ send_msg "${channel_it_came_from}" "${line_filtered}"
+ injected_data=1
+ else
- # Make sure they have not already been recommended to the bug tracker
- # less than one day ago.
- if [[ -f announcements/people/${personoslash}/seen ]] && (( ( $( stat -c %Y announcements/people/${personoslash}/shared_libs ) + 86400 ) > the_time_now ))
- then
- yepyep=0
- fi
+ ##########################
+ # Shared libraries error #
+ ##########################
- if (( yepyep ))
+ the_time_now=$(date +%s)
+
+ # If someone complains about error while loading shared libraries error
+ # then recomend them to the bug tracker.
+ if [[ ${line} == *"error while loading shared libraries"* ]]
then
- send_msg "${channel_it_came_from}" "${person}: please report a bug, specifying exact error message, package of the failing command and architecture"
- touch "announcements/people/${personoslash}/shared_libs"
+ yepyep=1
+
+ # Make sure they have not already been recommended to the bug
+ # tracker less than one day ago.
+ if [[ -f announcements/people/${personoslash}/seen ]] && (( ( $( stat -c %Y announcements/people/${personoslash}/shared_libs ) + 86400 ) > the_time_now ))
+ then
+ yepyep=0
+ fi
+
+ if (( yepyep ))
+ then
+ send_msg "${channel_it_came_from}" "${person}: please report a bug, specifying exact error message, package of the failing command and architecture"
+ touch "announcements/people/${personoslash}/shared_libs"
+ fi
fi
- fi
- ##########
- # Repeat #
- ##########
+ ##########
+ # Repeat #
+ ##########
- stuff_said="$( echo ${line} | cut --complement -d ' ' -f 1,2,3 )"
- stuff_said="${stuff_said#:}"
+ stuff_said="$( echo ${line} | cut --complement -d ' ' -f 1,2,3 )"
+ stuff_said="${stuff_said#:}"
- [[ ${stuff_said} != ${i_repeated} ]] && say_again=yesyes
+ [[ ${stuff_said} != ${i_repeated} ]] && say_again=yesyes
- # If two different people say the same thing in a row then say it again
- # for fun.
- if [[ ${stuff_said} == ${lastline} ]] && [[ ${person} != ${lastsender} ]] && [[ ${say_again} != nono ]]
- then
- send_msg "${channel_it_came_from}" "${stuff_said}"
- i_repeated="${stuff_said}"
- say_again=nono
- fi
+ # If two different people say the same thing in a row then say it again
+ # for fun.
+ if [[ ${stuff_said} == ${lastline} ]] && [[ ${person} != ${lastsender} ]] && [[ ${say_again} != nono ]]
+ then
+ send_msg "${channel_it_came_from}" "${stuff_said}"
+ i_repeated="${stuff_said}"
+ say_again=nono
+ fi
- lastline="${stuff_said}"
- lastsender="${person}"
+ lastline="${stuff_said}"
+ lastsender="${person}"
- #################
- # Announcements #
- #################
+ #################
+ # Announcements #
+ #################
- # Remove any forward slashes.
- personoslash="${person//\/}"
+ # 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"
+ # 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
+ fi
- the_time_now=$(date +%s)
+ 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 ))
+ # 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
- send_msg "${channel_it_came_from}" \
- "$( shuf "announcements/people/${personoslash}/phrases" | head -1 )"
+ # 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 "${channel_it_came_from}" \
+ "$( shuf "announcements/people/${personoslash}/phrases" | head -1 )"
+ fi
+
fi
- fi
-
- # Record that the person has been seen, and when.
- touch "announcements/people/${personoslash}/seen"
+ # Record that the person has been seen, and when.
+ touch "announcements/people/${personoslash}/seen"
- ########
- # Seen #
- ########
+ ########
+ # Seen #
+ ########
- # This one depends on the previous to record the last time the person was
- # seen and create the `the_time_now' var.
- if [[ ${line} == *"pbot-ng: when did you last see"* ]]
- then
- subject="${line##*pbot-ng: when did you last see }"
- subject="${subject%?}"
- subject="${subject%% *}"
- if [[ -f announcements/people/${subject}/seen ]]
+ # This one depends on the previous to record the last time the person
+ # was seen and create the `the_time_now' var.
+ if [[ ${line} == *"pbot-ng: when did you last see"* ]]
then
- seconds_ago_seen="$(( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ))"
- minutes_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 60 ))"
- hours_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 3600 ))"
- days_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 86400 ))"
- months_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 2592000 ))"
- years_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 946080000 ))"
- if (( seconds_ago_seen < 120 ))
- then
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${seconds_ago_seen} seconds ago."
- elif (( minutes_ago_seen < 120 ))
- then
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${minutes_ago_seen} minutes ago."
- elif (( hours_ago_seen < 48 ))
- then
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${hours_ago_seen} hours ago."
- elif (( days_ago_seen < 60 ))
+ subject="${line##*pbot-ng: when did you last see }"
+ subject="${subject%?}"
+ subject="${subject%% *}"
+ if [[ -f announcements/people/${subject}/seen ]]
then
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${days_ago_seen} days ago."
- elif (( months_ago_seen < 24 ))
- then
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${months_ago_seen} months ago."
+ seconds_ago_seen="$(( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ))"
+ minutes_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 60 ))"
+ hours_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 3600 ))"
+ days_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 86400 ))"
+ months_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 2592000 ))"
+ years_ago_seen="$(( ( the_time_now - $( stat -c %Y announcements/people/${subject}/seen ) ) / 946080000 ))"
+ if (( seconds_ago_seen < 120 ))
+ then
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${seconds_ago_seen} seconds ago."
+ elif (( minutes_ago_seen < 120 ))
+ then
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${minutes_ago_seen} minutes ago."
+ elif (( hours_ago_seen < 48 ))
+ then
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${hours_ago_seen} hours ago."
+ elif (( days_ago_seen < 60 ))
+ then
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${days_ago_seen} days ago."
+ elif (( months_ago_seen < 24 ))
+ then
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${months_ago_seen} months ago."
+ else
+ send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${years_ago_seen} years ago."
+ fi
else
- send_msg "${channel_it_came_from}" "I last saw ${subject} speak ${years_ago_seen} years ago."
+ send_msg "${channel_it_came_from}" "I never saw ${subject} speak."
fi
- else
- send_msg "${channel_it_came_from}" "I never saw ${subject} speak."
fi
- fi
-
- ######################
- # Echo injected data #
- ######################
- # Should send a message like: echo 'This is the message' > /tmp/un-provoked-message-store
+ #####################
+ # Page title getter #
+ #####################
- injected_data=0
+ # If pbot is present record it.
+ [[ ${sender%%!*} == pbot ]] && echo yes > pbot_present
- line_half_filtered="${line##*PRIVMSG}"
- line_filtered=${line_half_filtered##* :}
-
- if [[ ${personoslash} == tlCJ99mfZl ]]
- then
- send_msg "${channel_it_came_from}" "${line_filtered}"
- injected_data=1
- fi
-
- #####################
- # Page title getter #
- #####################
-
- # If pbot is present record it.
- [[ ${sender%%!*} == pbot ]] && echo yes > pbot_present
-
- # We don't want to get the page title if it's injected data.
- if [[ ${line} =~ http://[^\ ]+ ]] || [[ ${line} =~ https://[^\ ]+ ]] &&
- (( ! injected_data ))
- then
- url_to_get="${BASH_REMATCH}"
-
- # If pbot is not present.
- if grep no pbot_present > /dev/null
+ # We don't want to get the page title if it's injected data.
+ if [[ ${line} =~ http://[^\ ]+ ]] || [[ ${line} =~ https://[^\ ]+ ]] &&
+ (( ! injected_data ))
then
- the_title=$(
- curl -L --compressed "${url_to_get}" 2> /dev/null |
- while rdom
- do
- if [[ ${element} = title ]]
- then
- echo "${content}" | replace_wierd_html_chars
- fi
- done
- )
+ url_to_get="${BASH_REMATCH}"
- if ! [[ -z ${the_title} ]]
+ # If pbot is not present.
+ if grep no pbot_present > /dev/null
then
- send_msg "${channel_it_came_from}" "Page title: \`${the_title}'"
+ the_title=$(
+ curl -L --compressed "${url_to_get}" 2> /dev/null |
+ while rdom
+ do
+ if [[ ${element} = title ]]
+ then
+ echo "${content}" | replace_wierd_html_chars
+ fi
+ done
+ )
+
+ if ! [[ -z ${the_title} ]]
+ then
+ send_msg "${channel_it_came_from}" "Page title: \`${the_title}'"
+ fi
fi
fi
- fi
- # TODO: add a birthday announcement feature, cointoss feature, timer
- # feature.
+ # TODO: add a birthday announcement feature, cointoss feature, timer
+ # feature.
- #########
- # Tests #
- #########
+ #########
+ # Tests #
+ #########
- #echo "${line}"
+ #echo "${line}"
+ fi
}