defmodule Irc.Connection.Handler do @moduledoc """ Handler behaviour """ @type args :: Map.new() @doc """ Initializes """ @callback init(args()) :: args() @doc """ Capability negotiation. Allows the handler to request more capabilities from the server. """ @callback capabs(args()) :: [String.t()] @doc """ Connected callback. """ @callback connected(conn :: Irc.Connection.t(), args()) :: {:ok, conn :: Irc.Connection.t()} @doc """ An IRC line has been received. """ @callback line(conn :: Irc.Connection.t(), line :: Irc.Line.t()) :: {:ok, conn :: Irc.Connection.t()} @doc """ An IRC batch has been received. """ @callback batch(conn :: Irc.Connection.t(), batch :: Irc.Batch.t()) :: {:ok, conn :: Irc.Connection.t()} @doc """ Connection changed modes. """ @callback modes(conn :: Irc.Connection.t(), changes :: :todo, prev :: :todo) :: {:ok, conn :: Irc.Connection.t()} @doc """ Connection changed nick. """ @callback nick(conn :: Irc.Connection.t(), prev_nick :: String.t, new_nick :: String.t) :: {:ok, conn :: Irc.Connection.t()} @doc """ Disconnected callback. """ @callback disconnected(conn :: Irc.Connection.t(), reason :: atom()) :: any() end