mirror of https://github.com/Nofated095/Q2TG.git
feat: 在发送人名称前面加一个颜色 emoji,feature flag: COLOR_EMOJI_PREFIX
This commit is contained in:
parent
00a8e11e35
commit
f3a0a583de
|
@ -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];
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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/')) {
|
||||
|
|
Loading…
Reference in New Issue