Compare commits
No commits in common. "b050adbc02cb16aa857df3ef34c17f3fec259e55" and "3ea8a8817bab214d6bd9619608e68046630c1fa7" have entirely different histories.
b050adbc02
...
3ea8a8817b
77
start.sh
77
start.sh
@ -13,10 +13,6 @@ BOTDIR="$PWD"
|
||||
IRCIN="$BOTDIR/irc/$SERVER/$CHANNEL/in"
|
||||
IRCOUT="$BOTDIR/irc/$SERVER/$CHANNEL/out"
|
||||
|
||||
###
|
||||
### FUNCTIONS ###
|
||||
###
|
||||
|
||||
# $1 message
|
||||
say() {
|
||||
echo "out> $1"
|
||||
@ -98,20 +94,28 @@ savekarma() {
|
||||
|
||||
# $1 nick
|
||||
reportkarma() {
|
||||
n=$1
|
||||
[ -z "$n" ] \
|
||||
&& n=$NICK
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
n=$NICK
|
||||
else
|
||||
n=$1
|
||||
fi
|
||||
if [ ! -f "$BOTDIR/karma/$n" ]
|
||||
then
|
||||
[ "$n" == "$NICK" ] \
|
||||
&& say "Du hast bisher leider noch keine Gummipunkte gesammelt, $n." \
|
||||
|| say "$n hat leider noch keine Gummipunkte gesammelt."
|
||||
if [ "$n" == "$NICK" ]
|
||||
then
|
||||
say "Du hast bisher leider noch keine Gummipunkte gesammelt, $n."
|
||||
else
|
||||
say "$n hat leider noch keine Gummipunkte gesammelt."
|
||||
fi
|
||||
else
|
||||
cur=$(cat "$BOTDIR/karma/$n")
|
||||
[ "$n" == "$NICK" ] \
|
||||
&& say "Du hast momentan $cur Gummipunkt(e), $n." \
|
||||
|| say "$n hat momentan $cur Gummipunkt(e)."
|
||||
if [ "$n" == "$NICK" ]
|
||||
then
|
||||
say "Du hast momentan $cur Gummipunkt(e), $n."
|
||||
else
|
||||
say "$n hat momentan $cur Gummipunkt(e)."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -120,8 +124,11 @@ karma() {
|
||||
n="$(echo "$1" | tr -d "+-")"
|
||||
[ -z "$n" ] && return
|
||||
|
||||
[ "$n" == "$(echo "$NICK" | tr '[:upper:]' '[:lower:]' )" ] \
|
||||
&& say "So aber nicht mein lieber $NICK!" && return
|
||||
if [ "$n" == "$(echo "$NICK" | tr '[:upper:]' '[:lower:]' )" ]
|
||||
then
|
||||
say "So aber nicht mein lieber $NICK!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$1" | fgrep "++" \
|
||||
&& savekarma $n "+1"
|
||||
@ -143,9 +150,12 @@ transparenzbericht() {
|
||||
|
||||
seen() {
|
||||
[ -z "$1" ] && return
|
||||
[ -f "$BOTDIR/seen/$1" ] \
|
||||
&& say "$(cat "$BOTDIR/seen/$1")" \
|
||||
|| say "Hmm, ich habe keine Ahnung wann $1 zum letzten mal online war."
|
||||
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
|
||||
}
|
||||
|
||||
usage() {
|
||||
@ -163,18 +173,15 @@ usage() {
|
||||
|
||||
# $1 loc
|
||||
weather() {
|
||||
l=$1
|
||||
[ -z "$l" ] \
|
||||
&& l=heidelberg
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
l=heidelberg
|
||||
else
|
||||
l=$1
|
||||
fi
|
||||
say "$(curl -s "https://wttr.in/$l?lang=de&format=%l:+%t+%C+%w+%h+Regen")"
|
||||
}
|
||||
|
||||
|
||||
|
||||
###
|
||||
### MAIN PROGRAM ###
|
||||
###
|
||||
|
||||
mkdir -p "$BOTDIR/{irc,seen,karma}"
|
||||
cd "$BOTDIR"
|
||||
|
||||
@ -193,9 +200,11 @@ do
|
||||
NICK=$(echo "$line" \
|
||||
| sed -n 's/^....-..-.. ..:.. <\([^>]*\).*/\1/p')
|
||||
|
||||
# prevent loops
|
||||
[ "$NICK" == "$BOTNICK" ] \
|
||||
&& continue
|
||||
if [ "$NICK" == "$BOTNICK" ]
|
||||
then
|
||||
# prevent loops
|
||||
continue
|
||||
fi
|
||||
|
||||
COMMAND=$(echo "$line" \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
@ -212,8 +221,10 @@ do
|
||||
echo "in> $line"
|
||||
echo "in> NICK=$NICK, COMMAND=$COMMAND, ARG=$ARG, KARMA=$KARMA"
|
||||
|
||||
[ ! -z "$NICK" ] \
|
||||
&& echo "$line" > "$BOTDIR/seen/$NICK"
|
||||
if [ ! -z "$NICK" ]
|
||||
then
|
||||
echo "$line" > "$BOTDIR/seen/$NICK"
|
||||
fi
|
||||
|
||||
case "$COMMAND" in
|
||||
"!kalender") kalender $ARG; ;;
|
||||
|
Loading…
Reference in New Issue
Block a user