#10 теперь логгируется
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simple_Not 2024-01-24 14:09:31 +10:00
parent 4a3f799284
commit 66c2ef80c3
6 changed files with 40 additions and 32 deletions

4
bot.py
View File

@ -2,7 +2,7 @@ import logging
from aiogram import executor, Bot, Dispatcher from aiogram import executor, Bot, Dispatcher
from create_bot import dp from create_bot import dp
import handlers import handlers
import json import json, logging
from global_conf import CONFIG from global_conf import CONFIG
@ -40,7 +40,9 @@ logging.getLogger("aiogram").addFilter(filter_grammar_messages)
if __name__ == '__main__': if __name__ == '__main__':
#print(CONFIG) #print(CONFIG)
logging.info('Бот в строю.')
executor.start_polling(dp, skip_updates=True) executor.start_polling(dp, skip_updates=True)
logging.info('Всем пока.')

View File

@ -4,6 +4,8 @@ from global_conf import CONFIG
#### https://docs.python-arango.com/en/main/ #### https://docs.python-arango.com/en/main/
from arango import ArangoClient from arango import ArangoClient
import logging
def get_dicks_collection(): def get_dicks_collection():
@ -18,8 +20,8 @@ def get_dicks_collection():
return dicks_collection return dicks_collection
except Exception as e: except Exception as e:
print('ошибка DB при взятии коллекции пипис') logging.error('ошибка DB при взятии коллекции пипис')
print(e) logging.error(e)
def get_posts_removal_collection(): def get_posts_removal_collection():
@ -34,5 +36,5 @@ def get_posts_removal_collection():
return posts_removal_collection return posts_removal_collection
except Exception as e: except Exception as e:
print('ошибка DB при взятии коллекции постов-на-удаление') logging.error('ошибка DB при взятии коллекции постов-на-удаление')
print(e) logging.error(e)

View File

@ -1,5 +1,6 @@
from db_logic import collections from db_logic import collections
import datetime import datetime, logging
def append_post_to_cleaning_sequence(message, type=None): def append_post_to_cleaning_sequence(message, type=None):
@ -12,10 +13,10 @@ def append_post_to_cleaning_sequence(message, type=None):
} }
metadata = collections.get_posts_removal_collection().insert(novenkiy, overwrite_mode='update') metadata = collections.get_posts_removal_collection().insert(novenkiy, overwrite_mode='update')
print(f'Успешно добавлен пост на удаление') logging.debug('Успешно добавлен пост на удаление')
except Exception as e2: except Exception as e2:
print(f'ошибка DB :: добавление нового поста на удаление') logging.error('ошибка DB :: добавление нового поста на удаление')
print(e2) logging.error(e2)
def get_posts_to_be_removed(chat_id, type=None, max_id=None): def get_posts_to_be_removed(chat_id, type=None, max_id=None):
@ -46,8 +47,8 @@ def get_posts_to_be_removed(chat_id, type=None, max_id=None):
return posts_ret return posts_ret
except Exception as e: except Exception as e:
print('ошибка DB :: получение постов на удаление') logging.error('ошибка DB :: получение постов на удаление')
print(e) logging.error(e)
def del_post(msg_id, chat_id): def del_post(msg_id, chat_id):
@ -70,5 +71,5 @@ def del_post(msg_id, chat_id):
collections.get_posts_removal_collection().delete(pp) collections.get_posts_removal_collection().delete(pp)
except Exception as e: except Exception as e:
print('ошибка DB :: удаление поста на удаление') logging.error('ошибка DB :: удаление поста на удаление')
print(e) logging.error(e)

View File

