Skip to content

Commit

Permalink
feat: 隐藏加群提示里 QQ 号的 flag
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 4, 2024
1 parent 4b468cd commit 57f78ae
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions main/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const log = getLogger('Web Api');
let app = new Elysia()
.onError(error => {
log.error(error.request.method, error.request.url, error.error.message);
log.debug(error.error);
})
.get('/', () => {
return { hello: 'Q2TG' };
Expand Down
1 change: 1 addition & 0 deletions main/src/constants/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum flags {
DISABLE_SLASH_COMMAND = 1 << 13,
DISABLE_RICH_HEADER = 1 << 14,
DISABLE_OFFLINE_NOTICE = 1 << 15,
HIDE_ALL_QQ_NUMBER = 1 << 16,
}

export default flags;
3 changes: 2 additions & 1 deletion main/src/controllers/ForwardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ export default class ForwardController {
const pair = this.instance.forwardPairs.find(event.chat);
if (!pair) return false;
if ((pair?.flags | this.instance.flags) & flags.DISABLE_JOIN_NOTICE) return false;
const hideAllQqNumber = (pair.flags | this.instance.flags) & flags.HIDE_ALL_QQ_NUMBER;
const avatar = await getAvatar(event.userId);
await pair.tg.sendMessage({
file: new CustomFile('avatar.png', avatar.length, '', avatar),
message: `<b>${event.nickname}</b> (<code>${event.userId}</code>) <i>加入了本群</i>`,
message: `<b>${event.nickname}</b>${hideAllQqNumber ? '' : ` (<code>${event.userId}</code>)`} <i>加入了本群</i>`,
silent: true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default class ForwardService {
elem.text = `@${info.card || info.nickname}`;
}
}
if (env.WEB_ENDPOINT && typeof elem.qq === 'number') {
if (env.WEB_ENDPOINT && typeof elem.qq === 'number' && !((pair.flags | this.instance.flags) & flags.DISABLE_RICH_HEADER)) {
message += `<a href="${helper.generateRichHeaderUrl(pair.apiKey, elem.qq)}">[<i>${helper.htmlEscape(elem.text)}</i>]</a>`;
isContainAt = true;
break;
Expand Down

0 comments on commit 57f78ae

Please sign in to comment.