#!/bin/sh
# $Id: example-micq-event-script,v 1.1 2005/02/10 19:16:14 kuhlmann Exp $
# Example script - ~/.micq/event
# Do not use unmodified.

UPDATE=""

MSGUPD="\\
##############################################################################
#                  Automatic upgrade notice:                                 #
#            Get mICQ 0.5 from http://www.micq.org/!                         #
#                                                                            #
# If you aren't interested in mICQ anymore, reply with \"unsubscribe\"         #
# and I won't bother you again.                                              #
##############################################################################
."
MSGSUB="Subscribed $2 to mICQ update notification service."
MSGUNS="Removed $2 from update notification service."
MSGLAT="Latest version of mICQ is: mICQ 0.5."
MSGHELP="\\
### subscribe
###   Subscribe to the mICQ update notification service. If a new version of
###   mICQ is release and you're seen online, you'll receive a message.
### unsubscribe
###   Unsubscribe from the mICQ update notification service. This will also
###   remove you from my contact list.
### check
###   Query the latest released mICQ version.
."
MSGHILF="\\
### subscribe
###   Den mICQ-Aktualisierungs-Hinweisdienst abonnieren. Wenn eine neue
###   Version von mICQ herausgegen wird, bekommt man dann eine Nachricht,
###   sobald man gesehen wird.
### unsubscribe
###   Den mICQ-Aktualisierungs-Hinweisdienst abbestellen. Dies wird einen
###   auch von meiner Kontaktliste entfernen.
### check
###   Die aktuelle Version von mICQ abfragen.
."
MSGHELO="\\
(EN) Welcome to my ICQ answering machine, and probably welcome to mICQ as well.
### Don't ask me who I am - use your own brain to figure it out. Feel free to
### ask question about mICQ, but don't try to abuse me as a man page reader.
### You can subscribe to the mICQ update notification service with \"subscribe\",
### or issue the following commands: help subscribe unsubscribe check.
(DE) Willkommen zu meinem ICQ-Anrufbeantworter, und Willkommen zu mICQ.
### Ich verstehe diese Kommandos: hilfe subscribe unsubscribe check.
."

case "$1-$2-$3-$4-$5-$6-$7-$8" in
   icq-uin-nick-group-action-msgtype-msg-uagent)
     echo "example" ;;
   *-*--*-beep-*-*)
     xkbbell ;;
   *-*-*-*-msg-*-hilfe-*)
     echo "msg notab $2 $MSGHILF" >> $HOME/.micq/scripting
     ;;
   *-*-*-*-msg-*-help-*)
     echo "msg notab $2 $MSGHELP" >> $HOME/.micq/scripting
     ;;
   *-*-*-*-msg-*-unsubscribe-*)
     touch "$HOME/.micq/blacklist/$2"
     rm "$HOME/.micq/subscriber/$2"
     echo "rem $2 m:$2" >> $HOME/.micq/scripting
     echo "rem $2 new:$2" >> $HOME/.micq/scripting
     echo "msg notab $2 $MSGUNS" >> $HOME/.micq/scripting
     ;;
   *-*-*-*-msg-*-subscribe-*)
     rm "$HOME/.micq/blacklist/$2"
     touch "$HOME/.micq/subscriber/$2"
     echo "add $2 m:$2" >> $HOME/.micq/scripting
     echo "rem $2 new:$2" >> $HOME/.micq/scripting
     echo "msg notab $2 $MSGSUB" >> $HOME/.micq/scripting
     ;;
   *-*-*-*-msg-*-check-*)
     if [ -f "$HOME/.micq/subscriber/$2" ]
     then
       echo "msg notab $2 $MSGLAT $MSGSUB" >> $HOME/.micq/scripting
     else
       echo "msg notab $2 $MSGLAT $MSGUNS" >> $HOME/.micq/scripting
     fi
     ;;
   *-*-m:*-*-msg-*-contact?remove?$2*)
     touch "$HOME/.micq/blacklist/$2"
     echo "rem $2" >> $HOME/.micq/scripting
     echo "msg notab $2 Removed from contact list." >> $HOME/.micq/scripting
     ;;
   *-*-$2-*-msg-*)
     echo "add $2 new:$2" >> $HOME/.micq/scripting
     echo "msg notab $2 $MSGHELO" >> $HOME/.micq/scripting
     ;;
   *-*-*-*-on-*-mICQ\ 0.5)
     UPDATE=0.5 ;;
   *-*-m:*-*-on-*-mICQ*)
     UPDATE= ;;
   *-*-m:*-*-on-*-*)
     UPDATE=0.5 ;;
esac

if [ -n "$UPDATE" -a ! -f "$HOME/.micq/update-$UPDATE/$2" -a ! -f "$HOME/.micq/blacklist/$2" ]
then
  touch "$HOME/.micq/update-0.5/$2"
  echo "msg notab $2 $MSGUPD" >> $HOME/.micq/scripting
fi

