Add scripts and such
This commit is contained in:
parent
1f68248e67
commit
9070b29b7b
3 changed files with 53 additions and 0 deletions
|
@ -3,3 +3,8 @@ IRC Bot
|
||||||
|
|
||||||
This is a super simple IRC bot that can send out notices by talking to it via
|
This is a super simple IRC bot that can send out notices by talking to it via
|
||||||
netcat.
|
netcat.
|
||||||
|
|
||||||
|
## Running
|
||||||
|
Modify the parameters in the shell scripts and you're good to go.
|
||||||
|
|
||||||
|
[irc-say](irc-say) is a convenient program that you can use in other scripts.
|
||||||
|
|
37
irc-bot
Executable file
37
irc-bot
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Super simple IRC bot.
|
||||||
|
#
|
||||||
|
# Note: Requires the OpenBSD version of netcat!
|
||||||
|
|
||||||
|
NICK="bitlair-space"
|
||||||
|
CHANNEL="#bitlair-test"
|
||||||
|
SERVER="irc.smurfnet.ch"
|
||||||
|
INPORT="31337"
|
||||||
|
|
||||||
|
loop="/tmp/irc-bot-loop"
|
||||||
|
mkfifo "$loop"
|
||||||
|
trap "rm -f $loop" INT TERM EXIT
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "NICK $NICK"
|
||||||
|
sleep 0.2
|
||||||
|
echo "USER $NICK +i * :$0"
|
||||||
|
sleep 6
|
||||||
|
echo "JOIN $CHANNEL"
|
||||||
|
|
||||||
|
# FIXME: Possible race condition between loop and stdin.
|
||||||
|
tail -f "$loop" &
|
||||||
|
|
||||||
|
nc -6 -k -lp "$INPORT" | while read line; do
|
||||||
|
echo "NOTICE $CHANNEL $line"
|
||||||
|
done
|
||||||
|
} | \
|
||||||
|
nc "$SERVER" 6667 | while read message; do
|
||||||
|
case "$message" in
|
||||||
|
PING*) echo "PONG ${message#PING :}" | tee "$loop";;
|
||||||
|
ERROR*) echo "$message"; exit;;
|
||||||
|
*PRIVMSG*) echo "${message}" | sed -nr "s/^:([^!]+).*PRIVMSG[^:]+:(.*)/[$(date '+%R')] <\1> \2/p";;
|
||||||
|
*) echo "${message}";;
|
||||||
|
esac
|
||||||
|
done
|
11
irc-say
Executable file
11
irc-say
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
HOST=127.0.0.1
|
||||||
|
PORT=31337
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Usage: $0 <message>..."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$*" | nc "$HOST" "$PORT"
|
Loading…
Add table
Add a link
Reference in a new issue