src/bar_items/typing_notice.rs
27 lines · 655 bytes
3 symbols in this file
1use weechat::{
2 buffer::Buffer,
3 hooks::{BarItem, BarItemCallback},
4 Weechat,
5};
6
7use crate::{BufferOwner, Servers};
8
9pub(super) struct TypingNotice {
10 servers: Servers,
11}
12
13impl TypingNotice {
14 pub(super) fn create(servers: Servers) -> Result<BarItem, ()> {
15 let status = TypingNotice { servers };
16 BarItem::new("matrix_typing_notice", status)
17 }
18}
19
20impl BarItemCallback for TypingNotice {
21 fn callback(&mut self, _: &Weechat, buffer: &Buffer) -> String {
22 match self.servers.buffer_owner(buffer) {
23 BufferOwner::Room(_, room) => room.typing_notice(),
24 _ => String::new(),
25 }
26 }
27}