Add comments
This commit is contained in:
parent
70f75f82b5
commit
1f28b4f79e
13
start.sh
13
start.sh
@ -175,22 +175,26 @@ weather() {
|
|||||||
mkdir -p "$BOTDIR/{irc,seen,karma}"
|
mkdir -p "$BOTDIR/{irc,seen,karma}"
|
||||||
cd "$BOTDIR"
|
cd "$BOTDIR"
|
||||||
|
|
||||||
|
# Connect ii and join channel. Afterwards $IRCIN and $IRCOUT are
|
||||||
|
# available
|
||||||
|
|
||||||
echo "connecting."
|
echo "connecting."
|
||||||
ii -i $BOTDIR/irc -s $SERVER -p $PORT -n $BOTNICK &
|
ii -i $BOTDIR/irc -s $SERVER -p $PORT -n $BOTNICK &
|
||||||
PID=$!
|
PID=$!
|
||||||
sleep 1
|
sleep 1
|
||||||
echo "/join $CHANNEL" > $BOTDIR/irc/$SERVER/in
|
echo "/join $CHANNEL" > $BOTDIR/irc/$SERVER/in
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
echo "ready."
|
echo "ready."
|
||||||
|
|
||||||
|
# Listen on $IRCOUT, parse input and call functions once something
|
||||||
|
# of interest gets posted.
|
||||||
tail -n 0 -f "$IRCOUT" \
|
tail -n 0 -f "$IRCOUT" \
|
||||||
| while read -r line
|
| while read -r line
|
||||||
do
|
do
|
||||||
NICK=$(echo "$line" \
|
NICK=$(echo "$line" \
|
||||||
| sed -n 's/^....-..-.. ..:.. <\([^>]*\).*/\1/p')
|
| sed -n 's/^....-..-.. ..:.. <\([^>]*\).*/\1/p')
|
||||||
|
|
||||||
# prevent loops
|
# prevent loops; so the bot can't trigger itself.
|
||||||
[ "$NICK" == "$BOTNICK" ] \
|
[ "$NICK" == "$BOTNICK" ] \
|
||||||
&& continue
|
&& continue
|
||||||
|
|
||||||
@ -198,10 +202,13 @@ do
|
|||||||
| tr '[:upper:]' '[:lower:]' \
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
| sed -n 's|.*\(![a-z]*\).*|\1|p')
|
| sed -n 's|.*\(![a-z]*\).*|\1|p')
|
||||||
|
|
||||||
|
# intentionally limiting the argument to one and also limit the
|
||||||
|
# character set for safety reasons.
|
||||||
ARG=$(echo "$line" \
|
ARG=$(echo "$line" \
|
||||||
| tr '[:upper:]' '[:lower:]' \
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
| sed -n 's|.*![a-z]* \([a-zA-Z0-9\-_+]*\).*|\1|p')
|
| sed -n 's|.*![a-z]* \([a-zA-Z0-9\-_+]*\).*|\1|p')
|
||||||
|
|
||||||
|
# We call it gummipunkte now.
|
||||||
KARMA=$(echo "$line" \
|
KARMA=$(echo "$line" \
|
||||||
| tr '[:upper:]' '[:lower:]' \
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
| sed -n 's|.* \([a-zA-Z0-9\-_]*[+-][+-]\).*|\1|p')
|
| sed -n 's|.* \([a-zA-Z0-9\-_]*[+-][+-]\).*|\1|p')
|
||||||
@ -209,6 +216,7 @@ 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"
|
||||||
|
|
||||||
|
# we just save the line and replay it on the !seen command
|
||||||
[ ! -z "$NICK" ] \
|
[ ! -z "$NICK" ] \
|
||||||
&& echo "$line" > "$BOTDIR/seen/$NICK"
|
&& echo "$line" > "$BOTDIR/seen/$NICK"
|
||||||
|
|
||||||
@ -221,6 +229,7 @@ do
|
|||||||
"!settopic") settopic; ;;
|
"!settopic") settopic; ;;
|
||||||
"!seen") seen $ARG; ;;
|
"!seen") seen $ARG; ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$KARMA" in
|
case "$KARMA" in
|
||||||
*[+-][+-]) karma $KARMA; ;;
|
*[+-][+-]) karma $KARMA; ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user