feat: 自定义角色图上传

This commit is contained in:
bietiaop 2024-08-01 19:08:43 +08:00
parent be1c00db59
commit 64275de0e8
11 changed files with 498 additions and 326 deletions

44
apps/manage/alias.js Normal file
View file

@ -0,0 +1,44 @@
import { char } from '../../lib/convert.js';
import settings from '../../lib/settings.js';
export async function addAlias() {
if (!this.e.isMaster) {
this.reply('仅限主人设置');
return false;
}
const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg);
const key = match[1];
const value = match[2];
const oriName = char.aliasToName(key);
const isExist = char.aliasToName(value);
if (!oriName) {
await this.e.reply(`未找到 ${value} 的对应角色`);
return;
}
if (isExist) {
await this.e.reply(`别名 ${value} 已存在`);
return;
}
settings.addArrayleConfig('alias', oriName, value);
await this.e.reply(`角色 ${key} 别名 ${value} 成功`);
}
export async function deleteAlias() {
if (!this.e.isMaster) {
this.reply('仅限主人设置');
return false;
}
const match = /删除别名(\S+)$/g.exec(this.e.msg);
const key = match[1];
const oriName = char.aliasToName(key);
if (!oriName) {
await this.e.reply(`未找到 ${key} 的对应角色`);
return;
}
if (key === oriName) {
await this.e.reply(`别名 ${key} 为角色本名,无法删除`);
return;
}
settings.removeArrayleConfig('alias', oriName, key);
await this.e.reply(`角色 ${key} 别名删除成功`);
}