Function twitch_message::parse_emotes
source · Expand description
Parse emotes from a tag value and associated data
use twitch_message::{Tags, parse_emotes, Emote};
use std::borrow::Cow;
let emotes = "25:0-4,14-18";
let data = "Kappa testing Kappa";
let expected = [
Emote { id: Cow::from("25"), name: Cow::from("Kappa"), byte_pos: (0, 5) },
Emote { id: Cow::from("25"), name: Cow::from("Kappa"), byte_pos: (14, 19) },
];
for (i, emote) in parse_emotes(emotes, data).enumerate() {
assert_eq!(expected[i], emote);
}
See also
If you have an already parsed Tags
you can use Emote::from_tags