Example 'main' function to test bot

This commit is contained in:
Mikko Ahlroth 2013-08-03 00:40:36 +03:00
parent f70404a3c4
commit 09cacbfbd7

View file

@ -11,15 +11,36 @@ defmodule Nulform do
buffer <- {:nulform, :buffer, :reset_connection, connection}
:gen_server.cast connection, :connect
listen_loop
#{:ok, ircnet_buffer} = :gen_server.start_link Nulform.Buffer, nil, []
#{:ok, ircnet_connection} = :gen_server.start_link Nulform.Connection,
# [
# self(), ircnet_buffer, 1, "irc.cc.tut.fi", 6667,
# "Nulform", nil, "nulform", "␀form"
# ], []
#ircnet_buffer <- {:nulform, :buffer, :reset_connection, ircnet_connection}
#:gen_server.cast ircnet_connection, :connect
{:ok, urlanalyzer} = :gen_server.start_link Nulform.Plugins.URLAnalyzer,
nil, []
listen_loop urlanalyzer
end
def listen_loop() do
def listen_loop(urlanalyzer) do
receive do
{:nulform, :msg_in, msg} ->
IO.puts(to_binary(msg.connection_id) <> " -> " <> msg.raw_msg)
:gen_server.cast urlanalyzer, msg
case String.split msg.raw_msg do
[_, "376" | _] ->
:gen_server.cast msg.buffer, "JOIN #nulform"
_ ->
end
end
listen_loop
listen_loop urlanalyzer
end
end