Example 'main' function to test bot
This commit is contained in:
parent
f70404a3c4
commit
09cacbfbd7
1 changed files with 24 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue