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