Example #1
0
 def __add_grouped_pole(self, text, grouped_pole):
     user_id, count = grouped_pole
     formatted_user = UserFormatter.retrieve_and_format(
         user_id, self.user_storage_handler)
     formatted_grouped_pole = FormattedText().normal(text).start_format()\
         .bold(user=formatted_user).normal(pole_count=count).end_format()
     self.printable_poles.append(formatted_grouped_pole)
 def printable_version(self, user_storage_handler):
     formatted_date = DateFormatter.format(
         self.date) if self.date != -1 else "???"
     formatted_user = UserFormatter.retrieve_and_format(
         self.user_id,
         user_storage_handler) if self.user_id is not None else "???"
     return "%s  (%s by %s)" % (self.hashtag, formatted_date,
                                formatted_user)
Example #3
0
 def printable_version(self, event, user_storage_handler, index):
     formatted_user = UserFormatter.retrieve_and_format(
         self.user_id, user_storage_handler)
     formatted_date = DateFormatter.format(self.date)
     view_pole_command = UnderscoredCommandBuilder.build_command(
         event.command, str(index + 1))
     return _("{date} β†’ {user} β†’ {view_pole_command}")\
         .format(date=formatted_date, user=formatted_user, view_pole_command=view_pole_command)
Example #4
0
 def __log_command_execution(event, elapsed_seconds: float):
     event.logger.log(
         COMMAND_LOG_TAG,
         FormattedText().normal("{command} {args}").start_format().bold(
             command=event.command, args=event.command_args).end_format(),
         FormattedText().normal("User: {user}").start_format().bold(
             user=UserFormatter(
                 event.message.from_).full_data).end_format(),
         FormattedText().normal("Chat: {chat}").start_format().bold(
             chat=ChatFormatter(event.chat).full_data).end_format(),
         FormattedText().normal("Execution time: {time}").start_format().
         bold(time=TimeFormatter.format(elapsed_seconds)).end_format())
 def __log_throttling(event, remaining_seconds):
     event.logger.log(
         LOG_TAG,
         FormattedText().normal("{command} {args}").start_format().bold(
             command=event.command, args=event.command_args).end_format(),
         FormattedText().normal("User: {user}").start_format().bold(
             user=UserFormatter(
                 event.message.from_).full_data).end_format(),
         FormattedText().normal("Chat: {chat}").start_format().bold(
             chat=ChatFormatter(event.chat).full_data).end_format(),
         FormattedText().normal("Throttling for {seconds} seconds.").
         start_format().bold(seconds=remaining_seconds).end_format())
 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)
Example #7
0
 def full_printable_version(self, user_storage_handler):
     formatted_user = UserFormatter.retrieve_and_format(
         self.user_id, user_storage_handler)
     formatted_date = DateFormatter.format_full(self.date)
     formatted_duration = TimeFormatter.format(self.duration)
     formatted_size = SizeFormatter.format(self.file_size)
     text = "\U0001f446 That is the audio with id: {}\n\n".format(
         self.message_id)
     text += "Author: {}\n".format(formatted_user)
     text += "Sent at: {}\n".format(formatted_date)
     text += "Duration: {}\n".format(formatted_duration)
     text += "Size: {}".format(formatted_size)
     return Message.create(text).reply_to_message(
         message_id=self.message_id)
Example #8
0
 def printable_version(self, event, user_storage_handler, format_string):
     format_dict = {
         "formatted_user":
         UserFormatter.retrieve_and_format(self.user_id,
                                           user_storage_handler),
         "formatted_date":
         DateFormatter.format(self.date),
         "formatted_duration":
         TimeFormatter.format(self.duration),
         "formatted_size":
         SizeFormatter.format(self.file_size),
         "formatted_command":
         UnderscoredCommandBuilder.build_command(event.command,
                                                 self.message_id),
     }
     return format_string.format(**format_dict)
 def __format_user(self, user: ApiObject):
     full_data = UserFormatter(user).full_data
     first_name = self._text(user.first_name)
     last_name = self._text(user.last_name)
     username = self._username(user.username)
     _id = user.id
     language_code = self._text(user.language_code)
     is_bot = self._yes_no(user.is_bot,
                           yes_emoji="(🀖)",
                           no_emoji="(Γ°ΕΈβ€˜Β€)")
     self._add_title(full_data)
     self._add_empty()
     self._add_info("First name", first_name)
     self._add_info("Last name", last_name)
     self._add_info("Username", username)
     self._add_info("Id", _id)
     self._add_info("Language code", language_code)
     self._add_info("Is bot", is_bot, separator="?")
Example #10
0
 def printable_version(self, user_storage_handler, formatter=lambda x: x):
     return "\n".join(("{} β†’ {}".format(
         formatter(count),
         UserFormatter.retrieve_and_format(user_id, user_storage_handler))
                       for user_id, count in self.grouped_voices))
Example #11
0
 def _user(self, user: ApiObject, label: str = "From"):
     return FormattedText().normal("{label}: {user}").start_format()\
         .normal(label=label).bold(user=UserFormatter(user).full_data).end_format()
 def _user_formatter(self, user_id):
     return UserFormatter.retrieve(user_id, self.user_storage_handler)
 def printable_version(self, user_storage_handler):
     return "\n".join(
         ("%s β†’ %s" %
          (count,
           UserFormatter.retrieve_and_format(user_id, user_storage_handler))
          for user_id, count in self.grouped_users if user_id is not None))
 def printable_info(self, user_storage_handler):
     return FormattedText().normal("\n".join(
         ("%s β†’ %s" %
          (count,
           UserFormatter.retrieve_and_format(user_id, user_storage_handler))
          for user_id, count in self.grouped_messages)))