fishpi 0.0.56 → 0.0.58
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.
- package/LICENSE +21 -21
- package/README.md +105 -105
- package/lib/breezemoon.js +1 -1
- package/lib/chatroom.d.ts +7 -1
- package/lib/chatroom.js +129 -95
- package/package.json +2 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Ryan Sonshine
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Ryan Sonshine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
# 摸鱼派 API Package
|
|
2
|
-
摸鱼派社区 (https://fishpi.cn/) 的 API Package,可以快速开发出一款应用支援社区功能。
|
|
3
|
-
|
|
4
|
-
## 支援
|
|
5
|
-
- 用户信息;
|
|
6
|
-
- 聊天室;
|
|
7
|
-
- 话题编辑;
|
|
8
|
-
- 红包收发;
|
|
9
|
-
- 自定义表情包;
|
|
10
|
-
- 文件上传;
|
|
11
|
-
- 通知信息;
|
|
12
|
-
- 清风明月;
|
|
13
|
-
- 文章读写;
|
|
14
|
-
- 评论点赞;
|
|
15
|
-
- 私聊功能;
|
|
16
|
-
|
|
17
|
-
## 安装
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install fishpi
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 用例
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import FishPi from 'fishpi';
|
|
27
|
-
|
|
28
|
-
// 登录获取 apiKey
|
|
29
|
-
let apiKey = '';
|
|
30
|
-
let fish = new FishPi();
|
|
31
|
-
let rsp = await fish.login({
|
|
32
|
-
username: 'username',
|
|
33
|
-
passwd: 'password123456'
|
|
34
|
-
});
|
|
35
|
-
if (rsp.code == 0) apiKey = rsp.Key;
|
|
36
|
-
|
|
37
|
-
// 通过 apiKey 获取登录用户信息
|
|
38
|
-
let fish = new FishPi(apiKey);
|
|
39
|
-
console.dir(await fish.account.info());
|
|
40
|
-
|
|
41
|
-
// 获取用户自定义表情包
|
|
42
|
-
let emojis = await fish.emoji.get();
|
|
43
|
-
// 获取默认表情包
|
|
44
|
-
let defaultEmoji = fish.emoji.default;
|
|
45
|
-
|
|
46
|
-
// 监听聊天室消息
|
|
47
|
-
fish.chatroom.addListener(({ msg }) => console.dir(msg));
|
|
48
|
-
// 向聊天室发送信息(需要登录)
|
|
49
|
-
await fish.chatroom.send('Hello World!');
|
|
50
|
-
// 向聊天室发送红包
|
|
51
|
-
await fish.chatroom.redpacket.send({
|
|
52
|
-
type: 'random';
|
|
53
|
-
money: 32;
|
|
54
|
-
count: 2;
|
|
55
|
-
msg: '摸鱼者,事竟成!';
|
|
56
|
-
recivers: [];
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
// 私聊历史获取
|
|
60
|
-
let chatHistory = await fish.chat.get({ user: 'username', autoRead: false })
|
|
61
|
-
// 监听私聊新消息
|
|
62
|
-
fishpi.chat.addListener(async ({ msg }: { msg: NoticeMsg }) => {
|
|
63
|
-
switch (msg.command) {
|
|
64
|
-
// 私聊未读数更新
|
|
65
|
-
case 'chatUnreadCountRefresh':
|
|
66
|
-
if(msg.count! > 0) {
|
|
67
|
-
let unreadMsgs = await fishpi.chat.unread();
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
// 新私聊消息
|
|
71
|
-
case 'newIdleChatMessage':
|
|
72
|
-
// msg 就是新的私聊消息
|
|
73
|
-
console.log(msg.senderUserName, '说:', msg.preview);
|
|
74
|
-
break;
|
|
75
|
-
// 有新的消息通知
|
|
76
|
-
case 'refreshNotification':
|
|
77
|
-
console.log('你有新消息【', await fishpi.notice.count(), '】')
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
// 监听指定用户的私聊消息
|
|
82
|
-
fishpi.chat.addListener(({ msg }: { msg: ChatData }) => {
|
|
83
|
-
console.log(msg.senderUserName, '[', msg.time, ']:', msg.content);
|
|
84
|
-
}, 'username');
|
|
85
|
-
// 给指定用户发私聊消息
|
|
86
|
-
fishpi.chat.send('username', 'Hi~');
|
|
87
|
-
|
|
88
|
-
// 金手指
|
|
89
|
-
import { Finger, FingerTo } from 'fishpi';
|
|
90
|
-
|
|
91
|
-
// 一次性金手指
|
|
92
|
-
await FingerTo('GoldenFingerKey').queryLatestLoginIP('username')
|
|
93
|
-
|
|
94
|
-
// 金手指实例
|
|
95
|
-
const finger = new Finger(apiKey);
|
|
96
|
-
await finger.queryLatestLoginIP('username');
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## 注意事项
|
|
101
|
-
|
|
102
|
-
API 库使用 `fetch` 做 API 请求,浏览器环境可以直接使用。在 Node 环境需要安装 `node-fetch` 2.x 版本的库。执行如下代码设置 `fetch` 函数:
|
|
103
|
-
```typescript
|
|
104
|
-
import fetch from 'node-fetch'
|
|
105
|
-
globalThis.fetch = fetch as any;
|
|
1
|
+
# 摸鱼派 API Package
|
|
2
|
+
摸鱼派社区 (https://fishpi.cn/) 的 API Package,可以快速开发出一款应用支援社区功能。
|
|
3
|
+
|
|
4
|
+
## 支援
|
|
5
|
+
- 用户信息;
|
|
6
|
+
- 聊天室;
|
|
7
|
+
- 话题编辑;
|
|
8
|
+
- 红包收发;
|
|
9
|
+
- 自定义表情包;
|
|
10
|
+
- 文件上传;
|
|
11
|
+
- 通知信息;
|
|
12
|
+
- 清风明月;
|
|
13
|
+
- 文章读写;
|
|
14
|
+
- 评论点赞;
|
|
15
|
+
- 私聊功能;
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install fishpi
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 用例
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import FishPi from 'fishpi';
|
|
27
|
+
|
|
28
|
+
// 登录获取 apiKey
|
|
29
|
+
let apiKey = '';
|
|
30
|
+
let fish = new FishPi();
|
|
31
|
+
let rsp = await fish.login({
|
|
32
|
+
username: 'username',
|
|
33
|
+
passwd: 'password123456'
|
|
34
|
+
});
|
|
35
|
+
if (rsp.code == 0) apiKey = rsp.Key;
|
|
36
|
+
|
|
37
|
+
// 通过 apiKey 获取登录用户信息
|
|
38
|
+
let fish = new FishPi(apiKey);
|
|
39
|
+
console.dir(await fish.account.info());
|
|
40
|
+
|
|
41
|
+
// 获取用户自定义表情包
|
|
42
|
+
let emojis = await fish.emoji.get();
|
|
43
|
+
// 获取默认表情包
|
|
44
|
+
let defaultEmoji = fish.emoji.default;
|
|
45
|
+
|
|
46
|
+
// 监听聊天室消息
|
|
47
|
+
fish.chatroom.addListener(({ msg }) => console.dir(msg));
|
|
48
|
+
// 向聊天室发送信息(需要登录)
|
|
49
|
+
await fish.chatroom.send('Hello World!');
|
|
50
|
+
// 向聊天室发送红包
|
|
51
|
+
await fish.chatroom.redpacket.send({
|
|
52
|
+
type: 'random';
|
|
53
|
+
money: 32;
|
|
54
|
+
count: 2;
|
|
55
|
+
msg: '摸鱼者,事竟成!';
|
|
56
|
+
recivers: [];
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// 私聊历史获取
|
|
60
|
+
let chatHistory = await fish.chat.get({ user: 'username', autoRead: false })
|
|
61
|
+
// 监听私聊新消息
|
|
62
|
+
fishpi.chat.addListener(async ({ msg }: { msg: NoticeMsg }) => {
|
|
63
|
+
switch (msg.command) {
|
|
64
|
+
// 私聊未读数更新
|
|
65
|
+
case 'chatUnreadCountRefresh':
|
|
66
|
+
if(msg.count! > 0) {
|
|
67
|
+
let unreadMsgs = await fishpi.chat.unread();
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
// 新私聊消息
|
|
71
|
+
case 'newIdleChatMessage':
|
|
72
|
+
// msg 就是新的私聊消息
|
|
73
|
+
console.log(msg.senderUserName, '说:', msg.preview);
|
|
74
|
+
break;
|
|
75
|
+
// 有新的消息通知
|
|
76
|
+
case 'refreshNotification':
|
|
77
|
+
console.log('你有新消息【', await fishpi.notice.count(), '】')
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// 监听指定用户的私聊消息
|
|
82
|
+
fishpi.chat.addListener(({ msg }: { msg: ChatData }) => {
|
|
83
|
+
console.log(msg.senderUserName, '[', msg.time, ']:', msg.content);
|
|
84
|
+
}, 'username');
|
|
85
|
+
// 给指定用户发私聊消息
|
|
86
|
+
fishpi.chat.send('username', 'Hi~');
|
|
87
|
+
|
|
88
|
+
// 金手指
|
|
89
|
+
import { Finger, FingerTo } from 'fishpi';
|
|
90
|
+
|
|
91
|
+
// 一次性金手指
|
|
92
|
+
await FingerTo('GoldenFingerKey').queryLatestLoginIP('username')
|
|
93
|
+
|
|
94
|
+
// 金手指实例
|
|
95
|
+
const finger = new Finger(apiKey);
|
|
96
|
+
await finger.queryLatestLoginIP('username');
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 注意事项
|
|
101
|
+
|
|
102
|
+
API 库使用 `fetch` 做 API 请求,浏览器环境可以直接使用。在 Node 环境需要安装 `node-fetch` 2.x 版本的库。执行如下代码设置 `fetch` 函数:
|
|
103
|
+
```typescript
|
|
104
|
+
import fetch from 'node-fetch'
|
|
105
|
+
globalThis.fetch = fetch as any;
|
|
106
106
|
```
|
package/lib/breezemoon.js
CHANGED
|
@@ -96,7 +96,7 @@ var Breezemoon = /** @class */ (function () {
|
|
|
96
96
|
case 0:
|
|
97
97
|
_a.trys.push([0, 2, , 3]);
|
|
98
98
|
return [4 /*yield*/, (0, utils_1.request)({
|
|
99
|
-
url: "api/user/".concat(user, "breezemoons?p=").concat(page, "&size=").concat(size, "&apiKey=").concat(this._apiKey)
|
|
99
|
+
url: "api/user/".concat(user, "/breezemoons?p=").concat(page, "&size=").concat(size, "&apiKey=").concat(this._apiKey)
|
|
100
100
|
})];
|
|
101
101
|
case 1:
|
|
102
102
|
rsp = _a.sent();
|
package/lib/chatroom.d.ts
CHANGED
|
@@ -92,6 +92,11 @@ declare class ChatRoom {
|
|
|
92
92
|
*/
|
|
93
93
|
send(redpacket: RedPacket): Promise<ApiResponse<undefined>>;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* 获取聊天室节点
|
|
97
|
+
* @returns 返回节点地址
|
|
98
|
+
*/
|
|
99
|
+
getNode(): Promise<string>;
|
|
95
100
|
/**
|
|
96
101
|
* 重连聊天室
|
|
97
102
|
* @param timeout 超时时间
|
|
@@ -99,7 +104,8 @@ declare class ChatRoom {
|
|
|
99
104
|
* @param close 关闭回调
|
|
100
105
|
* @returns 返回 Open Event
|
|
101
106
|
*/
|
|
102
|
-
reconnect({ timeout, error, close }?: {
|
|
107
|
+
reconnect({ url, timeout, error, close }?: {
|
|
108
|
+
url?: string;
|
|
103
109
|
timeout?: number;
|
|
104
110
|
error?: (ev: any) => void;
|
|
105
111
|
close?: (ev: any) => void;
|
package/lib/chatroom.js
CHANGED
|
@@ -452,6 +452,32 @@ var ChatRoom = /** @class */ (function () {
|
|
|
452
452
|
enumerable: false,
|
|
453
453
|
configurable: true
|
|
454
454
|
});
|
|
455
|
+
/**
|
|
456
|
+
* 获取聊天室节点
|
|
457
|
+
* @returns 返回节点地址
|
|
458
|
+
*/
|
|
459
|
+
ChatRoom.prototype.getNode = function () {
|
|
460
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
461
|
+
var rsp, e_10;
|
|
462
|
+
return __generator(this, function (_a) {
|
|
463
|
+
switch (_a.label) {
|
|
464
|
+
case 0:
|
|
465
|
+
_a.trys.push([0, 2, , 3]);
|
|
466
|
+
return [4 /*yield*/, (0, utils_1.request)({
|
|
467
|
+
url: "chat-room/node/get",
|
|
468
|
+
method: 'get',
|
|
469
|
+
})];
|
|
470
|
+
case 1:
|
|
471
|
+
rsp = _a.sent();
|
|
472
|
+
return [2 /*return*/, rsp.data];
|
|
473
|
+
case 2:
|
|
474
|
+
e_10 = _a.sent();
|
|
475
|
+
throw e_10;
|
|
476
|
+
case 3: return [2 /*return*/];
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
};
|
|
455
481
|
/**
|
|
456
482
|
* 重连聊天室
|
|
457
483
|
* @param timeout 超时时间
|
|
@@ -460,106 +486,114 @@ var ChatRoom = /** @class */ (function () {
|
|
|
460
486
|
* @returns 返回 Open Event
|
|
461
487
|
*/
|
|
462
488
|
ChatRoom.prototype.reconnect = function (_a) {
|
|
463
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.
|
|
489
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.url, url = _c === void 0 ? "" : _c, _d = _b.timeout, timeout = _d === void 0 ? 10 : _d, _e = _b.error, error = _e === void 0 ? function (ev) { } : _e, _f = _b.close, close = _f === void 0 ? function (ev) { } : _f;
|
|
464
490
|
return __awaiter(this, void 0, void 0, function () {
|
|
465
491
|
var _this = this;
|
|
466
|
-
return __generator(this, function (
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
492
|
+
return __generator(this, function (_g) {
|
|
493
|
+
switch (_g.label) {
|
|
494
|
+
case 0:
|
|
495
|
+
if (!!url) return [3 /*break*/, 2];
|
|
496
|
+
return [4 /*yield*/, this.getNode()];
|
|
497
|
+
case 1:
|
|
498
|
+
url = _g.sent();
|
|
499
|
+
_g.label = 2;
|
|
500
|
+
case 2: return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
501
|
+
var _a, _b, _c, _d;
|
|
502
|
+
var _e;
|
|
503
|
+
var _this = this;
|
|
504
|
+
return __generator(this, function (_f) {
|
|
505
|
+
switch (_f.label) {
|
|
506
|
+
case 0:
|
|
507
|
+
if (this._rws)
|
|
508
|
+
return [2 /*return*/, resolve(this._rws.reconnect())];
|
|
509
|
+
_a = this;
|
|
510
|
+
_b = reconnecting_websocket_1.default.bind;
|
|
511
|
+
_c = [void 0, "".concat(url, "?apiKey=").concat(this._apiKey), []];
|
|
512
|
+
_e = {};
|
|
513
|
+
if (!utils_1.isBrowse) return [3 /*break*/, 1];
|
|
514
|
+
_d = window.WebSocket;
|
|
515
|
+
return [3 /*break*/, 3];
|
|
516
|
+
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('ws')); })];
|
|
517
|
+
case 2:
|
|
518
|
+
_d = (_f.sent()).WebSocket;
|
|
519
|
+
_f.label = 3;
|
|
520
|
+
case 3:
|
|
521
|
+
_a._rws = new (_b.apply(reconnecting_websocket_1.default, _c.concat([(
|
|
522
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
523
|
+
_e.WebSocket = _d,
|
|
524
|
+
_e.connectionTimeout = 1000 * timeout,
|
|
525
|
+
_e)])))();
|
|
526
|
+
this._rws.onopen = function (e) {
|
|
527
|
+
if (_this._wsTimer) {
|
|
528
|
+
clearInterval(_this._wsTimer);
|
|
529
|
+
}
|
|
530
|
+
_this._wsTimer = setInterval(function () {
|
|
531
|
+
var _a;
|
|
532
|
+
(_a = _this._rws) === null || _a === void 0 ? void 0 : _a.send('-hb-');
|
|
533
|
+
}, 1000 * 60 * 3);
|
|
534
|
+
resolve(e);
|
|
535
|
+
};
|
|
536
|
+
this._rws.onmessage = function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
537
|
+
var msg, data, barragerContent, userAvatarURL, userAvatarURL20, userNickname, barragerColor, userName, userAvatarURL210, userAvatarURL48, userOId, oId, time, userName, userNickname, userAvatarURL, content, md, client, data_1, oId, count, got, whoGive, whoGot;
|
|
538
|
+
return __generator(this, function (_a) {
|
|
539
|
+
msg = JSON.parse(e.data);
|
|
540
|
+
data = null;
|
|
541
|
+
switch (msg.type) {
|
|
542
|
+
case 'online': {
|
|
543
|
+
this._onlines = msg.users;
|
|
544
|
+
this._discusse = msg.discussing;
|
|
545
|
+
data = this._onlines;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
case 'discussChanged': {
|
|
549
|
+
data = msg.newDiscuss;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
case 'revoke': {
|
|
553
|
+
data = msg.oId;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
case 'barrager': {
|
|
557
|
+
barragerContent = msg.barragerContent, userAvatarURL = msg.userAvatarURL, userAvatarURL20 = msg.userAvatarURL20, userNickname = msg.userNickname, barragerColor = msg.barragerColor, userName = msg.userName, userAvatarURL210 = msg.userAvatarURL210, userAvatarURL48 = msg.userAvatarURL48;
|
|
558
|
+
data = { barragerContent: barragerContent, userAvatarURL: userAvatarURL, userAvatarURL20: userAvatarURL20, userNickname: userNickname, barragerColor: barragerColor, userName: userName, userAvatarURL210: userAvatarURL210, userAvatarURL48: userAvatarURL48 };
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
case 'msg': {
|
|
562
|
+
userOId = msg.userOId, oId = msg.oId, time = msg.time, userName = msg.userName, userNickname = msg.userNickname, userAvatarURL = msg.userAvatarURL, content = msg.content, md = msg.md, client = msg.client;
|
|
563
|
+
try {
|
|
564
|
+
data_1 = JSON.parse(content);
|
|
565
|
+
content = data_1;
|
|
566
|
+
msg.type = data_1.msgType;
|
|
567
|
+
}
|
|
568
|
+
catch (e) { }
|
|
569
|
+
data = { userOId: userOId, oId: oId, time: time, userName: userName, userNickname: userNickname, userAvatarURL: userAvatarURL, content: content, md: md, client: client, via: (0, utils_1.clientToVia)(client) };
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
case 'redPacketStatus': {
|
|
573
|
+
oId = msg.oId, count = msg.count, got = msg.got, whoGive = msg.whoGive, whoGot = msg.whoGot;
|
|
574
|
+
data = { oId: oId, count: count, got: got, whoGive: whoGive, whoGot: whoGot };
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
case 'customMessage': {
|
|
578
|
+
data = msg.message;
|
|
579
|
+
break;
|
|
534
580
|
}
|
|
535
|
-
catch (e) { }
|
|
536
|
-
data = { userOId: userOId, oId: oId, time: time, userName: userName, userNickname: userNickname, userAvatarURL: userAvatarURL, content: content, md: md, client: client, via: (0, utils_1.clientToVia)(client) };
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
case 'redPacketStatus': {
|
|
540
|
-
oId = msg.oId, count = msg.count, got = msg.got, whoGive = msg.whoGive, whoGot = msg.whoGot;
|
|
541
|
-
data = { oId: oId, count: count, got: got, whoGive: whoGive, whoGot: whoGot };
|
|
542
|
-
break;
|
|
543
|
-
}
|
|
544
|
-
case 'customMessage': {
|
|
545
|
-
data = msg.message;
|
|
546
|
-
break;
|
|
547
581
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
582
|
+
this._wsCallbacks.forEach(function (call) { return call(Object.assign(__assign(__assign({}, e), { msg: { type: msg.type, data: data } }))); });
|
|
583
|
+
return [2 /*return*/];
|
|
584
|
+
});
|
|
585
|
+
}); };
|
|
586
|
+
this._rws.onerror = error || (function (e) {
|
|
587
|
+
console.error(e);
|
|
551
588
|
});
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
}); })];
|
|
589
|
+
this._rws.onclose = close || (function (e) {
|
|
590
|
+
console.log(e);
|
|
591
|
+
});
|
|
592
|
+
return [2 /*return*/];
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}); })];
|
|
596
|
+
}
|
|
563
597
|
});
|
|
564
598
|
});
|
|
565
599
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fishpi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"description": "A Package to use API of fishpi.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"prebuild": "rimraf lib",
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"prepublish": "npm run build",
|
|
13
|
+
"prepare": "npm run build",
|
|
13
14
|
"test": "NODE_OPTIONS=\"-r ts-node/register --no-warnings\" node ./test/index.ts",
|
|
14
15
|
"publish": "npm publish"
|
|
15
16
|
},
|