@bililive-tools/bilibili-recorder 1.19.4 → 1.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/danma.js +23 -1
  2. package/package.json +2 -2
package/lib/danma.js CHANGED
@@ -136,10 +136,32 @@ class DanmaClient extends EventEmitter {
136
136
  };
137
137
  this.emit("Message", gift);
138
138
  },
139
+ raw: {
140
+ SEND_GIFT_V2: (data) => {
141
+ const msg = data.data;
142
+ const timestamp = this.useServerTimestamp ? msg.timestamp * 1000 : Date.now();
143
+ const gift = {
144
+ type: "give_gift",
145
+ timestamp: timestamp,
146
+ name: msg.gift_name,
147
+ count: msg.num,
148
+ price: msg.coin_type === "silver" ? 0 : msg.price / 1000,
149
+ sender: {
150
+ uid: String(msg.uid),
151
+ name: msg.uname,
152
+ avatar: msg.face,
153
+ },
154
+ };
155
+ this.emit("Message", gift);
156
+ },
157
+ },
139
158
  onGift: (msg) => {
159
+ // 由于兼容性0.5.6-beta.1,与上游存在冲突
160
+ if (msg.type === "SEND_GIFT_V2")
161
+ return;
140
162
  let timestamp = this.useServerTimestamp ? msg?.raw?.data?.timestamp * 1000 : Date.now();
141
163
  if (msg.type === "SEND_GIFT_V2") {
142
- timestamp = this.useServerTimestamp ? msg.timestamp : Date.now();
164
+ timestamp = this.useServerTimestamp ? msg.timestamp * 1000 : Date.now();
143
165
  }
144
166
  const gift = {
145
167
  type: "give_gift",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bililive-tools/bilibili-recorder",
3
- "version": "1.19.4",
3
+ "version": "1.19.5",
4
4
  "description": "bililive-tools bilibili recorder implemention",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "mitt": "^3.0.1",
43
43
  "lodash-es": "^4.17.21",
44
44
  "axios": "^1.15.0",
45
- "@bililive-tools/manager": "^1.17.3"
45
+ "@bililive-tools/manager": "^1.18.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsc",