clean up some more code
This commit is contained in:
parent
3b2441db92
commit
96cb54a70a
1 changed files with 16 additions and 16 deletions
24
irc.lamb
24
irc.lamb
|
@ -26,12 +26,6 @@ ircnick'("!"::xs, acc) -> acc.
|
||||||
ircnick'(x::xs, acc) -> ircnick'(xs, acc + x).
|
ircnick'(x::xs, acc) -> ircnick'(xs, acc + x).
|
||||||
ircnick(str) -> ircnick'(str, "").
|
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").
|
say(chan, msg) -> fputstr(sock, "PRIVMSG " + chan + " :" + msg + "\r\n").
|
||||||
|
|
||||||
handleMessage(nick, chan, "$ping") -> say(chan, nick + ": pong").
|
handleMessage(nick, chan, "$ping") -> say(chan, nick + ": pong").
|
||||||
|
@ -75,18 +69,24 @@ handleCommand(_, "366", _) -> (). -- End of NAMES list
|
||||||
handleCommand(src, cmd, args) ->
|
handleCommand(src, cmd, args) ->
|
||||||
putstrln("Unhandled command: " + cmd + ", with args: " + repr(args) + " from " + src).
|
putstrln("Unhandled command: " + cmd + ", with args: " + repr(args) + " from " + src).
|
||||||
|
|
||||||
handleLine(line) -> do
|
handleLine(":" :: line) -> do
|
||||||
if head(line) == ":" then do
|
-- sourced message
|
||||||
-- source
|
(source, rest) = takeUntilSpace(line);
|
||||||
(source, rest) = takeUntilSpace(tail(line));
|
|
||||||
command::args = splitirc(rest);
|
command::args = splitirc(rest);
|
||||||
handleCommand(source, command, args)
|
handleCommand(source, command, args)
|
||||||
end else do
|
end.
|
||||||
|
|
||||||
|
handleLine(line) -> do
|
||||||
|
-- non-sourced message
|
||||||
command::args = splitirc(line);
|
command::args = splitirc(line);
|
||||||
handleCommand(source, command, args)
|
handleCommand(source, command, args)
|
||||||
end
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-- now for our actual program!
|
||||||
|
|
||||||
|
-- build our socket and connect to the server
|
||||||
|
sock = sockopen("127.0.0.1", 6667).
|
||||||
|
|
||||||
-- send introduction
|
-- send introduction
|
||||||
fputstr(sock, "PASS foobar\r\n").
|
fputstr(sock, "PASS foobar\r\n").
|
||||||
fputstr(sock, "NICK quaileggeater\r\n").
|
fputstr(sock, "NICK quaileggeater\r\n").
|
||||||
|
|
Loading…
Reference in a new issue