Advertisement
UniQuet0p1

Untitled

Oct 7th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.51 KB | None | 0 0
  1. """Messenger."""
  2.  
  3. class User:
  4.     """User class."""
  5.  
  6.     def __init__(self, name):
  7.         """
  8.        User constructor.
  9.  
  10.        :param name: Name of the user.
  11.        """
  12.         self.name = name
  13.  
  14.  
  15. class Chat:
  16.     """Chat class."""
  17.  
  18.     def __init__(self, name, users):
  19.         """
  20.        Chat constructor.
  21.  
  22.        :param name: Name of the chat.
  23.        :param users: Users in the chat.
  24.        """
  25.         self.name = name
  26.         self.users = users
  27.         self.messages = []
  28.  
  29.  
  30. class Message:
  31.     """Message class."""
  32.  
  33.     def __init__(self, user, content):
  34.         """
  35.        Message constructor.
  36.  
  37.        :param user: Author of the message.
  38.        :param content: Content of the message.
  39.        """
  40.         self.user = user
  41.         self.content = content
  42.         self.reactions = 0
  43.  
  44.  
  45. def write_message(user: User, chat: Chat, content: str) -> None:
  46.     """
  47.    Write a message to given chat.
  48.  
  49.    Create a message with given values and then add it to the chat's messages.
  50.  
  51.    :param user: Author of the message.
  52.    :param chat: Chat to write the message to.
  53.    :param content: Content of the message.
  54.    """
  55.     pass
  56.  
  57.  
  58. def delete_message(chat: Chat, message: Message) -> None:
  59.     """
  60.    Delete message from chat.
  61.  
  62.    :param chat: Chat to delete message from.
  63.    :param message: Message to delete from chat.
  64.    """
  65.     pass
  66.  
  67.  
  68. def get_messages_by_user(user: User, chat: Chat) -> list:
  69.     """
  70.    Get messages by user in chat.
  71.  
  72.    :param user: User whose messages to get.
  73.    :param chat: Chat from where to get user's messages.
  74.    :return: A list of messages.
  75.    """
  76.     pass
  77.  
  78.  
  79. def react_to_last_message(chat: Chat) -> None:
  80.     """
  81.    Add reaction to last message in chat.
  82.  
  83.    :param chat: Chat in which the message is.
  84.    """
  85.     pass
  86.  
  87.  
  88. def find_most_reacted_message(chat: Chat) -> Message:
  89.     """
  90.    Find the most reacted message in chat.
  91.  
  92.    :param chat: Chat to get the message from.
  93.    :return: Most reacted message.
  94.    """
  95.     pass
  96.  
  97.  
  98. def count_reactions_in_chat(chat: Chat) -> int:
  99.     """
  100.    Count all reactions in chat.
  101.  
  102.    :param chat: Said chat.
  103.    :return: The amount of reactions.
  104.    """
  105.     pass
  106.  
  107.  
  108. def count_reactions_by_chat(chats: list) -> dict:
  109.     """
  110.    Count reactions in every chat.
  111.  
  112.    The function should return a dict where the key is the name of a chat and the value is the amount of reactions.
  113.  
  114.    :param chats: The chats in question.
  115.    :return: A dictionary as described.
  116.    """
  117.     pass
  118.  
  119.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement