Created
October 24, 2015 05:54
-
-
Save dayvonjersen/863a75b8e521a5064ff7 to your computer and use it in GitHub Desktop.
I'm pretty sure this is broken
This file contains hidden or 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
nick = "tso|bot" | |
chan = "#test" | |
introduced = false | |
irc = connect("localhost",6667) | |
#irc = connect(6667) | |
function sendmsg(msg) | |
write(irc,string(msg,"\n")) | |
println(msg) | |
end | |
#sendmsg("NICK $(nick)\n") | |
function introduce() | |
sendmsg("NICK $(nick)\n") | |
sendmsg(string("USER $(nick) localhost * :", replace(nick,r"[^0-9A-Za-z-_]+",""))) | |
sendmsg("JOIN $(chan)"); | |
end | |
function main() | |
#introduce() | |
x = 0 | |
while true | |
msg = readline(irc) | |
m = match(r"^PING :(.+)\n", msg) | |
if m != nothing | |
sendmsg(string("PONG :", m.captures[1])) | |
end | |
if ismatch(r":.* 462 ", msg) | |
introduced = true | |
end | |
if !introduced | |
introduce() | |
if ismatch(r":.* 001 .*", readline(irc)) || x >= 5 | |
introduced = true | |
continue | |
end | |
x += 1 | |
end | |
if ismatch(Regex("^:.* PRIVMSG $(chan) :.hello"), msg) | |
sendmsg("PRIVMSG $(chan) :world! :D") | |
sendmsg("QUIT") | |
break | |
end | |
if ismatch(Regex("^:.* PRIVMSG $(chan) :.bots"), msg) | |
sendmsg("PRIVMSG $(chan) :Reporting in! [\x0306julia\x03]\n") | |
end | |
write(STDOUT,msg) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment