package com.yutou.biliapi.bean.websocket.live;

import com.alibaba.fastjson2.JSONObject;
import com.yutou.common.utils.Log;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 超级留言
 * <a href="https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/live/message_stream.md#%E9%86%92%E7%9B%AE%E7%95%99%E8%A8%80-super_chat_message">醒目留言</a>
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class WSSuperChatMessage extends WSData{
    private long price;
    private long rate;
    private String uid;
    private long start_time;
    private long end_time;
    private String message;
    private String message_trans;
    private String message_font_color;
    private String userName;
    private String userNameColor;
    private String userAvatar;
    private String background_bottom_color;



    public static void main(String[] args) {
        JSONObject json=JSONObject.parseObject("{\"cmd\":\"SUPER_CHAT_MESSAGE\",\"data\":{\"background_bottom_color\":\"#E2B52B\",\"background_color\":\"#FFF1C5\",\"background_color_end\":\"#EEBE5C\",\"background_color_start\":\"#EAB400\",\"background_icon\":\"\",\"background_image\":\"\",\"background_price_color\":\"#ECCF75\",\"color_point\":0.7,\"dmscore\":714,\"end_time\":1730462758,\"gift\":{\"gift_id\":12000,\"gift_name\":\"醒目留言\",\"num\":1},\"group_medal\":{\"is_lighted\":0,\"medal_id\":0,\"name\":\"\"},\"id\":10855278,\"is_mystery\":false,\"is_ranked\":0,\"is_send_audit\":0,\"medal_info\":{\"anchor_roomid\":5265,\"anchor_uname\":\"Liyuu_\",\"guard_level\":3,\"icon_id\":0,\"is_lighted\":1,\"medal_color\":\"#06154c\",\"medal_color_border\":6809855,\"medal_color_end\":6850801,\"medal_color_start\":398668,\"medal_level\":25,\"medal_name\":\"水溅跃\",\"special\":\"\",\"target_id\":4549624},\"message\":\"芋泥泥最近在哪发财呢\",\"message_font_color\":\"#72110E\",\"message_trans\":\"\",\"price\":100,\"rate\":1000,\"start_time\":1730462458,\"time\":300,\"token\":\"D6F223DA\",\"trans_mark\":0,\"ts\":1730462458,\"uid\":19970343,\"uinfo\":{\"base\":{\"face\":\"https://i0.hdslb.com/bfs/face/e3b35f66d631f740770b2b64bd3bcc1e66322717.jpg\",\"is_mystery\":false,\"name\":\"蘭梅蛋糕\",\"name_color\":0,\"name_color_str\":\"#00D1F1\",\"official_info\":{\"desc\":\"\",\"role\":0,\"title\":\"\",\"type\":-1},\"origin_info\":{\"face\":\"https://i0.hdslb.com/bfs/face/e3b35f66d631f740770b2b64bd3bcc1e66322717.jpg\",\"name\":\"蘭梅蛋糕\"}},\"guard\":{\"expired_str\":\"2024-11-01 23:59:59\",\"level\":3},\"medal\":{\"color\":398668,\"color_border\":6809855,\"color_end\":6850801,\"color_start\":398668,\"guard_icon\":\"https://i0.hdslb.com/bfs/live/143f5ec3003b4080d1b5f817a9efdca46d631945.png\",\"guard_level\":3,\"honor_icon\":\"\",\"id\":0,\"is_light\":1,\"level\":25,\"name\":\"水溅跃\",\"ruid\":4549624,\"score\":50020367,\"typ\":0,\"user_receive_count\":0,\"v2_medal_color_border\":\"#58A1F8FF\",\"v2_medal_color_end\":\"#4775EFCC\",\"v2_medal_color_level\":\"#000B7099\",\"v2_medal_color_start\":\"#4775EFCC\",\"v2_medal_color_text\":\"#FFFFFFFF\"},\"title\":{\"old_title_css_id\":\"title-153-1\",\"title_css_id\":\"title-153-1\"},\"uid\":19970343},\"user_info\":{\"face\":\"https://i0.hdslb.com/bfs/face/e3b35f66d631f740770b2b64bd3bcc1e66322717.jpg\",\"face_frame\":\"https://i0.hdslb.com/bfs/live/80f732943cc3367029df65e267960d56736a82ee.png\",\"guard_level\":3,\"is_main_vip\":0,\"is_svip\":0,\"is_vip\":0,\"level_color\":\"#61c05a\",\"manager\":0,\"name_color\":\"#00D1F1\",\"title\":\"title-153-1\",\"uname\":\"蘭梅蛋糕\",\"user_level\":15}},\"is_report\":true,\"msg_id\":\"21972164819290113:1000:1000\",\"p_is_ack\":true,\"p_msg_type\":1,\"send_time\":1730462458528}");
        WSSuperChatMessage message=new WSSuperChatMessage(json);
        Log.i(message);
    }
    public WSSuperChatMessage(JSONObject json) {
        super(json);
        JSONObject data=json.getJSONObject("data");
        setPrice(data.getLongValue("price"));
        setRate(data.getLongValue("rate"));
        setUid(data.getString("uid"));
        setStart_time(data.getLongValue("start_time"));
        setEnd_time(getStart_time()+(data.getIntValue("time")));
        setMessage(data.getString("message"));
        setMessage_trans(data.getString("message_trans"));
        setMessage_font_color(data.getString("message_font_color"));
        setUserName(data.getJSONObject("user_info").getString("uname"));
        setUserAvatar(data.getJSONObject("user_info").getString("face"));
        setUserNameColor(data.getJSONObject("user_info").getString("name_color"));
        setBackground_bottom_color(data.getString("background_bottom_color"));
    }
}
