mirror of https://github.com/Nofated095/Q2TG.git
feat: 支持发起戳一戳
This commit is contained in:
parent
bb0992a04c
commit
fed155000a
|
@ -49,12 +49,16 @@ const groupInChatCommands = [
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
const privateInChatCommands = [
|
const personalInChatCommands = [
|
||||||
...groupInChatCommands,
|
...groupInChatCommands,
|
||||||
new Api.BotCommand({
|
new Api.BotCommand({
|
||||||
command: 'refresh',
|
command: 'refresh',
|
||||||
description: '刷新头像和简介',
|
description: '刷新头像和简介',
|
||||||
}),
|
}),
|
||||||
|
new Api.BotCommand({
|
||||||
|
command: 'poke',
|
||||||
|
description: '戳一戳',
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -64,5 +68,5 @@ export default {
|
||||||
groupPrivateSuperAdminCommands,
|
groupPrivateSuperAdminCommands,
|
||||||
personalPrivateSuperAdminCommands,
|
personalPrivateSuperAdminCommands,
|
||||||
groupInChatCommands,
|
groupInChatCommands,
|
||||||
privateInChatCommands,
|
personalInChatCommands,
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,9 @@ export default class InChatCommandsController {
|
||||||
case '/info':
|
case '/info':
|
||||||
await this.service.info(message, pair);
|
await this.service.info(message, pair);
|
||||||
return true;
|
return true;
|
||||||
|
case '/poke':
|
||||||
|
await this.service.poke(message, pair);
|
||||||
|
return true;
|
||||||
case '/refresh':
|
case '/refresh':
|
||||||
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;
|
||||||
await pair.updateInfo();
|
await pair.updateInfo();
|
||||||
|
|
|
@ -153,7 +153,7 @@ export default class Instance {
|
||||||
}
|
}
|
||||||
// 设定群组内的
|
// 设定群组内的
|
||||||
await this.tgBot.setCommands(
|
await this.tgBot.setCommands(
|
||||||
this.workMode === 'personal' ? commands.privateInChatCommands : commands.groupInChatCommands,
|
this.workMode === 'personal' ? commands.personalInChatCommands : commands.groupInChatCommands,
|
||||||
// 普通用户其实不需要这些命令,这样可以让用户的输入框少点东西
|
// 普通用户其实不需要这些命令,这样可以让用户的输入框少点东西
|
||||||
new Api.BotCommandScopeChatAdmins(),
|
new Api.BotCommandScopeChatAdmins(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Pair } from '../models/Pair';
|
||||||
import { CustomFile } from 'telegram/client/uploads';
|
import { CustomFile } from 'telegram/client/uploads';
|
||||||
import { getAvatar } from '../utils/urls';
|
import { getAvatar } from '../utils/urls';
|
||||||
import db from '../models/db';
|
import db from '../models/db';
|
||||||
import { Friend } from 'oicq';
|
import { Friend, Group } from 'oicq';
|
||||||
import { format } from 'date-and-time';
|
import { format } from 'date-and-time';
|
||||||
|
|
||||||
export default class InChatCommandsService {
|
export default class InChatCommandsService {
|
||||||
|
@ -83,4 +83,37 @@ export default class InChatCommandsService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async poke(message: Api.Message, pair: Pair) {
|
||||||
|
try {
|
||||||
|
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 (pair.qq instanceof Group && !target) {
|
||||||
|
await message.reply({
|
||||||
|
message: '<i>请回复一条消息</i>',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (pair.qq instanceof Group) {
|
||||||
|
await pair.qq.pokeMember(target);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await pair.qq.poke(target && target !== pair.qqRoomId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
await message.reply({
|
||||||
|
message: `<i>错误</i>\n${e.message}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue