#!/bin/bash
# 
# Autor: Julian Forster
# www.ProgMaschine.de.vu
#
#

if [ $# -eq 1 ]; then
    file=/tmp/`basename $0`-$$
    grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file

    echo "digraph G {"
    cat $file | while read line ; do
        isProfil=`echo $line | grep "Profil von:"`
        if [ -n "$isProfil" ] ; then
            name=$(echo $line |  awk '{ print $3 }')
            
        else
            buddy=$(echo $line |  awk '{ print $3 }')
            echo "\"$name\" -> \"$buddy\";"
            
        fi    
    done

    echo "}"

    exit 0
else
    echo ""
    exit 1
fi
