Убрана очистка исключенных участников при запуске.
This commit is contained in:
parent
b11b3ab16d
commit
ac55d8700c
1 changed files with 1 additions and 24 deletions
25
tasks.py
25
tasks.py
|
|
@ -2,7 +2,7 @@ import datetime
|
|||
import traceback
|
||||
|
||||
from asyncio import sleep
|
||||
from vkbottle import API, bold, VKAPIError
|
||||
from vkbottle import API, bold
|
||||
|
||||
import database
|
||||
from handlers.user import format_rating
|
||||
|
|
@ -99,29 +99,6 @@ async def daily_maintenance_task(api: API):
|
|||
target_datetime = target_datetime + datetime.timedelta(days=1)
|
||||
|
||||
|
||||
async def cleanup_users(api: API):
|
||||
for chat in database.DB.get_chats():
|
||||
chat_id = chat['id']
|
||||
try:
|
||||
members = await api.messages.get_conversation_members(peer_id=chat_id, extended=False)
|
||||
except VKAPIError as e:
|
||||
continue
|
||||
|
||||
for user in database.DB.get_users(chat_id):
|
||||
user_id = user['user_id']
|
||||
found = False
|
||||
for profile in members.profiles:
|
||||
if profile.id == user_id:
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
database.DB.delete_user(chat_id, user_id)
|
||||
print(f'Удален пользователь id={user_id}')
|
||||
|
||||
|
||||
async def startup_task(api: API):
|
||||
me = (await api.groups.get_by_id()).groups[0]
|
||||
print(f"Бот '{me.name}' (id={me.id}) запущен.")
|
||||
|
||||
await cleanup_users(api)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue