#irc-v3 #tags #twitch

ircv3_tags

仅解析 IRCv3 标签部分

9 个版本

0.1.3 2024 年 5 月 7 日
0.1.2 2024 年 3 月 16 日
0.0.6 2024 年 3 月 2 日
0.0.4 2024 年 2 月 29 日

#irc-v3 中排名第 2

Download history 87/week @ 2024-05-02 16/week @ 2024-05-09 6/week @ 2024-05-16 3/week @ 2024-05-23 1/week @ 2024-05-30 2/week @ 2024-06-06 3/week @ 2024-06-13

每月下载 951
2 个包中使用 (通过 ircv3_parse)

MIT/Apache 许可

7KB

IRCv3 消息

仅解析标签


lib.rs:

仅解析 IRCv3 标签部分

示例

use ircv3_tags::IRCv3Tags;
use std::collections::HashMap;

let msg = "@badge-info=;badges=broadcaster/1;client-nonce=997dcf443c31e258c1d32a8da47b6936;color=#0000FF;display-name=abc;emotes=;first-msg=0;flags=0-6:S.7;id=eb24e920-8065-492a-8aea-266a00fc5126;mod=0;room-id=713936733;subscriber=0;tmi-sent-ts=1642786203573;turbo=0;user-id=713936733;user-type= :[email protected] PRIVMSG #xyz :HeyGuys";
let (remain, tags) = IRCv3Tags::parse(msg).unwrap();
let expected_tags = HashMap::from([
   ("badge-info", ""),
   ("subscriber", "0"),
   ("id", "eb24e920-8065-492a-8aea-266a00fc5126"),
   ("user-id", "713936733"),
   ("emotes", ""),
   ("tmi-sent-ts", "1642786203573"),
   ("client-nonce", "997dcf443c31e258c1d32a8da47b6936"),
   ("mod", "0"),
   ("badges", "broadcaster/1"),
   ("room-id", "713936733"),
   ("flags", "0-6:S.7"),
   ("color", "#0000FF"),
   ("turbo", "0"),
   ("display-name", "abc"),
   ("first-msg", "0"),
   ("user-type", ""),
]);
assert_eq!(remain, ":[email protected] PRIVMSG #xyz :HeyGuys");
assert_eq!(tags.as_ref(), &Some(expected_tags));

let tmi_sent_ts = tags.get("tmi-sent-ts");
assert_eq!(tmi_sent_ts, Some("1642786203573"));

let notif = tags.get("not-if");
assert_eq!(notif, None);

依赖

约 1MB
约 19K SLoC