Skip to content

Commit

Permalink
fix: at 变表情
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jul 17, 2024
1 parent 7a2b297 commit 961d05a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
33 changes: 7 additions & 26 deletions main/src/client/NapCatClient/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,26 @@ export const messageElemToNapCatSendable = async (elem: SendableElem): Promise<{
export const napCatReceiveToMessageElem = (data: Receive[keyof Receive]): MessageElem | Receive['forward'] => {
switch (data.type) {
case 'text':
return {
...data.data,
type: data.type,
};
case 'face':
case 'image':
case 'record':
case 'json':
case 'markdown':
return {
...data.data,
type: data.type,
};
} as any;
case 'mface':
return {
type: 'image',
url: data.data.url,
file: data.data.url,
};
case 'at':
const qqNum = Number(data.data.qq);
return {
...data.data,
type: data.type,
};
case 'image':
return {
...data.data,
type: data.type,
};
case 'record':
return {
...data.data,
type: data.type,
qq: isNaN(qqNum) ? data.data.qq : qqNum,
};
case 'file':
return {
Expand All @@ -124,22 +115,12 @@ export const napCatReceiveToMessageElem = (data: Receive[keyof Receive]): Messag
fid: data.data.url,
file: data.data.url,
};
case 'json':
return {
...data.data,
type: data.type,
};
case 'dice':
case 'rps':
return {
id: data.data.result,
type: data.type,
};
case 'markdown':
return {
...data.data,
type: data.type,
};
case 'forward':
return data;
case 'reply':
Expand Down
14 changes: 11 additions & 3 deletions main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
import { fetchFile, getBigFaceUrl, getImageUrlByMd5, isContainsUrl } from '../utils/urls';
import { ButtonLike, FileLike } from 'telegram/define';
import { getLogger, Logger } from 'log4js';
import path from 'path';
import exts from '../constants/exts';
import helper from '../helpers/forwardHelper';
import db from '../models/db';
import { Button } from 'telegram/tl/custom/button';
Expand All @@ -38,7 +36,7 @@ import { CustomFile } from 'telegram/client/uploads';
import flags from '../constants/flags';
import BigInteger from 'big-integer';
import pastebin from '../utils/pastebin';
import { MessageEvent, QQClient, Sendable, SendableElem } from '../client/QQClient';
import { Group, MessageEvent, QQClient, Sendable, SendableElem } from '../client/QQClient';
import posthog from '../models/posthog';
import { NapCatClient } from '../client/NapCatClient';
import fsP from 'fs/promises';
Expand Down Expand Up @@ -205,6 +203,16 @@ export default class ForwardService {
message += `<a href="${helper.generateRichHeaderUrl(pair.apiKey, elem.qq)}">[<i>${helper.htmlEscape(elem.text)}</i>]</a>`;
break;
}
if (!elem.text) {
if (isNaN(elem.qq as number)) {
elem.text = `@${elem.qq === 'all' ? '全体成员' : elem.qq}`;
}
else {
const member = (pair.qq as Group).pickMember(elem.qq as number);
const info = await member.renew();
elem.text = `@${info.card || info.nickname}`;
}
}
}
case 'face':
// 判断 tgs 表情
Expand Down

0 comments on commit 961d05a

Please sign in to comment.