fishpi 0.0.63 → 0.1.0

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 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) 2025 Hancel Lin
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,99 @@
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
+ # Fishpi.js
2
+
3
+ 摸鱼派社区 (https://fishpi.cn/) 的 API Package,可以快速开发出一款应用支援社区功能。
4
+
5
+ ## 功能
6
+ - 用户信息;
7
+ - 聊天室;
8
+ - 话题编辑;
9
+ - 红包收发;
10
+ - 自定义表情包;
11
+ - 文件上传;
12
+ - 通知信息;
13
+ - 清风明月;
14
+ - 文章读写;
15
+ - 评论点赞;
16
+ - 私聊功能;
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ npm install fishpi
22
+ ```
23
+
24
+ ## 用例
25
+
26
+ ```ts
27
+ import FishPi from 'fishpi';
28
+
29
+ // 登录获取 apiKey
30
+ let apiKey = '';
31
+ let fish = new FishPi();
32
+ let rsp = await fish.login({
33
+ username: 'username',
34
+ passwd: 'password123456'
35
+ });
36
+ if (rsp.code == 0) apiKey = rsp.Key;
37
+
38
+ // 通过 apiKey 获取登录用户信息
39
+ let fish = new FishPi(apiKey);
40
+ console.dir(await fish.account.info());
41
+
42
+ // 获取用户自定义表情包
43
+ let emojis = await fish.emoji.get();
44
+ // 获取默认表情包
45
+ let defaultEmoji = fish.emoji.default;
46
+
47
+ // 监听聊天室消息
48
+ fish.chatroom.on('msg', (msg) => console.dir(msg));
49
+ // 向聊天室发送信息(需要登录)
50
+ await fish.chatroom.send('Hello World!');
51
+ // 向聊天室发送红包
52
+ await fish.chatroom.redpacket.send({
53
+ type: 'random';
54
+ money: 32;
55
+ count: 2;
56
+ msg: '摸鱼者,事竟成!';
57
+ recivers: [];
58
+ })
59
+
60
+ // 私聊历史获取
61
+ let chatHistory = await fish.chat.get({ user: 'username', autoRead: false })
62
+ // 监听私聊新消息
63
+ fishpi.notice.on('newIdleChatMessage', (msg: NoticeMsg) => {
64
+ console.log(msg.senderUserName, '说:', msg.preview);
65
+ });
66
+ // 监听指定用户的私聊消息
67
+ fishpi.chat.channel('username').on('data', (msg: ChatData) => {
68
+ console.log(msg.senderUserName, '[', msg.time, ']:', msg.content);
69
+ );
70
+ // 给指定用户发私聊消息
71
+ fishpi.chat.channel('username').send('Hi~');
72
+
73
+ // 金手指
74
+ import { Finger, FingerTo } from 'fishpi';
75
+
76
+ // 一次性金手指
77
+ await FingerTo('GoldenFingerKey').queryLatestLoginIP('username')
78
+
79
+ // 金手指实例
80
+ const finger = new Finger(apiKey);
81
+ await finger.queryLatestLoginIP('username');
82
+
83
+ ```
84
+
85
+ ## 注意事项
86
+
87
+ API 库使用 `fetch` 做 API 请求,浏览器环境可以直接使用。在 Node 环境需要安装 `node-fetch` 2.x 版本的库。执行如下代码设置 `fetch` 函数:
88
+ ```typescript
89
+ import fetch from 'node-fetch'
90
+ globalThis.fetch = fetch as any;
91
+ ```
92
+
93
+ ## 命令行工具
94
+
95
+ 全局安装可以直接通过 `fishpi` 执行一个摸鱼派命令行工具,包含几乎所有功能。
96
+
97
+ ```
98
+ npm i -g fishpi
106
99
  ```