Commit 4bae4166 authored by nanahira's avatar nanahira

logging

parent 66ef9639
......@@ -31,18 +31,25 @@ export default class GuildVerifier {
@InjectConfig()
private config: GuildVerifierConfig;
getUserDisplayName(session: Session) {
return `${session.username || '未知用户'}(${session.userId})`;
}
getGuildDisplayName(session: Session) {
return `${session.guildName || '未知群组'}(${session.guildId})`;
}
@UseEvent('guild-request')
private async onGuildRequest(session: Session) {
const userDisplayName = `${session.username || '未知用户'}(${
session.userId
}) `;
const guildDisplayName = `${session.guildName || '未知群组'}(${
session.guildId
})`;
const userDisplayName = this.getUserDisplayName(session);
const guildDisplayName = this.getGuildDisplayName(session);
this.logger.info(
`${session.messageId}: ${userDisplayName} invited ${session.selfId} to ${guildDisplayName}.`,
);
if (session.userId && this.config.isAdmin(session.userId)) {
this.logger.info(
`${session.messageId}: Accepted because ${userDisplayName} is an admin.`,
);
return session.bot.handleGuildRequest(session.messageId, true);
}
if (!this.config.notifyGuildId) {
......@@ -65,6 +72,11 @@ export default class GuildVerifier {
if (!this.config.isAdmin(session.userId)) {
return '你没有权限操作。';
}
this.logger.info(
`${this.getUserDisplayName(session)} ${
accept ? 'accepted' : 'rejected'
} the invitation of ${messageId}.`,
);
try {
await session.bot.handleGuildRequest(messageId, accept);
} catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment