Created
August 12, 2012 07:07
-
-
Save Wollw/3330337 to your computer and use it in GitHub Desktop.
IRC bot in written in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Open a connection to canternet | |
exec 3<>/dev/tcp/irc.canternet.org/6667; | |
# Login and join the channel. | |
printf "NICK BashBot\r\n" >&3; | |
printf "USER bashbot 8 * :IRC Bot in Bash\r\n" >&3; | |
sleep 2; | |
printf "JOIN #HackingIsMagic\r\n" >&3; | |
# Main loop | |
while [ true ]; do | |
read msg_in <&3; | |
# UGLY ping response. Sends a PONG whenever PING shows up. | |
if [[ $msg_in =~ "PING" ]] ; then | |
printf "PONG %s\n" "${msg_in:5}"; | |
printf "PONG %s\r\n" "${msg_in:5}" >&3; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment