Added oop task#9
Open
ibragimovaamina wants to merge 2 commits into
Open
Conversation
added 2 commits
February 24, 2023 14:20
krglkvrmn
suggested changes
Mar 17, 2023
Comment on lines
+15
to
+18
| if start is None: | ||
| start = self.default_start | ||
| if end is None: | ||
| end = datetime.now() |
There was a problem hiding this comment.
Я бы лучше использовал время первого и последних сообщений в качестве дефолтных дат, тем более, что их просто получить
Suggested change
| if start is None: | |
| start = self.default_start | |
| if end is None: | |
| end = datetime.now() | |
| if start is None: | |
| start = self._chat_history[-1].datetime | |
| if end is None: | |
| end = self._chat_history[0].datetime |
Comment on lines
+22
to
+24
| for message in self._chat_history: | ||
| if self.end >= message.datetime >= self.start: | ||
| print(message.show()) |
Comment on lines
+30
to
+32
| if isinstance(message, Message): | ||
| message.datetime = datetime.now() # Set attribute datetime when message is recieved by chat | ||
| self._chat_history.insert(0, message) |
There was a problem hiding this comment.
В таких случаях лучше писать else в котором кидать исключение, так как юзер может получить None, передав не тот тип, и потом будет гадать, что пошло не так
Suggested change
| if isinstance(message, Message): | |
| message.datetime = datetime.now() # Set attribute datetime when message is recieved by chat | |
| self._chat_history.insert(0, message) | |
| if isinstance(message, Message): | |
| message.datetime = datetime.now() # Set attribute datetime when message is recieved by chat | |
| self._chat_history.insert(0, message) | |
| else: | |
| raise TypeError(f"Method does not support type {type(message)}") |
Comment on lines
+41
to
+45
| def show(self): | ||
| if self.datetime: | ||
| return f'{self.datetime} {self.user}: {self.text}' | ||
| else: | ||
| return f'{self.user}: {self.text}' |
There was a problem hiding this comment.
Обычно функции, которые имеют в названии show, не возвращают, а показывают данные
Suggested change
| def show(self): | |
| if self.datetime: | |
| return f'{self.datetime} {self.user}: {self.text}' | |
| else: | |
| return f'{self.user}: {self.text}' | |
| def show(self): | |
| if self.datetime: | |
| print(f'{self.datetime} {self.user}: {self.text}') | |
| else: | |
| print(f'{self.user}: {self.text}') |
Comment on lines
+48
to
+49
| if isinstance(chat, Chat): | ||
| chat._recieve(self) |
There was a problem hiding this comment.
Аналогично предыдущему, но подход через такое взаимодействие send и recieve хороший
|
|
||
|
|
||
| class User: | ||
| all_users = [] # List of all objects of class User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.