def __send_throttling_warning(self, event, throttling_state): remaining_seconds = throttling_state.remaining_seconds( event.message.date) self.__log_throttling(event, remaining_seconds) message = FormattedText().bold("Ignoring repeated command.").normal(" Try again in ")\ .code_inline(remaining_seconds).normal(" seconds.")\ .build_message() message.to_chat_replying(event.message) self.api. async .send_message(message)
def do_enable(self, event): disable_command = UnderscoredCommandBuilder.build_command( event.command, "off") message = FormattedText().normal("Activating #silence mode. I won't send anything here until you ")\ .normal(disable_command).normal(" me.")\ .build_message() # sending reply before activating silence mode, so that it is actually sent message.to_chat_replying(event.message) self.api.send_message(message) event.state.silenced = "yes" # returning a message to avoid caller failing, but message should not be sent, as silence mode is now enabled return message