     message_loop(sock, state)
   end
 
-  def process_hooks(msg, State[text_hooks: text, token_hooks: token], sock) do
-    Enum.each(text, fn {_, f} -> resolve_hook_result(f.(msg), sock) end)
-
+  def process_hooks(msg, State[hooks: hooks], sock) do
     tokens = tokenize(msg)
-    Enum.each(token, fn {_, f} -> resolve_hook_result(f.(tokens), sock) end)
+    Enum.each(hooks, fn
+      {_, hookrec(type: type, direct: direct, fn: f)} ->
+        if not direct || receiver == @nickname do
+          arg = case type do
+            :text  -> msg
+            :token -> tokens
+          end
+          resolve_hook_result(f.(sender, arg), sock)
+        end
+    end)
   end
 
   defp tokenize(msg) do

  end
end

:inets.start
:ssl.start
IRCBot.Connection.start_link

  end

  defp resolve_hook_result({:reply, text}, sock) do
    irc_cmd(sock, "PRIVMSG", "\##{@channel} #{@nickname}: :#{text}")
  end

  defp resolve_hook_result({:reply, to, text}, sock) do
    irc_cmd(sock, "PRIVMSG", "\##{@channel} #{to}: :#{text}")
  end

  defp resolve_hook_result({:msg, text}, sock) do
