Skip to content

Instantly share code, notes, and snippets.

@eldstal
Created October 30, 2012 09:07
Show Gist options
  • Save eldstal/3979151 to your computer and use it in GitHub Desktop.
Save eldstal/3979151 to your computer and use it in GitHub Desktop.
A simple IRC bot. Join, spam, disconnect.
#!/bin/bash
# $1: The nickname to use
function ircpreamble {
echo "NICK ${1}"
echo "USER ${1} 0 * :Totally not a spambot"
}
# $1: Channel to join
function channel {
echo "JOIN ${1}"
}
# stdin: a stream where each line is converted to a message
# $1: The user/channel to send to
function privmsg {
TARGET=$1
sed -re "s/^(.*)\$/PRIVMSG ${TARGET} :\1/"
}
# Curtail spam protection
function delay {
while read LINE; do
sleep 2
echo $LINE
done
}
# Replace with reading your file or whatever
function messages {
echo "spam spam spam"
echo "lovely spam"
}
function disconnect {
echo "QUIT no more spam"
}
(
ircpreamble "FarbrorAlBot";
channel "#megabice";
messages | privmsg "#megabice";
disconnect;
) | delay | nc irc.freenode.net 6667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment