Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread.IsOk fix + timestamp sorting(Ctrl+c Ctrl+v) #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion dvach.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def IsOk(self, KEY_WORDS: List[str]):
"""
if len(KEY_WORDS) != 0:
for word in KEY_WORDS:
if word in self.comment.lower():
if word.lower() in self.comment.lower():
return True # подходит если есть одно из ключевых слов
else:
return True # Подходит если ключевые слова не указаны.
Expand Down Expand Up @@ -296,6 +296,15 @@ def sort_threads_by_posts(self):
if self.threads[key_i].posts_count < self.threads[key_j].posts_count:
self.threads[key_i], self.threads[key_j] = self.threads[key_j], self.threads[key_i]

def sort_threads_by_timestamp(self):
""" Сортировка тредов по unix timestamp"""
for i in range(len(self.threads.keys())):
for j in range(i, len(self.threads.keys())):
key_i = list(self.threads.keys())[i]
key_j = list(self.threads.keys())[j]
if self.threads[key_i].timestamp > self.threads[key_j].timestamp:
self.threads[key_i], self.threads[key_j] = self.threads[key_j], self.threads[key_i]

def update_threads(self):
""" Скачать треды"""
self.threads = Board.from_json(Board.json_download(self.name)).threads
Expand Down