summaryrefslogtreecommitdiff
path: root/lib/irc/connection_handler.ex
blob: a5d5f3f8d9b73cf335f4f6c616a30865cd66f15e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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