This commit is contained in:
Simple_Not 2024-01-23 15:29:34 +10:00
parent ee27dbfd7b
commit 53bac66692
2 changed files with 12 additions and 11 deletions

View File

@ -18,7 +18,7 @@ def append_post_to_cleaning_sequence(message, type=None):
print(e2)
def get_posts_to_be_removed(chat_id, type=None):
def get_posts_to_be_removed(chat_id, type=None, max_id=None):
# собираем
try:
#posts = [p for p in collections.get_posts_removal_collection().all( ) ]
@ -36,7 +36,9 @@ def get_posts_to_be_removed(chat_id, type=None):
if timediff > 60:
posts_ret.append(p)
print(posts_ret)
if max_id:
posts_ret = [ p for p in posts_ret if p['msg_id'] != max_id)]
else:
posts_ret = [ p for p in posts_ret if p['msg_id'] != max([pp['msg_id'] for pp in posts_ret])]
### оставлять последний пост

View File

@ -22,7 +22,7 @@ async def up_dick(message: types.Message):
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__DICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__DICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__DICK', max_id=message.message_id)
#### TODO уплатить нолог с 100 см для самого нищего
@ -54,7 +54,7 @@ async def up_dick(message: types.Message):
user_stuff.update_attempts( message, user)
postcleaner.append_post_to_cleaning_sequence(message=mmm, type='ALREADY_ROLLED')
await clean_posts(chat_id=mmm.chat.id, type='ALREADY_ROLLED')
await clean_posts(chat_id=mmm.chat.id, type='ALREADY_ROLLED', max_id=mmm.message_id)
else:
## если нету, то создать
user_stuff.store_new_user(message, result)
@ -83,11 +83,11 @@ async def send_topchat(message: types.Message):
if top_:
dickos = tops.get_tops( top_ = True, chat_id=message.chat.id )
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__TOPDICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__TOPDICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__TOPDICK', max_id=message.message_id)
elif glob_:
dickos = tops.get_tops( glob_ = True )
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__GLOBALDICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__GLOBALDICK')
await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__GLOBALDICK', max_id=message.message_id)
else:
print('вызывают хз что!')
@ -104,9 +104,8 @@ async def send_topchat(message: types.Message):
'Вы можете посмотреть топ по миру /globaldick')
async def clean_posts(chat_id, type=None):
psts = postcleaner.get_posts_to_be_removed(chat_id, type)
print(psts)
async def clean_posts(chat_id, type=None, max_id=None):
psts = postcleaner.get_posts_to_be_removed(chat_id, type, max_id)
for p in psts:
postcleaner.del_post(chat_id=p['chat_id'], msg_id=p['msg_id'])