@ -1,5 +1,6 @@
from global_conf import CONFIG from global_conf import CONFIG
from db_logic import collections from db_logic import collections
import logging
def get_tops(top_ = False, glob_ = False, chat_id = None): def get_tops(top_ = False, glob_ = False, chat_id = None):
@ -8,16 +9,16 @@ def get_tops(top_ = False, glob_ = False, chat_id = None):
try: try:
dicks = [d for d in collections.get_dicks_collection().find({'chat_id': chat_id}, skip=0, limit=1100)] dicks = [d for d in collections.get_dicks_collection().find({'chat_id': chat_id}, skip=0, limit=1100)]
except Exception as e: except Exception as e:
print('ошибка DB в /topdick') logging.error('ошибка DB в /topdick')
print(e) logging.error(e)
elif glob_: elif glob_:
try: try:
dicks = [d for d in collections.get_dicks_collection().all( ) if d['user_id'] != d['chat_id']] dicks = [d for d in collections.get_dicks_collection().all( ) if d['user_id'] != d['chat_id']]
except Exception as e: except Exception as e:
print('ошибка DB в /globaldick') logging.error('ошибка DB в /globaldick')
print(e) logging.error(e)
else: else:
print('вызывают хз что!') logging.error('вызывают хз что!')
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True) top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
top_dicks = top_dicks[:( min(len(top_dicks), 10) )] top_dicks = top_dicks[:( min(len(top_dicks), 10) )]

View File

@ -1,5 +1,5 @@
from db_logic import collections from db_logic import collections
import datetime import datetime, logging
def store_new_user(message, result ): def store_new_user(message, result ):
@ -15,10 +15,10 @@ def store_new_user(message, result ):
} }
metadata = collections.get_dicks_collection().insert(novenkiy, overwrite_mode='update') metadata = collections.get_dicks_collection().insert(novenkiy, overwrite_mode='update')
print(f'Успешно добавлен нового пользователь @{message.from_user.username}') logging.debug(f'Успешно добавлен нового пользователь @{message.from_user.username}')
except Exception as e2: except Exception as e2:
print(f'ошибка DB в /dick :: добавление нового пользователя @{message.from_user.username}') logging.error(f'ошибка DB в /dick :: добавление нового пользователя @{message.from_user.username}')
print(e2) logging.error(e2)
def update_attempts(message, user ): def update_attempts(message, user ):
@ -35,10 +35,11 @@ def update_attempts(message, user ):
}, },
overwrite_mode='update' overwrite_mode='update'
) )
print(f'Успешно апдейтнули попытку крутить пипису @{message.from_user.username}')
logging.debug(f'Успешно апдейтнули попытку крутить пипису @{message.from_user.username}')
except Exception as e2: except Exception as e2:
print(f'ошибка DB в /dick :: обновление попытки крутить пипису @{message.from_user.username}') logging.error(f'ошибка DB в /dick :: обновление попытки крутить пипису @{message.from_user.username}')
print(e2) logging.error(e2)
def update_dick_size(message, user, updatedDick ): def update_dick_size(message, user, updatedDick ):
@ -56,10 +57,11 @@ def update_dick_size(message, user, updatedDick ):
}, },
overwrite_mode='update' overwrite_mode='update'
) )
print(f'Успешно апдейтнули пипису @{message.from_user.username}')
logging.info(f'Успешно апдейтнули пипису @{message.from_user.username}')
except Exception as e2: except Exception as e2:
print(f'ошибка DB в /dick :: обновление пиписы @{message.from_user.username}') logging.error(f'ошибка DB в /dick :: обновление пиписы @{message.from_user.username}')
print(e2) logging.error(e2)
def get_user(message): def get_user(message):
@ -80,5 +82,5 @@ def get_user(message):
return user return user
except Exception as e: except Exception as e:
print('ошибка DB в /dick :: поиск юзера') logging.error('ошибка DB в /dick :: поиск юзера')
print(e) logging.error(e)

View File

@ -2,7 +2,7 @@ from aiogram import types
from create_bot import bot, dp from create_bot import bot, dp
import random import random
from random import randint from random import randint
import datetime import datetime, logging
from dicktxt import ForReadDict, WordsChange from dicktxt import ForReadDict, WordsChange
from pipisa_functions import pipisa_time from pipisa_functions import pipisa_time
@ -89,7 +89,7 @@ async def send_topchat(message: types.Message):
postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__GLOBALDICK') 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', max_id=message.message_id) await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__GLOBALDICK', max_id=message.message_id)
else: else:
print('вызывают хз что!') logging.error('вызывают хз что!')
if not dickos: if not dickos: