mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-22 23:21:28 +00:00
Compare commits
3 commits
e782cacf5a
...
a949ecd9b6
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | a949ecd9b6 | ||
localhost_frssoft | 8e3253fd50 | ||
localhost_frssoft | 4d02fde9aa |
|
@ -13,5 +13,5 @@ max_fail_limit = 4 # Игнорировать предложения польз
|
|||
hour_poll_posting = 16 # Час в который будет создан пост с голосовалкой (и завершение сбора)
|
||||
fmn_next_watching_hour = 21 # Час начала киносеанса
|
||||
|
||||
logger_default_level = 10 # Уровень логгирования 10 - DEBUG, 20 - INFO, 30 - WARN
|
||||
logger_default_level = 'DEBUG' # Уровень логгирования TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from src import listener_context, listener_mention, imdb_datasets_worker
|
||||
from config import logger_default_level
|
||||
import logging
|
||||
from loguru import logger
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logger_default_level)
|
||||
logger.remove()
|
||||
logger.add(sink=sys.stderr, level=logger_default_level)
|
||||
|
||||
listener_mention.run_scan_notif() # Слушаем упоминания в фоне
|
||||
time.sleep(1)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
loguru
|
||||
requests
|
||||
python-dateutil
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@ from config import instance
|
|||
import time
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('fedi_api')
|
||||
from loguru import logger
|
||||
|
||||
instance_point = f"https://{instance}/api/v1"
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import sqlite3
|
||||
import logging
|
||||
from loguru import logger
|
||||
from config import limit_movies_per_user
|
||||
|
||||
|
||||
logger = logging.getLogger('fmn_db')
|
||||
|
||||
conn = sqlite3.connect("fmn.sqlite")
|
||||
c = conn.cursor()
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@ from src.fedi_api import get_status, post_status, upload_attachment
|
|||
from src.fmn_states_db import add_state, get_state, clear_all_states
|
||||
from src.fmn_database import get_movies_for_poll, write_votes, read_votes, mark_as_watched_movie, get_already_watched, rewrite_db, reset_poll
|
||||
from collections import Counter
|
||||
import logging
|
||||
from loguru import logger
|
||||
import time
|
||||
|
||||
logger = logging.getLogger('fmn_poll')
|
||||
|
||||
text_create_poll = '''Друзья, голосование за следующий Fediverse Movie Night объявляю открытым!
|
||||
|
||||
|
@ -29,7 +28,7 @@ def create_poll_movies(text=text_create_poll, poll_expires=345600):
|
|||
formated_poll_options.append(poll_option_string)
|
||||
poll_status_id = post_status(text, None, formated_poll_options,
|
||||
poll_expires=poll_expires, attachments=[upload_attachment('src/FMN.png')])
|
||||
logger.info('Голосовалка создана')
|
||||
logger.success('Голосовалка создана')
|
||||
add_state('poll_expires_at', int(time.time()) + poll_expires)
|
||||
add_state('poll_status_id', poll_status_id['id'])
|
||||
return poll_status_id
|
||||
|
@ -77,7 +76,7 @@ def get_winner_movie(poll_status_id=str):
|
|||
{win_variant}
|
||||
'''.replace('\t', '')
|
||||
|
||||
logger.warning("Победил " + str(movie))
|
||||
logger.success("Победил " + str(movie))
|
||||
post_status(text_winned, attachments=[upload_attachment('src/FMN.png')])
|
||||
clear_all_states()
|
||||
reset_poll()
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import sqlite3
|
||||
import logging
|
||||
from loguru import logger
|
||||
|
||||
|
||||
logger = logging.getLogger('fmn_states_database')
|
||||
|
||||
conn = sqlite3.connect("fmn_states.sqlite", check_same_thread=False)
|
||||
c = conn.cursor()
|
||||
|
||||
|
@ -23,7 +21,7 @@ def add_state(key, value):
|
|||
|
||||
def get_state(key):
|
||||
'''Получение стейта по ключу'''
|
||||
logger.debug(f'Запрошен стейт {key}')
|
||||
logger.trace(f'Запрошен стейт {key}')
|
||||
value = c.execute("SELECT value FROM states WHERE key = (?)", (key,)).fetchone()
|
||||
if value:
|
||||
return value[0]
|
||||
|
|
|
@ -84,20 +84,14 @@ def convert_datasets_to_db():
|
|||
|
||||
|
||||
def get_title_by_id(films_ids=list):
|
||||
tt_list = []
|
||||
for i in films_ids:
|
||||
tt_film = c.execute("SELECT * FROM titles WHERE tt_id = (?)", (i,)).fetchone()
|
||||
tt_list.append(tt_film)
|
||||
tt_list = c.executemany("SELECT * FROM titles WHERE tt_id = (?)", films_ids).fetchall()
|
||||
if tt_list != []:
|
||||
return tt_list
|
||||
|
||||
|
||||
def get_title_by_names_and_year(film_names=list):
|
||||
tt_list = []
|
||||
for i in film_names:
|
||||
tt_film = c.execute('''SELECT * FROM titles
|
||||
tt_list = c.executemany('''SELECT * FROM titles
|
||||
WHERE (original_name = (?) OR ru_name = (?))
|
||||
AND year = (?)''', i).fetchone()
|
||||
if tt_film:
|
||||
tt_list.append(tt_film)
|
||||
AND year = (?)''', film_names).fetchall()
|
||||
if tt_list != []:
|
||||
return tt_list
|
||||
|
|
|
@ -5,16 +5,13 @@ from src.imdb_datasets_worker import get_title_by_id
|
|||
from src.fmn_database import add_movie_to_poll, get_already_watched, get_suggested_movies_count
|
||||
from src.fmn_states_db import get_state, add_state
|
||||
from src.fmn_poll import create_poll_movies, get_winner_movie
|
||||
import re
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.parser import parse as dateutilparse
|
||||
from dateutil.relativedelta import relativedelta, TU
|
||||
from collections import Counter
|
||||
import re
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger('thread_listener')
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def parse_links(text=str):
|
||||
|
@ -149,7 +146,7 @@ def scan_context_thread():
|
|||
add_result = add_movie_to_poll(acct, name, name_ru, year)
|
||||
if add_result == 0:
|
||||
message_writer.append(f"✅ Принято: {movie_string}")
|
||||
logger.info(f'Предложение от {acct} принято: {name} {name_ru} {year}')
|
||||
logger.success(f'Предложение от {acct} принято: {name} {name_ru} {year}')
|
||||
success = True
|
||||
elif add_result == 1:
|
||||
message_writer.append("❌ Этот фильм уже был предложен")
|
||||
|
|
Loading…
Reference in a new issue