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

Upd tg-bot to v20 #8

Merged
merged 5 commits into from
Jul 6, 2023
Merged

Upd tg-bot to v20 #8

merged 5 commits into from
Jul 6, 2023

Conversation

da-maltsev
Copy link
Collaborator

@da-maltsev da-maltsev commented Jul 6, 2023

Обновил версию библиотеки для бота до актуальной + перенес конфиги к pyproject.toml (#7)

Саму логику нигде никак не менял. Все изменения какие есть - только в следствие изменения апи библиотек на совместимые. После обновления затестил бота - работает так же как и до этого, ничего не сломалось.

@da-maltsev da-maltsev added the enhancement New feature or request label Jul 6, 2023
@da-maltsev da-maltsev self-assigned this Jul 6, 2023
@da-maltsev da-maltsev requested a review from f213 July 6, 2023 06:42
bot.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
filters.py Outdated
@@ -11,7 +11,7 @@ class HasNoValidPreviousMessages(MessageFilter):
MIN_PREVIOUS_MESSAGES_COUNT = 3

def filter(self, message: Message) -> bool:
if not DB_ENABLED():
if not DB_ENABLED() or not message.from_user:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А в каких случаях у сообщения может не быть from_user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут и ниже где проверка if message - в библиотеке обновились немного типы, и теперь from_user стал Optional и update.message/edited_message тоже Optional. Mypy это подсветил и я добавил доп проверки

bot.py Show resolved Hide resolved
bot.py Outdated
message_id=message.message_id,
chat_id=message.chat_id,
)
if message:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А в каких случаях message может быть False?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я тут просто на наличие проверяю переменую. Критично ли писать так, а не is not None?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мой вопрос был в том, в каких случаях этой переменной может не быть и почему?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А, ну тут может быть вполне, что в Update пришло не сообщение, а что-то из channel_post, poll, poll_answer etc

@da-maltsev da-maltsev requested a review from f213 July 6, 2023 08:18
bot.py Outdated
@@ -33,7 +23,6 @@ def log_message(message: Message, action: Optional[str] = ''):
text=message.text or '',
meta={
'tags': [
*rekognition.get_labels(image_url=get_profile_picture(message)),
*text.Labels(message.text)(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Конструкция [*text.Labels(message.text)()] стала выглядеть довольно странно. Почему бы не сделать просто text.Labels(message.text)()?

@da-maltsev da-maltsev merged commit 5662ff8 into master Jul 6, 2023
@da-maltsev da-maltsev deleted the tg-bot-20 branch July 6, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants