koishi-plugin-onebot-info-image 0.0.1-alpha.2 → 0.2.0-alpha.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.
- package/lib/index.d.ts +27 -0
- package/lib/index.js +1567 -0
- package/lib/renderAdminList.d.ts +3 -0
- package/lib/renderUserInfo.d.ts +14 -0
- package/lib/type.d.ts +157 -0
- package/lib/utils.d.ts +27 -0
- package/package.json +10 -7
- package/readme.md +32 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { type ImageStyle, ImageType, UnifiedAdminInfo, UnifiedContextInfo } from './type';
|
|
3
|
+
export declare function renderAdminList(ctx: Context, admins: UnifiedAdminInfo[], contextInfo: UnifiedContextInfo, imageStyle: ImageStyle, enableDarkMode: boolean, imageType: ImageType, screenshotQuality: number): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { type ImageStyle, ImageType, UnifiedUserInfo, UnifiedContextInfo } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* 渲染用户信息为图片并返回 base64 编码。
|
|
5
|
+
* @param ctx Koishi Context 实例
|
|
6
|
+
* @param userInfo 统一的用户信息对象
|
|
7
|
+
* @param contextInfo 统一的上下文信息对象
|
|
8
|
+
* @param imageStyle 图片样式
|
|
9
|
+
* @param enableDarkMode 是否启用暗黑模式
|
|
10
|
+
* @param imageType 图片类型
|
|
11
|
+
* @param screenshotQuality 截图质量
|
|
12
|
+
* @returns Promise<string> 图片的 base64 编码
|
|
13
|
+
*/
|
|
14
|
+
export declare function renderUserInfo(ctx: Context, userInfo: UnifiedUserInfo, contextInfo: UnifiedContextInfo, imageStyle: ImageStyle, enableDarkMode: boolean, imageType: ImageType, screenshotQuality: number): Promise<string>;
|
package/lib/type.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export declare const IMAGE_STYLES: {
|
|
2
|
+
readonly SOURCE_HAN_SERIF_SC: "思源宋体SourceHanSerifSC";
|
|
3
|
+
readonly LXGW_WENKAI: "落霞孤鹜文楷LXGWWenKai";
|
|
4
|
+
};
|
|
5
|
+
export type ImageStyle = typeof IMAGE_STYLES[keyof typeof IMAGE_STYLES];
|
|
6
|
+
export declare const FONT_FILES: {
|
|
7
|
+
readonly 思源宋体SourceHanSerifSC: "SourceHanSerifSC-Medium.otf";
|
|
8
|
+
readonly 落霞孤鹜文楷LXGWWenKai: "LXGWWenKaiMono-Regular.ttf";
|
|
9
|
+
};
|
|
10
|
+
export declare const IMAGE_TYPES: {
|
|
11
|
+
readonly PNG: "png";
|
|
12
|
+
readonly JPEG: "jpeg";
|
|
13
|
+
readonly WEBP: "webp";
|
|
14
|
+
};
|
|
15
|
+
export type ImageType = typeof IMAGE_TYPES[keyof typeof IMAGE_TYPES];
|
|
16
|
+
export declare const ONEBOT_IMPL_NAME: {
|
|
17
|
+
LAGRNAGE: string;
|
|
18
|
+
NAPCAT: string;
|
|
19
|
+
};
|
|
20
|
+
export type OneBotImplName = typeof ONEBOT_IMPL_NAME[keyof typeof ONEBOT_IMPL_NAME];
|
|
21
|
+
export interface UnifiedUserInfo {
|
|
22
|
+
user_id: string;
|
|
23
|
+
nickname: string;
|
|
24
|
+
sex: 'male' | 'female' | 'unknown' | '';
|
|
25
|
+
age: number;
|
|
26
|
+
group_id?: number;
|
|
27
|
+
card?: string;
|
|
28
|
+
level?: string;
|
|
29
|
+
qq_level?: number;
|
|
30
|
+
join_time?: number;
|
|
31
|
+
last_sent_time?: number;
|
|
32
|
+
role?: 'owner' | 'admin' | 'member';
|
|
33
|
+
title?: string;
|
|
34
|
+
title_expire_time?: number;
|
|
35
|
+
unfriendly?: boolean;
|
|
36
|
+
card_changeable?: boolean;
|
|
37
|
+
is_robot?: boolean;
|
|
38
|
+
shut_up_timestamp?: number;
|
|
39
|
+
uid?: string;
|
|
40
|
+
uin?: string;
|
|
41
|
+
nick?: string;
|
|
42
|
+
remark?: string;
|
|
43
|
+
constellation?: number;
|
|
44
|
+
shengXiao?: number;
|
|
45
|
+
kBloodType?: number;
|
|
46
|
+
homeTown?: string;
|
|
47
|
+
makeFriendCareer?: number;
|
|
48
|
+
pos?: string;
|
|
49
|
+
college?: string;
|
|
50
|
+
country?: string;
|
|
51
|
+
province?: string;
|
|
52
|
+
city?: string;
|
|
53
|
+
postCode?: string;
|
|
54
|
+
address?: string;
|
|
55
|
+
regTime?: number;
|
|
56
|
+
reg_time?: number;
|
|
57
|
+
interest?: string;
|
|
58
|
+
labels?: any[];
|
|
59
|
+
qqLevel?: number;
|
|
60
|
+
qid?: string;
|
|
61
|
+
q_id?: string;
|
|
62
|
+
longNick?: string;
|
|
63
|
+
long_nick?: string;
|
|
64
|
+
birthday_year?: number;
|
|
65
|
+
birthday_month?: number;
|
|
66
|
+
birthday_day?: number;
|
|
67
|
+
eMail?: string;
|
|
68
|
+
phoneNum?: string;
|
|
69
|
+
categoryId?: number;
|
|
70
|
+
richTime?: number;
|
|
71
|
+
richBuffer?: any;
|
|
72
|
+
topTime?: string;
|
|
73
|
+
isBlock?: boolean;
|
|
74
|
+
isMsgDisturb?: boolean;
|
|
75
|
+
isSpecialCareOpen?: boolean;
|
|
76
|
+
isSpecialCareZone?: boolean;
|
|
77
|
+
ringId?: string;
|
|
78
|
+
isBlocked?: boolean;
|
|
79
|
+
recommendImgFlag?: number;
|
|
80
|
+
disableEmojiShortCuts?: number;
|
|
81
|
+
qidianMasterFlag?: number;
|
|
82
|
+
qidianCrewFlag?: number;
|
|
83
|
+
qidianCrewFlag2?: number;
|
|
84
|
+
isHideQQLevel?: number;
|
|
85
|
+
isHidePrivilegeIcon?: number;
|
|
86
|
+
status?: number | {
|
|
87
|
+
status_id?: number;
|
|
88
|
+
face_id?: number;
|
|
89
|
+
message?: string;
|
|
90
|
+
};
|
|
91
|
+
extStatus?: number;
|
|
92
|
+
batteryStatus?: number;
|
|
93
|
+
termType?: number;
|
|
94
|
+
netType?: number;
|
|
95
|
+
iconType?: number;
|
|
96
|
+
customStatus?: any;
|
|
97
|
+
setTime?: string;
|
|
98
|
+
specialFlag?: number;
|
|
99
|
+
abiFlag?: number;
|
|
100
|
+
eNetworkType?: number;
|
|
101
|
+
showName?: string;
|
|
102
|
+
termDesc?: string;
|
|
103
|
+
musicInfo?: any;
|
|
104
|
+
extOnlineBusinessInfo?: any;
|
|
105
|
+
extBuffer?: any;
|
|
106
|
+
is_vip?: boolean;
|
|
107
|
+
is_years_vip?: boolean;
|
|
108
|
+
vip_level?: number;
|
|
109
|
+
login_days?: number;
|
|
110
|
+
avatar?: string;
|
|
111
|
+
sign?: string;
|
|
112
|
+
area?: string;
|
|
113
|
+
group_level?: string;
|
|
114
|
+
RegisterTime?: number;
|
|
115
|
+
Business?: any[];
|
|
116
|
+
}
|
|
117
|
+
export interface UnifiedAdminInfo {
|
|
118
|
+
user_id: number;
|
|
119
|
+
nickname: string;
|
|
120
|
+
card?: string;
|
|
121
|
+
sex?: 'male' | 'female' | 'unknown' | '';
|
|
122
|
+
age?: number;
|
|
123
|
+
area?: string;
|
|
124
|
+
level?: string;
|
|
125
|
+
qq_level?: number;
|
|
126
|
+
join_time?: number;
|
|
127
|
+
last_sent_time?: number;
|
|
128
|
+
title_expire_time?: number;
|
|
129
|
+
unfriendly?: boolean;
|
|
130
|
+
card_changeable?: boolean;
|
|
131
|
+
is_robot?: boolean;
|
|
132
|
+
shut_up_timestamp?: number;
|
|
133
|
+
role: 'owner' | 'admin';
|
|
134
|
+
title?: string;
|
|
135
|
+
avatar?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface UnifiedContextInfo {
|
|
138
|
+
isGroup: boolean;
|
|
139
|
+
groupId?: number;
|
|
140
|
+
groupName?: string;
|
|
141
|
+
memberCount?: number;
|
|
142
|
+
maxMemberCount?: number;
|
|
143
|
+
groupAvatarUrl?: string;
|
|
144
|
+
}
|
|
145
|
+
export declare function convertToUnifiedUserInfo(userInfo: any, onebotImplName: OneBotImplName): UnifiedUserInfo;
|
|
146
|
+
export declare function convertToUnifiedAdminInfo(adminInfo: any, onebotImplName: OneBotImplName): UnifiedAdminInfo;
|
|
147
|
+
export declare function convertToUnifiedContextInfo(contextInfo: any, onebotImplName: OneBotImplName): UnifiedContextInfo;
|
|
148
|
+
export declare const NAPCAT_QQ_STATUS_MAP: {
|
|
149
|
+
[key: string]: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* 根据QQ状态码和扩展状态码获取对应的文本描述
|
|
153
|
+
* @param status 主状态码
|
|
154
|
+
* @param ext_status 扩展状态码
|
|
155
|
+
* @returns 对应的状态文本,如果未找到则返回 '未知状态'
|
|
156
|
+
*/
|
|
157
|
+
export declare function getNapcatQQStatusText(status: number, ext_status: number): string;
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { type ImageStyle } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* 生成当前时间戳字符串
|
|
5
|
+
* @returns 格式为 YYYY/MM/DD HH:MM:SS 的时间戳字符串
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateTimestamp(): string;
|
|
8
|
+
/**
|
|
9
|
+
* 获取群头像的 Base64 编码
|
|
10
|
+
* @param ctx Koishi Context 实例
|
|
11
|
+
* @param groupId 群号
|
|
12
|
+
* @returns Promise<string> 群头像的 base64 编码
|
|
13
|
+
*/
|
|
14
|
+
export declare function getGroupAvatarBase64(ctx: Context, groupId: string): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* 获取字体文件的 Base64 编码
|
|
17
|
+
* @param ctx Koishi Context 实例
|
|
18
|
+
* @param imageStyle 图片样式
|
|
19
|
+
* @returns Promise<string> 字体文件的 base64 编码
|
|
20
|
+
*/
|
|
21
|
+
export declare function getFontBase64(ctx: Context, imageStyle: ImageStyle): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* 验证并下载字体文件
|
|
24
|
+
* @param ctx Koishi Context 实例
|
|
25
|
+
* @returns Promise<void>
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateFonts(ctx: Context): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-onebot-info-image",
|
|
3
|
-
"description": "用onebot api
|
|
4
|
-
"version": "0.0
|
|
3
|
+
"description": "用onebot api获取用户详细信息/群管理员列表信息,可以发纯文本/合并转发/渲染图片。 现在只做了lagrange和napcat的适配",
|
|
4
|
+
"version": "0.2.0-alpha.5+20250929",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://github.com/VincentZyu233/koishi-plugin-onebot-image",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://
|
|
15
|
+
"url": "git+https://gitee.com/vincent-zyu/koishi-plugin-onebot-image"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"chatbot",
|
|
@@ -24,12 +24,15 @@
|
|
|
24
24
|
"koishi": "^4.18.7"
|
|
25
25
|
},
|
|
26
26
|
"koishi": {
|
|
27
|
-
"description": {
|
|
27
|
+
"description": {
|
|
28
28
|
"en": "Fetch detailed user info / group admin list using OneBot API, and send plain text / merged forward messages / rendered images.",
|
|
29
|
-
"zh": "用onebot api
|
|
29
|
+
"zh": "用onebot api获取用户详细信息/群管理员列表信息,可以发纯文本/合并转发/渲染图片。现在只做了lagrange和napcat的适配"
|
|
30
30
|
},
|
|
31
31
|
"service": {
|
|
32
|
-
"required": [
|
|
32
|
+
"required": [
|
|
33
|
+
"puppeteer",
|
|
34
|
+
"http"
|
|
35
|
+
]
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}
|
package/readme.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
# koishi-plugin-
|
|
1
|
+
# koishi-plugin-onebot-info-image
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/koishi-plugin-onebot-info-image)
|
|
4
4
|
|
|
5
5
|
获取成员信息/管理员列表,发送文字/图片/合并转发消息,仅支持onebot
|
|
6
|
+
|
|
7
|
+
现在只做了lagrange和napcat的适配
|
|
8
|
+
|
|
9
|
+
## dev
|
|
10
|
+
查看git大文件
|
|
11
|
+
```shell
|
|
12
|
+
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | Where-Object { $_ -match '^blob' } | ForEach-Object { $parts = $_ -split ' ', 4; [PSCustomObject]@{ Size = [int]$parts[2]; Name = $parts[3] } } | Sort-Object Size -Descending | Select-Object -First 20
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
发布到npm workflow
|
|
16
|
+
```shell
|
|
17
|
+
cd G:\GGames\Minecraft\shuyeyun\qq-bot\koishi-dev\koishi-dev-3\external\onebot-info-image
|
|
18
|
+
git add .
|
|
19
|
+
git commit -m "message"
|
|
20
|
+
git push origin main
|
|
21
|
+
|
|
22
|
+
# ensure plugin dir name is onebot-info-image, then:
|
|
23
|
+
cd G:\GGames\Minecraft\shuyeyun\qq-bot\koishi-dev\koishi-dev-3
|
|
24
|
+
yarn
|
|
25
|
+
yarn build onebot-info-image
|
|
26
|
+
|
|
27
|
+
$Env:HTTP_PROXY = "http://127.0.0.1:7890"
|
|
28
|
+
$Env:HTTPS_PROXY = "http://127.0.0.1:7890"
|
|
29
|
+
Invoke-WebRequest -Uri "https://www.google.com" -Method Head -UseBasicParsing
|
|
30
|
+
npm login --registry https://registry.npmjs.org
|
|
31
|
+
# login npm in browser
|
|
32
|
+
npm run pub onebot-info-image -- --registry https://registry.npmjs.org
|
|
33
|
+
|
|
34
|
+
npm-stat.com
|
|
35
|
+
```
|