-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update to v4 #62
base: master
Are you sure you want to change the base?
Update to v4 #62
Conversation
alcortazzo
commented
Aug 12, 2023
•
edited
Loading
edited
- Implemented the ability to run multiple bots with a single script
- Made bot compatible with aiogram v3+
…with one script (#46)
… behavior when the bot cannot receive posts from VK. Now the bot does not stop after a bad response from VK.
Fix vk links matching
Добрый день. Возможно ли исправить: |
Беглым взглядом глянул - Какая версия у вас Python и aiogram? |
Я запускаю через докер. Git Clone и docker-compose. Ну и подредактировал конфиг файл (поставил свои ID куда нужно)
|
Добрый день. Я рассматриваю сейчас форк - https://github.com/Atronar/alcortazzo-vktgbot. Не знаю куда там написать. Напишу сюда. Ситуация такая: я прописываю в файл last_known_id.txt номер последнего сообщения в группе. Далее в группе еще появляются, например, 5 постов новых. Скрипт кидает их в телегу. Все как нужно. Просто супер. Но! если я перезапускаю контейнер, то он поновой этиже 5 новых сообщений кидает. Опять начинает с того же номера, которого я прописывал в файл. Хотя я смотрю. что вроде как реализовано, чтобы записывал новый номер сообщения в файл и начинал с него. Но у меня почему то не отрабатывает данный функционал (( Помогите! |
Спасибо за багрепорт. Сейчас проверил - действительно, aiogram на новых версиях выдает ошибку. Что касается проблемы с файлом last_known_id.txt - у меня таких проблем не наблюдается и не наблюдалось. Подозреваю, что проблема в изменениях в форке. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use for
instead of while
; use else
instead of if
in loop body for consistency and readability
if num_tries > 5: | ||
logger.error(f"{config_name} - Post was not sent to Telegram. Too many tries.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if num_tries > 5: | |
logger.error(f"{config_name} - Post was not sent to Telegram. Too many tries.") | |
else: | |
logger.error(f"{config_name} - Post was not sent to Telegram. Too many tries.") |
num_tries = 1 | ||
while num_tries <= 5: | ||
num_tries += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num_tries = 1 | |
while num_tries <= 5: | |
num_tries += 1 | |
MAX_TRIES = 5 | |
for num_tries in range(1, MAX_TRIES + 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use constants instead of magic numbers where possible
photos (list): List of photos. | ||
docs (list): List of documents. | ||
config_name (str): Name of config. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
""" | |
RETRY_DELAY = 10 | |
BAD_REQUEST_DELAY = 60 |
f"{config_name} - Flood limit is exceeded. Sleep {ex.retry_after + 10} seconds. Try: {num_tries - 1}." | ||
) | ||
await asyncio.sleep(ex.retry_after + 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"{config_name} - Flood limit is exceeded. Sleep {ex.retry_after + 10} seconds. Try: {num_tries - 1}." | |
) | |
await asyncio.sleep(ex.retry_after + 10) | |
f"{config_name} - Flood limit is exceeded. Sleep {ex.retry_after + RETRY_DELAY} seconds. Try: {num_tries - 1}." | |
) | |
await asyncio.sleep(ex.retry_after + RETRY_DELAY) |
logger.warning(f"{config_name} - Bad request. Wait 60 seconds. Try: {num_tries}. {ex}") | ||
await asyncio.sleep(60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.warning(f"{config_name} - Bad request. Wait 60 seconds. Try: {num_tries}. {ex}") | |
await asyncio.sleep(60) | |
logger.warning(f"{config_name} - Bad request. Wait {BAD_REQUEST_DELAY} seconds. Try: {num_tries}. {ex}") | |
await asyncio.sleep(BAD_REQUEST_DELAY) |