fix: 群组模式不应该响应好友消息

This commit is contained in:
Clansty 2022-03-07 21:04:53 +08:00
parent c44cec4aa0
commit 3c7f261e70
No known key found for this signature in database
GPG Key ID: 05F8479BA63A8E92
2 changed files with 6 additions and 5 deletions

View File

@ -91,7 +91,7 @@ export default class ConfigController {
};
private handleQqMessage = async (message: GroupMessageEvent | PrivateMessageEvent) => {
if (message.message_type !== 'private') return false;
if (message.message_type !== 'private' || this.instance.workMode === 'group') return false;
const pair = this.instance.forwardPairs.find(message.friend);
if (pair) return false;
// 如果正在创建中,应该阻塞

View File

@ -22,7 +22,7 @@ export default class ConfigService {
private readonly tgBot: Telegram,
private readonly tgUser: Telegram,
private readonly oicq: OicqClient) {
this.log = getLogger(`ConfigService - ${instance.id}`)
this.log = getLogger(`ConfigService - ${instance.id}`);
this.owner = tgBot.getChat(this.instance.owner);
}
@ -231,6 +231,7 @@ export default class ConfigService {
}
catch (e) {
message = `错误:<code>${e}</code>`;
this.log.error(e);
}
await (await this.owner).sendMessage({ message });
}
@ -295,11 +296,11 @@ export default class ConfigService {
return text + `\n\n由 @${this.tgBot.me.username} 管理`;
}
public async migrateAllChats(){
public async migrateAllChats() {
const dbPairs = await db.forwardPair.findMany();
for (const forwardPair of dbPairs) {
const chatForUser = await this.tgUser.getChat(Number(forwardPair.tgChatId))
if(chatForUser.entity instanceof Api.Chat){
const chatForUser = await this.tgUser.getChat(Number(forwardPair.tgChatId));
if (chatForUser.entity instanceof Api.Chat) {
this.log.info('升级群组 ', chatForUser.id);
await chatForUser.migrate();
}