diff options
author | Joseph Graham <joseph@fibreglass.tunachunks> | 2013-08-06 13:08:32 +0100 |
---|---|---|
committer | Joseph Graham <joseph@fibreglass.tunachunks> | 2013-08-06 13:08:32 +0100 |
commit | e695815d7717ad6d8280169e60832cc2d3d45e3a (patch) | |
tree | 0908d58c92b76d74c3dba784d7a4299b063d073b /hack_of_all_hacks | |
parent | 6d4771245c37d1f07cdb53b65dd6a91c4d333ab0 (diff) |
*** empty log message ***
Diffstat (limited to 'hack_of_all_hacks')
-rw-r--r-- | hack_of_all_hacks | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/hack_of_all_hacks b/hack_of_all_hacks index e2f491f..a4d0312 100644 --- a/hack_of_all_hacks +++ b/hack_of_all_hacks @@ -11,6 +11,8 @@ source common_codez function l33t_codes { + my_own_name='pbot' + channel_it_came_from="$( echo ${line} | cut -d ' ' -f 3 )" person="${sender%%!*}" @@ -72,7 +74,7 @@ function l33t_codes # 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 ]] && [[ ${stuff_said} != 'pbot: '* ]] # If two different people say the same thing to me in quick sucession I shouldn't repeat them. + if [[ ${stuff_said} == ${lastline} ]] && [[ ${person} != ${lastsender} ]] && [[ ${say_again} != nono ]] && [[ ${stuff_said} != "${my_own_name}: "* ]] # If two different people say the same thing to me in quick sucession I shouldn't repeat them. then send_msg "${channel_it_came_from}" "${stuff_said}" i_repeated="${stuff_said}" @@ -176,12 +178,15 @@ EOF # This one depends on the previous to record the last time the person # was seen and create the `the_time_now' var. case "${sentence}" in - "pbot: when did you last see"* ) - subject="${sentence##pbot: when did you last see }" - subject="${subject##pbot: when did you last see: }" # If there's an `:', we can still handle it. + "${my_own_name}: when did you last see"* ) + subject="${sentence##${my_own_name}: when did you last see }" + subject="${subject##${my_own_name}: when did you last see: }" # If there's an `:', we can still handle it. subject="${subject%?}" subject="${subject%% *}" - if [[ -f announcements/people/${subject}/seen ]] + if [[ "${subject}" == ${my_own_name} ]] + then + send_msg "${channel_it_came_from}" "I last saw ${subject} speak 0 seconds ago." + elif [[ -f announcements/people/${subject}/seen ]] 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 ))" @@ -211,10 +216,10 @@ EOF send_msg "${channel_it_came_from}" "I never saw ${subject} speak." fi ;; - "pbot: tell "+([![:space:]])": "+([![:space:]])* ) + "${my_own_name}: tell "+([![:space:]])": "+([![:space:]])* ) # The line will be something such as: # pbot: tell fauno: you suck - process="${sentence##pbot: tell }" + process="${sentence##${my_own_name}: tell }" subject="${process%%:*}" message="${process#*:}" message="${message# }" @@ -225,24 +230,24 @@ EOF response=$(shuf -e 'certainly' 'I will do' 'OK' | head -1) send_msg "${channel_it_came_from}" "${personoslash}: ${response}" ;; - "pbot: "+([![:space:]])" is "+([![:space:]])* ) - thing="${sentence#pbot: }" + "${my_own_name}: "+([![:space:]])" is "+([![:space:]])* ) + thing="${sentence#${my_own_name}: }" thing="${thing%% is *}" is="${sentence#* is }" echo "${is}" >> "info/${thing}" send_msg "${channel_it_came_from}" "${personoslash}: Remembered." ;; - "pbot: "+([![:space:]])" is: "+([![:space:]])* ) - thing="${sentence#pbot: }" + "${my_own_name}: "+([![:space:]])" is: "+([![:space:]])* ) + thing="${sentence#${my_own_name}: }" thing="${thing%% is: *}" is="${sentence#* is: }" echo "${is}" >> "info/${thing}" send_msg "${channel_it_came_from}" "${personoslash}: Remembered." ;; - "pbot: "+([![:space:]])" isn't "+([![:space:]])* ) - thing="${sentence#pbot: }" + "${my_own_name}: "+([![:space:]])" isn't "+([![:space:]])* ) + thing="${sentence#${my_own_name}: }" thing="${thing%% isn\'t *}" isnt="${sentence#* isn\'t }" @@ -257,8 +262,8 @@ EOF send_msg "${channel_it_came_from}" "${personoslash}: I know." fi ;; - "pbot: "+([![:space:]])" isn't: "+([![:space:]])* ) - thing="${sentence#pbot: }" + "${my_own_name}: "+([![:space:]])" isn't: "+([![:space:]])* ) + thing="${sentence#${my_own_name}: }" thing="${thing%% isn\'t: *}" isnt="${sentence#* isn\'t: }" @@ -285,16 +290,16 @@ EOF done fi ;; - pbot:* ) + ${my_own_name}:* ) while read line do send_msg "${channel_it_came_from}" "${line}" done <<< cat << EOF Command not recognised. Example commands: -pbot: tell Jack: hi Jack -pbot: when did you last see Jill? -pbot: lemon is yummy -pbot: lemon isn't yummy +${my_own_name}: tell Jack: hi Jack +${my_own_name}: when did you last see Jill? +${my_own_name}: lemon is yummy +${my_own_name}: lemon isn't yummy ,lemon EOF ;; |