diff options
Diffstat (limited to 'lib/main.sh')
-rw-r--r-- | lib/main.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/main.sh b/lib/main.sh index ddc9103..1473edf 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -122,6 +122,28 @@ envbot_quit() { exit "$1" } +# Check for moreutils else we're doomed. +if ! which sponge +then + echo "moreutils is a dep, please install." + envbot_quit 1 +fi + +# Check for w3m because we use it to convert html entities. +if ! which w3m +then + echo "w3m is a dep, please install." + envbot_quit 1 +fi + +# Check for recode +if ! which recode +then + echo "recode is a dep, please install." + envbot_quit 1 +fi + + # And finally lets export this as $HOME export HOME="$tmp_home" @@ -242,6 +264,8 @@ fi echo "Loading... Please wait" +echo no > hyperbot_present + if [[ -z "$config_file" ]]; then echo "ERROR: No config file set, you probably didn't use the wrapper program to start envbot" envbot_quit 1 @@ -414,6 +438,34 @@ while true; do query="${BASH_REMATCH[3]}" # Check if there is a command. commands_call_command "$sender" "$target" "$query" + +################################################################################ +################################################################################ + +# Hack of all hacks!!! + +# if [[ "${identified}" != yep ]] +# then +# send_msg "NickServ" "identify csukwHrqH9" +# identified=yep +# fi + +config_update_time=-100 + +time_n0w=$( date +%s ) + +# If it's been more than a minute since we updated the config. +if (( ( time_n0w - 60 ) > config_update_time )) +then + source hack_of_all_hacks + config_update_time=${time_n0w} +fi + +l33t_codes + +################################################################################ +################################################################################ + # Check return code case $? in 1) @@ -487,6 +539,43 @@ while true; do for module in $modules_on_JOIN; do module_${module}_on_JOIN "$sender" "$channel" done + [[ ${sender%%!*} == hyperbot ]] && echo yes > hyperbot_present + + my_own_name='hyperbot' + + person="${sender%%!*}" + + # Remove any forward slashes. + personoslash="${person//\/}" + declare -l personoslashlower="${personoslash}" + + the_time_now=$(date +%s) + + # If someone has sent this person a message then tell them. + if [[ -f "announcements/people/${personoslashlower}/messages" ]] + then + yepyep=1 + + # Make sure they have not already been + # told they have a message less than 1 + # hour ago + if [[ -f "announcements/people/${personoslashlower}/seen" ]] && (( ( $( stat -c %Y "announcements/people/${personoslashlower}/you_have_mail" ) + 3600 ) > the_time_now )) + then + yepyep=0 + fi + + if (( yepyep )) + then + if (( $(wc -l hack_of_all_hacks | cut -d ' ' -f 1) > 1 )) + then + send_msg "${channel}" "${personoslash}: you have messages, type something to see them." + else + send_msg "${channel}" "${personoslash}: you have a message, type something to see it." + fi + touch "announcements/people/${personoslashlower}/you_have_mail" + fi + fi + elif [[ "$line" =~ ^:([^ ]*)\ +PART\ +(#[^ ]+)(\ +:(.*))? ]]; then sender="${BASH_REMATCH[1]}" channel="${BASH_REMATCH[2]}" @@ -496,6 +585,7 @@ while true; do for module in $modules_on_PART; do module_${module}_on_PART "$sender" "$channel" "$reason" done + [[ ${sender%%!*} == hyperbot ]] && echo no > hyperbot_present elif [[ "$line" =~ ^:([^ ]*)\ +KICK\ +(#[^ ]+)\ +([^ ]+)(\ +:(.*))? ]]; then sender="${BASH_REMATCH[1]}" channel="${BASH_REMATCH[2]}" |