[JavaScript] 纯文本查看 复制代码 if (ss.method == 'WebcastGiftMessage') {//有人送礼
let ret = webcast_im_GiftMessage.decode(ss.payload);
if (GiftsFilter[`d${ret.traceid}`]) {
return; //过滤重复事件
} else {
GiftsFilter[`d${ret.traceid}`] = Date.now();
setTimeout((s) => {
delete GiftsFilter[`d${s}`];
}, 3000, ret.traceid);//3秒后删除
}
if (ret.gift.combo == true) {//连击
//连击结束
if (ret.repeatend == 1) await this.Message_Format('douyin', 'gift', { user_id: ret.user.id.toString(), nick: ret.user.nickname, avatar: ret.user.avatarthumb.urllist[0] }, false, { gift_id: ret.gift.id.toString(), name: ret.gift.name, image: ret.gift.image.urllist[0], count: Number(ret.repeatcount.toString()) });
} else {
await this.Message_Format('douyin', 'gift', { user_id: ret.user.id.toString(), nick: ret.user.nickname, avatar: ret.user.avatarthumb.urllist[0] }, false, { gift_id: ret.gift.id.toString(), name: ret.gift.name, image: ret.gift.image.urllist[0], count: Number(ret.repeatcount.toString()) });
}
ret = null;
}
如果你定义了.proto进行反序列化的话 |