short form 'if' is less cluttered and better readable, often.
This commit is contained in:
parent
3ea8a8817b
commit
321dc3654b
61
start.sh
61
start.sh
@ -94,28 +94,20 @@ savekarma() {
|
||||
|
||||
# $1 nick
|
||||
reportkarma() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
n=$NICK
|
||||
else
|
||||
n=$1
|
||||
fi
|
||||
[ -z "$n" ] \
|
||||
&& n=$NICK
|
||||
|
||||
if [ ! -f "$BOTDIR/karma/$n" ]
|
||||
then
|
||||
if [ "$n" == "$NICK" ]
|
||||
then
|
||||
say "Du hast bisher leider noch keine Gummipunkte gesammelt, $n."
|
||||
else
|
||||
say "$n hat leider noch keine Gummipunkte gesammelt."
|
||||
fi
|
||||
[ "$n" == "$NICK" ] \
|
||||
&& say "Du hast bisher leider noch keine Gummipunkte gesammelt, $n." \
|
||||
|| say "$n hat leider noch keine Gummipunkte gesammelt."
|
||||
else
|
||||
cur=$(cat "$BOTDIR/karma/$n")
|
||||
if [ "$n" == "$NICK" ]
|
||||
then
|
||||
say "Du hast momentan $cur Gummipunkt(e), $n."
|
||||
else
|
||||
say "$n hat momentan $cur Gummipunkt(e)."
|
||||
fi
|
||||
[ "$n" == "$NICK" ] \
|
||||
&& say "Du hast momentan $cur Gummipunkt(e), $n." \
|
||||
|| say "$n hat momentan $cur Gummipunkt(e)."
|
||||
fi
|
||||
}
|
||||
|
||||
@ -124,11 +116,8 @@ karma() {
|
||||
n="$(echo "$1" | tr -d "+-")"
|
||||
[ -z "$n" ] && return
|
||||
|
||||
if [ "$n" == "$(echo "$NICK" | tr '[:upper:]' '[:lower:]' )" ]
|
||||
then
|
||||
say "So aber nicht mein lieber $NICK!"
|
||||
return
|
||||
fi
|
||||
[ "$n" == "$(echo "$NICK" | tr '[:upper:]' '[:lower:]' )" ] \
|
||||
&& say "So aber nicht mein lieber $NICK!" && return
|
||||
|
||||
echo "$1" | fgrep "++" \
|
||||
&& savekarma $n "+1"
|
||||
@ -150,12 +139,9 @@ transparenzbericht() {
|
||||
|
||||
seen() {
|
||||
[ -z "$1" ] && return
|
||||
if [ -f "$BOTDIR/seen/$1" ]
|
||||
then
|
||||
say "$(cat "$BOTDIR/seen/$1")"
|
||||
else
|
||||
say "Hmm, ich habe keine Ahnung wann $1 zum letzten mal online war."
|
||||
fi
|
||||
[ -f "$BOTDIR/seen/$1" ] \
|
||||
&& say "$(cat "$BOTDIR/seen/$1")" \
|
||||
|| say "Hmm, ich habe keine Ahnung wann $1 zum letzten mal online war."
|
||||
}
|
||||
|
||||
usage() {
|
||||
@ -173,12 +159,9 @@ usage() {
|
||||
|
||||
# $1 loc
|
||||
weather() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
l=heidelberg
|
||||
else
|
||||
l=$1
|
||||
fi
|
||||
[ -z "$l" ] \
|
||||
&& l=heidelberg
|
||||
say "$(curl -s "https://wttr.in/$l?lang=de&format=%l:+%t+%C+%w+%h+Regen")"
|
||||
}
|
||||
|
||||
@ -200,11 +183,9 @@ do
|
||||
NICK=$(echo "$line" \
|
||||
| sed -n 's/^....-..-.. ..:.. <\([^>]*\).*/\1/p')
|
||||
|
||||
if [ "$NICK" == "$BOTNICK" ]
|
||||
then
|
||||
# prevent loops
|
||||
continue
|
||||
fi
|
||||
[ "$NICK" == "$BOTNICK" ] \
|
||||
&& continue
|
||||
|
||||
COMMAND=$(echo "$line" \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
@ -221,10 +202,8 @@ do
|
||||
echo "in> $line"
|
||||
echo "in> NICK=$NICK, COMMAND=$COMMAND, ARG=$ARG, KARMA=$KARMA"
|
||||
|
||||
if [ ! -z "$NICK" ]
|
||||
then
|
||||
echo "$line" > "$BOTDIR/seen/$NICK"
|
||||
fi
|
||||
[ ! -z "$NICK" ] \
|
||||
&& echo "$line" > "$BOTDIR/seen/$NICK"
|
||||
|
||||
case "$COMMAND" in
|
||||
"!kalender") kalender $ARG; ;;
|
||||
|
Loading…
Reference in New Issue
Block a user