Skip to content

Commit 990cf02

Browse files
committed
feat: 支持 QQ 端的 debug_net_card
1 parent 3ec9d99 commit 990cf02

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

apps/qqbot/src/adapter/BundledMessage.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ export class BundledMessageNode extends BundledMessageNodeBase<BotTypes> {
6868
// @ts-ignore
6969
params.content = params.message;
7070
}
71+
if(this._markdown) {
72+
params.content.push({
73+
type: 'markdown',
74+
data: {
75+
content: this._markdown
76+
}
77+
});
78+
}
7179

7280
return {
7381
type: 'node',

apps/tgbot/src/bot/commandList.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const commandListBase = [
33
{ command: 'chuni', description: '搜索中二节奏歌曲信息' },
44
{ command: 'b50', description: '生成 Maimai DX B50 成绩图' },
55
{ command: 'query', description: '查询自己 Maimai DX 某首歌的成绩' },
6+
{ command: 'qchu', description: '查询自己中二节奏某首歌的成绩' },
67
{ command: 'help', description: '查看一些帮助信息' }
78
] as const;
89

packages/botcore/src/modules/admin/index.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,26 @@ export default <T extends BotTypes>({ bot, env, getContext, musicToFile }: Build
2929

3030
const card = event.params[0];
3131
const req = await client.debugUserProfile(card);
32-
const data = await req.json();
32+
const data = await req.json() as { card: { id: number, luid: string, extId: number }, games: object[] }[];
3333
const enc = new TextEncoder();
3434

35-
await event.reply()
36-
.addDocument(bot.constructFile(enc.encode(JSON.stringify(data, null, 2)), `${card}.json`))
37-
.dispatch();
35+
const reply = event.reply();
36+
try {
37+
reply.addDocument(bot.constructFile(enc.encode(JSON.stringify(data, null, 2)), `${card}.json`));
38+
} catch (e) {
39+
}
40+
41+
const bundle = reply.addBundledMessage();
42+
bundle.setTitle(`找到的卡片数量: ${data.length}`);
43+
for (const { card, games } of data) {
44+
const sub = bundle.addNode().addBundledMessage().setTitle(`卡片 ${card.luid}`).setDescription(`游戏数量: ${games.length}`);
45+
sub.addNode().setQQMarkdown('```json\n' + JSON.stringify(card, null, 2) + '\n```');
46+
for (const game of games) {
47+
sub.addNode().setQQMarkdown('```json\n' + JSON.stringify(game, null, 2) + '\n```');
48+
}
49+
}
50+
51+
await reply.dispatch();
3852

3953
return true;
4054
});

packages/botfirm/src/BundledMessage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ export abstract class BundledMessageNodeBase<T extends BotTypes> extends BaseTex
3434
protected _file: T['SendableFile'] = null;
3535
protected _fileType: 'audio' | 'document' | 'photo' = null;
3636
protected _bundledMessage: BundledMessageBase<T> = null;
37+
protected _markdown: string = null;
3738

3839
public addPhoto(file: T['SendableFile']) {
3940
this._fileType = 'photo';
4041
this._file = file;
4142
return this;
4243
}
4344

45+
public setQQMarkdown(text: string) {
46+
this._markdown = text;
47+
}
48+
4449
public abstract addBundledMessage(): BundledMessageBase<T>;
4550
}
4651

0 commit comments

Comments
 (0)