All pastes #1411954 Raw Edit

florian

public text v1 · immutable
#1411954 ·published 2009-05-04 09:31 UTC
rendered paste body
#!/bin/bash# If aviable source the settings file, if not quit with an arror.if [ -f ~/.awaysms ]; then	. ~/.awaysms 	echo "`date +%H:%M:%S` [query.sh]: settings loaded" >> "$debug"else	echo "FATAL ERROR: settings not found. Please report that to The-Compiler."	exit 1fiecho "===== LOG OPENED AT `date +%H:%M:%S` ====" >> "$debug"server="$1"host="$2"text="$3"# Some debug output...echo "`date +%H:%M:%S` [query.sh]: server: $server || host: $host || text: $text" >> $debug# Exit if the away2web file doesn't existif [ ! -e "$awayfile" ]; then	echo "`date +%H:%M:%S` [query.sh]: awayfile $awayfile doesn't exist. Aborting." >> "$debug"	exit 2else	echo "`date +%H:%M:%S` [query.sh]: awayfile $awayfile exists." >> "$debug"fi	# If we aren't away exitecho "`date +%H:%M:%S` [query.sh]: checking away status" >> "$debug"awaystatus=$(head -n 1 "$awayfile")if [ "$awaystatus" -eq 1 ]; then	echo "`date +%H:%M:%S` [query.sh]: awaystatus is $awaystatus - not away. Aborting." >> "$debug"	exit 1else	echo "`date +%H:%M:%S` [query.sh]: awaystatus is $awaystatus - away." >> "$debug"fi# Get the awayreasonecho "`date +%H:%M:%S` [query.sh]: reading away-reason" >> "$debug"awayreason=$(tail -n 1 "$awayfile")echo "`date +%H:%M:%S` [query.sh]: away-reason is: $awayreason" >> "$debug"# get the options for the userecho "`date +%H:%M:%S` [query.sh]: giving control to readoptions.sh now" >> "$debug"readoptions=$("$dir/readoptions.sh" "$host")echo "`date +%H:%M:%S` [query.sh]: gained control back, exit status $? || readoptions: $readoptions" >> "$debug"# split options upecho "`date +%H:%M:%S` [query.sh]: splitting options up now" >> "$debug"options=$(echo $readoptions | cut -d " " -f 1)number=$(echo $readoptions | cut -d " " -f 2)echo "`date +%H:%M:%S` [query.sh]: options: $options || number: $number" >> "$debug"# check if the user is bannedecho "`date +%H:%M:%S` [query.sh]: let's see if the user is banned" >> "$debug"if echo "$readoptions" | grep -q ban; then	echo "`date +%H:%M:%S` [query.sh]: ouch. User $host is banned. Aborting." >> "$debug"	exit 3else	echo "`date +%H:%M:%S` [query.sh]: okay, the user $host isn't banned." >> "$debug"fi# check what the user wants to doecho "`date +%H:%M:%S` [query.sh]: now checking the text: >$text<" >> "$debug"case $text in	\!send*) #send something		;;	\!help*) # help		echo "`date +%H:%M:%S` [query.sh]: The user wanted some help, aye." >> "$debug"		echo "Possible commands:"		echo "!send <message> - send a message to me"		;;	\!*) # unknown command		echo "`date +%H:%M:%S` [query.sh]: The command $text was unknown." >> "$debug"		echo "Unknown command. Try !help"		;;	*) # normal text		echo "`date +%H:%M:%S` [query.sh]: $text seems to be a normal text, giving the user my awaymessage." >> "$debug"		echo "Sorry, but I'm not here at the moment ($awayreason) - use !send <message> to send me a message via SMS."		;;esacecho "`date +%H:%M:%S` [query.sh]: We did what we had to do, exiting." >> "$debug"exit 0