feat: 在发送人名称前面加一个颜色 emoji,feature flag: COLOR_EMOJI_PREFIX

This commit is contained in:
Clansty 2024-01-30 15:39:47 +08:00
parent 00a8e11e35
commit f3a0a583de
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
3 changed files with 14 additions and 1 deletions

View File

@ -2,4 +2,9 @@ import random from '../utils/random';
export default {
picture: () => random.pick('🎆', '🌃', '🌇', '🎇', '🌌', '🌠', '🌅', '🌉', '🏞', '🌆', '🌄', '🖼', '🗾', '🎑', '🏙', '🌁'),
color(index: number) {
const arr = [...'🔴🟠🟡🟢🔵🟣⚫️⚪️🟤'];
index = index % arr.length;
return arr[index];
},
};

View File

@ -5,6 +5,7 @@ enum flags {
DISABLE_POKE = 1 << 3,
NO_DELETE_MESSAGE = 1 << 4,
NO_AUTO_CREATE_PM = 1 << 5,
COLOR_EMOJI_PREFIX = 1 << 6,
}
export default flags;

View File

@ -43,6 +43,7 @@ import Docker from 'dockerode';
import ReplyKeyboardHide = Api.ReplyKeyboardHide;
import env from '../models/env';
import { CustomFile } from 'telegram/client/uploads';
import flags from '../constants/flags';
const NOT_CHAINABLE_ELEMENTS = ['flash', 'record', 'video', 'location', 'share', 'json', 'xml', 'poke'];
@ -106,7 +107,10 @@ export default class ForwardService {
if (event.anonymous) {
sender = `[${sender}]${event.anonymous.name}`;
}
messageHeader = `<b>${helper.htmlEscape(sender)}</b>: `;
if ((pair.flags | this.instance.flags) & flags.COLOR_EMOJI_PREFIX) {
messageHeader += emoji.color(event.sender.user_id);
}
messageHeader += `<b>${helper.htmlEscape(sender)}</b>: `;
}
const useSticker = (file: FileLike) => {
files.push(file);
@ -415,6 +419,9 @@ export default class ForwardService {
helper.getUserDisplayName(await message.forward.getChat() || await message.forward.getSender())) :
'') +
': \n';
if ((pair.flags | this.instance.flags) & flags.COLOR_EMOJI_PREFIX) {
messageHeader = emoji.color(message.senderId.toJSNumber()) + messageHeader;
}
if (message.photo instanceof Api.Photo ||
// stickers 和以文件发送的图片都是这个
message.document?.mimeType?.startsWith('image/')) {