aboutsummaryrefslogtreecommitdiff
path: root/docs/02-event-reference.md
blob: 62f89d68cdd24c7a23d38809ba6d77be0e51722d (plain)
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
51
52
53
54
55
56
57
58
59
[[back to main docs]](../README.md#documentation-map)

# Event Reference

The module offers named, numeric, and convenience events. The named and
numeric events correspond to IRC protocol events, while convenience events
are an extra layer provided to make using the module easier. This means one
IRC event can trigger several events of the module. For example, if someone
addresses our bot in a channel, the following chain of events will be fired:

    irc-addressed  ▶  irc-to-me  ▶  irc-privmsg-channel  ▶  irc-privmsg  ▶  irc-all

The events are ordered from "narrowest" to "widest": `irc-addressed` can be
triggered only in-channel, when our bot is addressed; `irc-to-me` can also
be triggered via notice and private message, so it's wider;
`irc-privmsg-channel` includes all channel messages, so it's wider still;
and `irc-privmsg` also includes private messages to our bot. The chain ends
by the widest event of them all: `irc-all`.

## Responding to Events

See [section in Basic Tutorial](01-basics.md#responding-to-events) for
responding by returning a value from the event handler.

The Message Objects received by the event handlers for the `irc-privmsg` and
`irc-notice` event chains also provide a `.reply` method using which you
can reply to the event. When this method is called `.is-replied` attribute
of the Message Object is set to `True`, which signals to the Client Object
that the returned value from the event handler should be discarded.

## Event Map

All event chains end with `irc-all`, which is not shown in the table below,
for brevity. `irc-XXX` stands for numeric events where `XXX` is a
three-digit number. See [this numerics
table](https://www.alien.net.au/irc/irc2numerics.html) for meaning of codes,
depending on the server used.

```
irc-addressed  ▶  irc-to-me      ▶  irc-privmsg-channel  ▶  irc-privmsg
                  irc-mentioned  ▶  irc-privmsg-channel  ▶  irc-privmsg
                                    irc-privmsg-channel  ▶  irc-privmsg
                  irc-to-me      ▶  irc-privmsg-me       ▶  irc-privmsg

irc-addressed  ▶  irc-to-me      ▶  irc-notice-channel   ▶  irc-notice
                  irc-mentioned  ▶  irc-notice-channel   ▶  irc-notice
                                    irc-notice-channel   ▶  irc-notice
                  irc-to-me      ▶  irc-notice-me        ▶  irc-notice

                                    irc-mode-channel     ▶  irc-mode
                                    irc-mode-me          ▶  irc-mode

                  irc-connected  ▶  irc-numeric          ▶  irc-XXX
                                    irc-numeric          ▶  irc-XXX
```

## Up Next

Read [the method reference](03-method-reference.md) next.