         hookrec(rec, type: type)
       {:direct, flag}, rec ->
         hookrec(rec, direct: flag)
+      {:exclusive, flag}, rec ->
+        hookrec(rec, exclusive: flag)
     end)
     state.update_hooks(&( &1 ++ [{id, hook}] ))
   end

end


:inets.start
:ssl.start
:random.seed(:erlang.now())
IRCBot.Connection.start_link
IRCBot.Connection.add_hook :issue, &IssueHook.run/2, in: :text
IRCBot.Connection.add_hook :doc, &DocHook.run/2, in: :text
IRCBot.Connection.add_hook :link, &LinkHook.run/2, in: :text, direct: true
IRCBot.Connection.add_hook :linkscan, &LinkScanHook.run/2, in: :text
IRCBot.Connection.add_hook :trivia, &TriviaHook.run/2, in: :text
IRCBot.Connection.add_hook :ping, &PingHook.run/2, in: :text, direct: true
IRCBot.Connection.add_hook :rudereply, &RudeReplyHook.run/2, in: :text, direct: true
IRCBot.Connection.add_hook :likewhat, &LikeWhatHook.run/2, in: :text, direct: true
IRCBot.Connection.add_hook :eval, &EvalHook.run/2, in: :text

    IO.puts "receiver: '#{receiver}', sender: '#{sender}'"

    tokens = tokenize(msg)
    Enum.reduce(hooks, 0, fn
      {_, hookrec(type: type, direct: direct, exclusive: ex, fn: f)}, successes ->
        if ((not direct) || (receiver == @nickname)) && ((not ex) || (successes == 0)) do
          arg = case type do
            :text  -> if direct do strip_msg_receiver(msg, receiver) else msg end
            :token -> tokens
          end

          if resolve_hook_result(f.(sender, arg), sock) do
            successes+1
          else
            successes
          end
        else
          successes
        end
    end)
  end
