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