Closed SitiSchu closed 5 years ago
I think doing something transactional would be best here (pseudocode):
try {
await addCommandToStore(commandFromUser);
await sendCommandSuccess(commandFromUser);
} catch (err) {
await deleteCommandFromStore(commandFromUser);
await sendCommandError(err);
}
Trying to send the user command as part of the success message, and if that fails, remove it and send the error.
Could just try sending the command, and if it succeeds, edit the message to a success message.
I think the success feedback should contain the formatted message as well? Successfully added command: This is the formatted response
I tend to agree...I usually find myself testing the command to see if I ducked up the formatting or not so sending it is a nice idea
No need to validate at all if instead of HTML formatted plaintext the command would take formatted message and unformat it using https://github.com/telegraf/telegraf/blob/develop/core/replicators.js
If a custom command has invalid HTML, the command will not be sent, and the bot will error. The user never sees a notice which is bad. A way around this could be testing if the custom command content is valid. This can be checked by either using a HTML Linter(if such thing exists) or by sending the Command. If there's an error, tell the user. If there is none delete it and tell the User that the command was added.