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
60
61
62
63
64
65
66
67
use super::*;
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RoomState {
pub tags: Tags,
pub channel: String,
}
impl RoomState {
pub fn channel(&self) -> &str {
&self.channel
}
}
impl RoomState {
pub fn emote_only(&self) -> bool {
self.get_as_bool("emote-only")
}
pub fn followers_only(&self) -> FollowersOnly {
self.get("followers-only")
.and_then(|k| k.parse().ok())
.map(|k| match k {
-1 => FollowersOnly::Disabled,
0 => FollowersOnly::All,
d => FollowersOnly::Limit(d),
})
.unwrap_or_else(|| FollowersOnly::All)
}
pub fn r9k(&self) -> bool {
self.get_as_bool("r9k")
}
pub fn slow(&self) -> u64 {
self.get_parsed("slow").unwrap_or_else(|| 0)
}
pub fn subs_only(&self) -> bool {
self.get_as_bool("subs-only")
}
}
impl Tag for RoomState {
fn get(&self, key: &str) -> Option<&str> {
self.tags.get(key).map(AsRef::as_ref)
}
}
#[derive(Debug, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum FollowersOnly {
Disabled,
All,
Limit(i64),
}