From 96cb54a70ab16563d9d9a20798b00448e04f7a75 Mon Sep 17 00:00:00 2001 From: darkf Date: Fri, 25 Oct 2013 15:24:12 -0700 Subject: [PATCH] clean up some more code --- irc.lamb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/irc.lamb b/irc.lamb index 99e4200..bf32e20 100644 --- a/irc.lamb +++ b/irc.lamb @@ -26,12 +26,6 @@ ircnick'("!"::xs, acc) -> acc. ircnick'(x::xs, acc) -> ircnick'(xs, acc + x). ircnick(str) -> ircnick'(str, ""). - --- and then we'll kick off the main program. - --- 127.0.0.1 -sock = sockopen("127.0.0.1", 6667). --("irc.freenode.net", 6667). - say(chan, msg) -> fputstr(sock, "PRIVMSG " + chan + " :" + msg + "\r\n"). handleMessage(nick, chan, "$ping") -> say(chan, nick + ": pong"). @@ -75,18 +69,24 @@ handleCommand(_, "366", _) -> (). -- End of NAMES list handleCommand(src, cmd, args) -> putstrln("Unhandled command: " + cmd + ", with args: " + repr(args) + " from " + src). -handleLine(line) -> do - if head(line) == ":" then do - -- source - (source, rest) = takeUntilSpace(tail(line)); - command::args = splitirc(rest); - handleCommand(source, command, args) - end else do - command::args = splitirc(line); - handleCommand(source, command, args) - end +handleLine(":" :: line) -> do + -- sourced message + (source, rest) = takeUntilSpace(line); + command::args = splitirc(rest); + handleCommand(source, command, args) end. +handleLine(line) -> do + -- non-sourced message + command::args = splitirc(line); + handleCommand(source, command, args) +end. + +-- now for our actual program! + +-- build our socket and connect to the server +sock = sockopen("127.0.0.1", 6667). + -- send introduction fputstr(sock, "PASS foobar\r\n"). fputstr(sock, "NICK quaileggeater\r\n").