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
/// Capabilities allow you to get more data from twitch
///
/// The default, `generic` is very simplistic (basically just read/write PRIVMSGs for a channel)
///
/// While enabling `membership` + `commands` + `tags` will allow you to get a much more rich set of messages
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Capability {
    /// Generic capability, the default.
    ///
    /// Simply read basic irc messages from a twitch channel
    Generic,
    /// Membership capability
    ///
    /// Similar to Generic, but allows to see who is in the channel
    Membership,
    /// Commands capability
    ///
    /// Enables many twitch specific commands
    Commands,
    /// Tags capability
    ///
    /// Provides metadata attached to each message
    Tags,
}

impl Capability {
    pub(crate) fn get_command(self) -> Option<&'static str> {
        match self {
            Capability::Generic => None,
            Capability::Membership => Some("CAP REQ :twitch.tv/membership"),
            Capability::Commands => Some("CAP REQ :twitch.tv/commands"),
            Capability::Tags => Some("CAP REQ :twitch.tv/tags"),
        }
    }
}

impl Default for Capability {
    fn default() -> Self {
        Capability::Generic
    }
}