12 unstable releases (3 breaking)

0.3.1 Oct 5, 2024
0.3.0 Oct 4, 2024
0.2.0 Oct 3, 2024
0.1.3 May 7, 2024
0.0.4 Feb 29, 2024

#1639 in Network programming

Download history 10/week @ 2024-09-23 384/week @ 2024-09-30 69/week @ 2024-10-07 20/week @ 2024-10-14

483 downloads per month
Used in 2 crates (via ircv3_parse)

MIT/Apache

8KB
51 lines

IRCv3 message

only tags parse


lib.rs:

only parse IRCv3 tags part

Examples

use ircv3_tags::{IRCv3Tags, parse};
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= :abc!abc@abc.tmi.twitch.tv PRIVMSG #xyz :HeyGuys";
let (remain, tags) = parse(msg);
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", ""),
]).into_iter()
  .map(|(key, value)| (key.to_string(), value.to_string()))
  .collect::<HashMap<String, String>>();

assert_eq!(remain, ":abc!abc@abc.tmi.twitch.tv PRIVMSG #xyz :HeyGuys");

assert!(tags.is_some());
let tags = tags.unwrap();
assert_eq!(tags, IRCv3Tags::new(expected_tags));

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

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

Dependencies

~1MB
~19K SLoC