diff --git a/scripts/wichtelbot/message/handlingDefinition.ts b/scripts/wichtelbot/message/handlingDefinition.ts index 76afd7959b0526bdeeeb7e143c8813955d9ffe71..97c8f827f42d62e61cbed529781b8d6fe23c1adf 100644 --- a/scripts/wichtelbot/message/handlingDefinition.ts +++ b/scripts/wichtelbot/message/handlingDefinition.ts @@ -410,7 +410,7 @@ export default class HandlingDefinition public publicCommands: CommandDefinition[] = [ { commandInfo: Localisation.commands.contacting, - handlerFunction: async (message: Message): Promise<void> => this.generalModule.firstContact(message) + handlerFunction: async (message: Message): Promise<void> => this.generalModule.makeFirstContact(message) } ]; diff --git a/scripts/wichtelbot/message/messageHandler.ts b/scripts/wichtelbot/message/messageHandler.ts index cfd00f095efd6283fb34ee556ff883eabaf2d3da..f7fa2aa9604bb4bfa8cd41942b067f54a149bcb2 100644 --- a/scripts/wichtelbot/message/messageHandler.ts +++ b/scripts/wichtelbot/message/messageHandler.ts @@ -36,12 +36,6 @@ export default class MessageHandler // In group/server channels: protected publicCommands: CommandMap = new Map<string, CommandHandlerFunction>(); protected moderatorCommands: CommandMap = new Map<string, CommandHandlerFunction>(); - // Special: - protected firstContact: CommandHandlerFunction = async (message): Promise<void> => this.generalModule.firstContact(message); - protected messageNotUnterstood = async (message: Message): Promise<void> => this.generalModule.notUnderstood(message); - protected sentHelpText = async (message: Message, availableCommands: CommandInfo[]): Promise<void> => - this.generalModule.sendHelpText(message, availableCommands); - protected sentComponentText: CommandHandlerFunction = async (message): Promise<void> => this.generalModule.sentComponentText(message); protected componentExpectedStates: Set<State> = new Set(); @@ -168,7 +162,7 @@ export default class MessageHandler if (this.helpCommands.includes(message.command)) { const availableCommands = this.getAvailableCommands(state); - await this.sentHelpText(message, availableCommands); + await this.generalModule.sendHelpText(message, availableCommands); return CommandCallResult.Called; } @@ -271,18 +265,26 @@ export default class MessageHandler // We need to do nothing here, already called successfully. break; case CommandCallResult.MissingComponentOrigin: - // Who sent us the text on a button has to be put to his place: - await this.sentComponentText(message); - break; + { + // Who sent us the text on a button has to be put to his place: + const answer = Localisation.texts.sentComponentText.process(message.author); + await message.reply(answer); + + break; + } case CommandCallResult.NotFound: - await this.messageNotUnterstood(message); - break; + { + const answer = Localisation.texts.notUnderstood.process(message.author); + await message.reply(answer); + + break; + } } } else { // First contact: - await this.firstContact(message); + await this.generalModule.makeFirstContact(message); } } else diff --git a/scripts/wichtelbot/message/modules/generalModule.ts b/scripts/wichtelbot/message/modules/generalModule.ts index 33046d3585e42fb4b86d22e35281087d20524b7a..60aab5afe516fa2f8ef259aea0cd2aac10035fbb 100644 --- a/scripts/wichtelbot/message/modules/generalModule.ts +++ b/scripts/wichtelbot/message/modules/generalModule.ts @@ -52,7 +52,7 @@ export default class GeneralModule * Makes first contact with a new user. \ * Will save the new contact in the database. */ - public async firstContact (message: Message): Promise<void> + public async makeFirstContact (message: Message): Promise<void> { let answer: string; @@ -150,26 +150,6 @@ export default class GeneralModule } } - /** - * Replies with the appropriate text for sending the text on a component instead of clicking it. - */ - public async sentComponentText (message: Message): Promise<void> - { - const answer = Localisation.texts.sentComponentText.process(message.author); - - await message.reply(answer); - } - - /** - * Replies context-dependend help messages. - */ - public async notUnderstood (message: Message): Promise<void> - { - const answer = Localisation.texts.notUnderstood.process(message.author); - - await message.reply(answer); - } - public async sendHelpText (message: Message, availableCommands: CommandInfo[]): Promise<void> { let helpText: string|null = null;