|
23 | 23 | # the key has to be mapped to the corresponding attr name and any conversion that needs to be done |
24 | 24 |
|
25 | 25 | MESSAGE_TAG_MAPPING:dict[str:tuple[str,Callable]] = { |
26 | | - "badge-info": ("badge_info", (_return_as_is := lambda value: value),), |
27 | | - "badges": ("badges", _return_as_is,), |
28 | | - "client-nonce": ("client_nonce", _return_as_is,), |
29 | | - "color": ("color", lambda value: HEX(value) if value else HEX(),), |
30 | | - "display-name": ("display_name", _return_as_is,), |
31 | | - "emotes": ("emotes", _return_as_is,), |
32 | | - "first-msg": ("first_msg", (_return_as_bool:=lambda value: bool(int(value))),), |
33 | | - "flag": ("flag", _return_as_is,), |
34 | | - "flags": ("flags", _return_as_is,), |
35 | | - "id": ("message_id", _return_as_is,), |
36 | | - "mod": ("mod", _return_as_bool,), |
37 | | - "room-id": ("room_id", _return_as_is,), |
38 | | - "subscriber": ("subscriber", _return_as_bool,), |
39 | | - "tmi-sent-ts": ("tmi_sent_ts", (_return_as_int := lambda value: int(value)),), |
40 | | - "turbo": ("turbo", _return_as_bool,), |
41 | | - "user-id": ("user_id", _return_as_int,), |
42 | | - "user-type": ("user_type", _return_as_is,), |
43 | | - "reply-parent-display-name": ("reply_parent_display_name", _return_as_is,), |
44 | | - "reply-parent-msg-body": ("reply_parent_msg_body", _return_as_is,), |
45 | | - "reply-parent-msg-id": ("reply_parent_msg_id", _return_as_is,), |
46 | | - "reply-parent-user-id": ("reply_parent_user_id", _return_as_int,), |
47 | | - "reply-parent-user-login": ("reply_parent_user_login", _return_as_is,), |
48 | | - "emote-only": ("emote_only", _return_as_bool,), |
49 | | - "returning-chatter": ("returning_chatter", _return_as_bool,), |
| 26 | + "badge-info": ("badge_info", (_return_as_is := lambda value: value)), |
| 27 | + "badges": ("badges", _return_as_is), |
| 28 | + "client-nonce": ("client_nonce", _return_as_is), |
| 29 | + "color": ("color", lambda value: HEX(value) if value else HEX()), |
| 30 | + "display-name": ("display_name", _return_as_is), |
| 31 | + "emotes": ("emotes", _return_as_is), |
| 32 | + "first-msg": ("first_msg", (_return_as_bool:=lambda value: bool(int(value)))), |
| 33 | + "flag": ("flag", _return_as_is), |
| 34 | + "flags": ("flags", _return_as_is), |
| 35 | + "id": ("message_id", _return_as_is), |
| 36 | + "mod": ("mod", _return_as_bool), |
| 37 | + "room-id": ("room_id", _return_as_is), |
| 38 | + "subscriber": ("subscriber", _return_as_bool), |
| 39 | + "tmi-sent-ts": ("tmi_sent_ts", (_return_as_int := lambda value: int(value))), |
| 40 | + "turbo": ("turbo", _return_as_bool), |
| 41 | + "user-id": ("user_id", _return_as_int), |
| 42 | + "user-type": ("user_type", _return_as_is), |
| 43 | + "reply-parent-display-name": ("reply_parent_display_name", _return_as_is), |
| 44 | + "reply-parent-msg-body": ("reply_parent_msg_body", _return_as_is), |
| 45 | + "reply-parent-msg-id": ("reply_parent_msg_id", _return_as_is), |
| 46 | + "reply-parent-user-id": ("reply_parent_user_id", _return_as_int), |
| 47 | + "reply-parent-user-login": ("reply_parent_user_login", _return_as_is), |
| 48 | + "emote-only": ("emote_only", _return_as_bool), |
| 49 | + "returning-chatter": ("returning_chatter", _return_as_bool), |
50 | 50 | "custom-reward-id": ("custom_reward_id", _return_as_is), |
51 | 51 | "emote-sets": ("emote_sets", _return_as_is), |
52 | 52 | "msg-id": ("msg_id", _return_as_is), |
| 53 | + "vip": ("vip", _return_as_bool) |
53 | 54 | } |
54 | 55 |
|
55 | 56 | # ---------------------------------------------------------------------------------------------------------------------- |
@@ -84,6 +85,7 @@ class MessageTags: |
84 | 85 | custom_reward_id:str = NOTHING |
85 | 86 | emote_sets:str =NOTHING |
86 | 87 | msg_id:str=NOTHING |
| 88 | + vip:bool=False |
87 | 89 |
|
88 | 90 | @classmethod |
89 | 91 | def new_from_tags_str(cls, tags_str:str) -> MessageTags: |
|
0 commit comments