Compare commits
2 Commits
3ea8a8817b
...
b050adbc02
Author | SHA1 | Date | |
---|---|---|---|
|
b050adbc02 | ||
|
321dc3654b |
71
start.sh
71
start.sh
@ -13,6 +13,10 @@ BOTDIR="$PWD"
|
|||||||
IRCIN="$BOTDIR/irc/$SERVER/$CHANNEL/in"
|
IRCIN="$BOTDIR/irc/$SERVER/$CHANNEL/in"
|
||||||
IRCOUT="$BOTDIR/irc/$SERVER/$CHANNEL/out"
|
IRCOUT="$BOTDIR/irc/$SERVER/$CHANNEL/out"
|
||||||
|
|
||||||
|
###
|
||||||
|
### FUNCTIONS ###
|
||||||
|
###
|
||||||
|
|
||||||
# $1 message
|
# $1 message
|
||||||
say() {
|
say() {
|
||||||
echo "out> $1"
|
echo "out> $1"
|
||||||
@ -94,28 +98,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 +120,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 +143,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,15 +163,18 @@ 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")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### MAIN PROGRAM ###
|
||||||
|
###
|
||||||
|
|
||||||
mkdir -p "$BOTDIR/{irc,seen,karma}"
|
mkdir -p "$BOTDIR/{irc,seen,karma}"
|
||||||
cd "$BOTDIR"
|
cd "$BOTDIR"
|
||||||
|
|
||||||
@ -200,11 +193,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 +212,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