mirror of https://github.com/Nofated095/Q2TG.git
feat: 个人模式下给群成员禁言
This commit is contained in:
parent
88c2d7238f
commit
5706491f9a
|
@ -28,6 +28,10 @@ const personalPrivateCommands = [
|
||||||
command: 'login',
|
command: 'login',
|
||||||
description: '当 QQ 处于下线状态时,使用此命令重新登录 QQ',
|
description: '当 QQ 处于下线状态时,使用此命令重新登录 QQ',
|
||||||
}),
|
}),
|
||||||
|
new Api.BotCommand({
|
||||||
|
command: 'flags',
|
||||||
|
description: 'WARNING: EXPERIMENTAL FEATURES AHEAD!',
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 服务器零号实例的管理员
|
// 服务器零号实例的管理员
|
||||||
|
@ -57,6 +61,10 @@ const inChatCommands = [
|
||||||
command: 'search',
|
command: 'search',
|
||||||
description: '搜索消息',
|
description: '搜索消息',
|
||||||
}),
|
}),
|
||||||
|
new Api.BotCommand({
|
||||||
|
command: 'q',
|
||||||
|
description: '生成 QuotLy 图片',
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
const groupInChatCommands = [
|
const groupInChatCommands = [
|
||||||
|
@ -93,6 +101,10 @@ const personalInChatCommands = [
|
||||||
command: 'nick',
|
command: 'nick',
|
||||||
description: '获取/设置群名片',
|
description: '获取/设置群名片',
|
||||||
}),
|
}),
|
||||||
|
new Api.BotCommand({
|
||||||
|
command: 'mute',
|
||||||
|
description: '设置 QQ 成员禁言',
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -44,6 +44,13 @@ export default class InChatCommandsController {
|
||||||
case '/poke':
|
case '/poke':
|
||||||
await this.service.poke(message, pair);
|
await this.service.poke(message, pair);
|
||||||
return true;
|
return true;
|
||||||
|
case '/unmute':
|
||||||
|
messageParts.unshift('0');
|
||||||
|
case '/mute':
|
||||||
|
if (this.instance.workMode !== 'personal' || !message.senderId?.eq(this.instance.owner)) return false;
|
||||||
|
if (!(pair.qq instanceof Group)) return true;
|
||||||
|
await this.service.mute(message, pair, messageParts);
|
||||||
|
return true;
|
||||||
case '/forwardoff':
|
case '/forwardoff':
|
||||||
pair.flags |= flags.DISABLE_Q2TG | flags.DISABLE_TG2Q;
|
pair.flags |= flags.DISABLE_Q2TG | flags.DISABLE_TG2Q;
|
||||||
await message.reply({ message: '转发已禁用' });
|
await message.reply({ message: '转发已禁用' });
|
||||||
|
@ -85,7 +92,7 @@ export default class InChatCommandsController {
|
||||||
return true;
|
return true;
|
||||||
case '/nick':
|
case '/nick':
|
||||||
if (this.instance.workMode !== 'personal' || !message.senderId?.eq(this.instance.owner)) return false;
|
if (this.instance.workMode !== 'personal' || !message.senderId?.eq(this.instance.owner)) return false;
|
||||||
if (!(pair.qq instanceof Group)) return;
|
if (!(pair.qq instanceof Group)) return true;
|
||||||
if (!params) {
|
if (!params) {
|
||||||
await message.reply({
|
await message.reply({
|
||||||
message: `群名片:<i>${pair.qq.pickMember(this.instance.qqUin, true).card}</i>`,
|
message: `群名片:<i>${pair.qq.pickMember(this.instance.qqUin, true).card}</i>`,
|
||||||
|
|
|
@ -146,4 +146,73 @@ export default class InChatCommandsService {
|
||||||
});
|
});
|
||||||
return rpy.join('\n');
|
return rpy.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 禁言 QQ 成员
|
||||||
|
public async mute(message: Api.Message, pair: Pair, args: string[]) {
|
||||||
|
try {
|
||||||
|
const group = pair.qq as Group;
|
||||||
|
if(!(group.is_admin||group.is_owner)){
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>无管理员权限</i>',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let target: number;
|
||||||
|
if (message.replyToMsgId) {
|
||||||
|
const dbEntry = await db.message.findFirst({
|
||||||
|
where: {
|
||||||
|
tgChatId: pair.tgId,
|
||||||
|
tgMsgId: message.replyToMsgId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (dbEntry) {
|
||||||
|
target = Number(dbEntry.qqSenderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!target) {
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>请回复一条消息</i>',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!args.length) {
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>请输入禁言的时间</i>',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let time = Number(args[0]);
|
||||||
|
if (isNaN(time)) {
|
||||||
|
const unit = args[0].substring(args[0].length - 1, args[0].length);
|
||||||
|
time = Number(args[0].substring(0, args[0].length - 1));
|
||||||
|
|
||||||
|
switch (unit) {
|
||||||
|
case 'd':
|
||||||
|
time *= 24;
|
||||||
|
case 'h':
|
||||||
|
time *= 60;
|
||||||
|
case 'm':
|
||||||
|
time *= 60;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
time = NaN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isNaN(time)) {
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>请输入正确的时间</i>',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await group.muteMember(target, time);
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>成功</i>',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
await message.reply({
|
||||||
|
message: `<i>错误</i>\n${e.message}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue