def get_response_ranking(self, event, hashtags,
                          number_of_users_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     printable_hashtags = hashtags.grouped_by_user(
         number_of_users_to_display).printable_version(user_storage_handler)
     return self.__build_success_response_message(
         event, "Users who write most hashtags:", printable_hashtags)
Esempio n. 2
0
 def get_response_recent(self, event, poles, number_of_poles_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     sorted_poles = poles.most_recent(number_of_poles_to_display)
     printable_poles = sorted_poles.printable_version(
         event, user_storage_handler)
     return self.__build_success_response_message(
         event, self.__formatted(_("Most recent {poles}:")),
         printable_poles)
Esempio n. 3
0
 def get_response_recent(self, event, voices, number_of_voices_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     format_string = "{formatted_date} → {formatted_user} → {formatted_command}"
     printable_voices = voices.most_recent().limit(number_of_voices_to_display)\
         .printable_version(event, user_storage_handler, format_string)
     return self.__build_success_response_message(event,
                                                  "Most recent audios:",
                                                  printable_voices)
 def get_response_ranking(self, event, messages,
                          number_of_users_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     printable_messages = messages.grouped_by_user(
         number_of_users_to_display).printable_info(user_storage_handler)
     return self.__build_success_response_message(event,
                                                  "Ranking of users:",
                                                  printable_messages)
 def get_response_recent(self, event, messages,
                         number_of_messages_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     sorted_messages = messages.most_recent(number_of_messages_to_display)
     printable_messages = sorted_messages.printable_info(
         event, user_storage_handler)
     return self.__build_success_response_message(event,
                                                  "Most recent messages:",
                                                  printable_messages)
Esempio n. 6
0
 def get_response_ranking(self, event, poles, number_of_users_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     printable_poles = poles.grouped_by_user(
         number_of_users_to_display).printable_version(user_storage_handler)
     recent_poles_command = UnderscoredCommandBuilder.build_command(
         event.command, "recent")
     recent_poles_text = FormattedText().normal(_("Write {0} to see recent {poles}."))\
         .start_format().normal(recent_poles_command).normal(**self.pole_format_dict).end_format()
     return self.__build_success_response_message(
         event, self.__formatted(_("Ranking of {poles}:")), printable_poles,
         recent_poles_text)
Esempio n. 7
0
 def get_response_number(self, event, voices, number_of_users_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     printable_voices = voices.grouped_by_user(number_of_users_to_display)\
         .printable_version(user_storage_handler)
     suggested_command = UnderscoredCommandBuilder.build_command(
         event.command, "mean")
     footer_text = FormattedText().normal("Write ").normal(
         suggested_command).normal(" to see mean audio length per user.")
     return self.__build_success_response_message(
         event, "Number of audios sent per user:", printable_voices,
         footer_text)
 def get_response_from(self, event, messages, from_message_id,
                       number_of_messages_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     sorted_messages = messages.slice_from(from_message_id,
                                           number_of_messages_to_display)
     printable_messages = sorted_messages.printable_info(
         event, user_storage_handler)
     title = FormattedText().normal("Messages from {0}:").start_format(
     ).bold(from_message_id).end_format()
     return self.__build_success_response_message(event, title,
                                                  printable_messages)
Esempio n. 9
0
 def get_response_biggest(self, event, voices, number_of_voices_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     format_string = "{formatted_size} → {formatted_user} → {formatted_command}"
     printable_voices = voices.biggest().limit(number_of_voices_to_display)\
         .printable_version(event, user_storage_handler, format_string)
     suggested_command = UnderscoredCommandBuilder.build_command(
         event.command, "smallest")
     footer_text = FormattedText().normal("Write ").normal(
         suggested_command).normal(" to see smallest audios.")
     return self.__build_success_response_message(event, "Biggest audios:",
                                                  printable_voices,
                                                  footer_text)
Esempio n. 10
0
 def get_response_size(self, event, voices, number_of_users_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     formatter = SizeFormatter.format
     printable_voices = voices.grouped_by_size(number_of_users_to_display)\
         .printable_version(user_storage_handler, formatter)
     suggested_command = UnderscoredCommandBuilder.build_command(
         event.command, "biggest")
     footer_text = FormattedText().normal("Write ").normal(
         suggested_command).normal(" to see biggest audios.")
     return self.__build_success_response_message(
         event, "Sum of audios size per user:", printable_voices,
         footer_text)
 def get_response_show(self, event, messages, message_id):
     message = messages.get(message_id)
     if message is None:
         return Message.create("Invalid message_id.\nUse " + event.command +
                               " to get valid message_ids.")
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     if not OptOutManager(self.state).should_display_message(
             event, message.user_id):
         user = UserFormatter.retrieve_and_format(message.user_id,
                                                  user_storage_handler)
         return FormattedText().normal("🙁 Sorry, ").bold(user).normal(
             " has opted-out from this feature.").build_message()
     return message.printable_full_message(user_storage_handler)
 def get_response_recent(self, event, hashtags,
                         number_of_hashtags_to_display):
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     sorted_hashtags = hashtags.sorted_by_recent_use(
         number_of_hashtags_to_display)
     printable_hashtags = sorted_hashtags.printable_version(
         user_storage_handler)
     ranking_hashtags_command = UnderscoredCommandBuilder.build_command(
         event.command, "ranking")
     ranking_hashtags_text = FormattedText().normal("Write ").normal(
         ranking_hashtags_command).normal(
             " to see which users write most hashtags.")
     return self.__build_success_response_message(event,
                                                  "Most recent hashtags:",
                                                  printable_hashtags,
                                                  ranking_hashtags_text)
Esempio n. 13
0
 def retrieve(user_id, user_storage_handler: UserStorageHandler):
     user = user_storage_handler.get(user_id)
     return UserFormatter(user)
Esempio n. 14
0
 def get_response_show(self, event, replied_message):
     message = self.__get_message(event, replied_message)
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     return message.printable_full_message(user_storage_handler)
Esempio n. 15
0
 def get_response_show(self, event, voices, message_id):
     voice = voices.get(message_id)
     if voice is None:
         return Message.create("No such audio with that message_id.")
     user_storage_handler = UserStorageHandler.get_instance(self.state)
     return voice.full_printable_version(user_storage_handler)
 def __init__(self, config: Config, state: State):
     """
     :param state: Used to resolve chat ids to names
     """
     self.config = config
     self.user_storage_handler = UserStorageHandler.get_instance(state)