from api.server import trigger_api from executors.location import write_current_location from executors.logger import logger from executors.offline import automator, initiate_tunneling from executors.telegram import handler from modules.audio import speech_synthesis from modules.database import database from modules.models import models from modules.retry import retry from modules.utils import shared env = models.env fileio = models.FileIO() indicators = models.Indicators() db = database.Database(database=fileio.base_db) docker_container = speech_synthesis.SpeechSynthesizer() @retry.retry(attempts=3, interval=2, warn=True) def delete_db() -> NoReturn: """Delete base db if exists. Called upon restart or shut down.""" if os.path.isfile(fileio.base_db): logger.info(f"Removing {fileio.base_db}") os.remove(fileio.base_db) if os.path.isfile(fileio.base_db): raise FileExistsError(f"{fileio.base_db} still exists!") return def start_processes(
from vk_api.keyboard import VkKeyboard, VkKeyboardColor from vk_api.utils import get_random_id from vk_api.longpoll import VkLongPoll, VkEventType import modules.config as config import modules.database.database as database vk_session = vk_api.VkApi(token=config.token) longpoll = VkLongPoll(vk_session) vk = vk_session.get_api() user_vars = {} # Переменные пользователей last_user = -1 # Последний пользователь с кем взаимодействовал бот developer_id = 369071929 # Для отправления ошибок и т.п. db = database.Database() # Инициализация базы данных class Mode(Enum): """ Содержит список состояний пользователя """ menu = auto() repeat_cards = auto() manage_decks = auto() wait_subscribe_deck_id = auto() wait_share_deck_id = auto() wait_remove_deck_id = auto() wait_edit_deck_id = auto() edit_deck = auto() wait_remove_card_id = auto()
os.path.join('logs', 'speech_synthesis_%d-%m-%Y.log')) class Indicators(BaseModel): """Loads all the mp3 files' path required by Jarvis. >>> Indicators """ acknowledgement: FilePath = os.path.join('indicators', 'acknowledgement.mp3') alarm: FilePath = os.path.join('indicators', 'alarm.mp3') coin: FilePath = os.path.join('indicators', 'coin.mp3') end: FilePath = os.path.join('indicators', 'end.mp3') exhaust: FilePath = os.path.join('indicators', 'exhaust.mp3') initialize: FilePath = os.path.join('indicators', 'initialize.mp3') start: FilePath = os.path.join('indicators', 'start.mp3') tv_connect: FilePath = os.path.join('indicators', 'tv_connect.mp3') tv_scan: FilePath = os.path.join('indicators', 'tv_scan.mp3') # Create all necessary DB tables during startup db = database.Database(database=FileIO().base_db) db.create_table(table_name=env.event_app, columns=["info", "date"]) db.create_table(table_name="ics", columns=["info", "date"]) db.create_table(table_name="stopper", columns=["flag", "caller"]) db.create_table(table_name="restart", columns=["flag", "caller"]) db.create_table(table_name="children", columns=["meetings", "events"]) db.create_table(table_name="vpn", columns=["state"])
import json import sys from modules.audio import listener, speaker from modules.conditions import keywords from modules.database import database from modules.models import models from modules.utils import shared env = models.env fileio = models.FileIO() tdb = database.Database(database=fileio.task_db) tdb.create_table(table_name="tasks", columns=["category", "item"]) def todo() -> None: """Says the item and category stored in the to-do list.""" sys.stdout.write("\rQuerying DB for to-do list..") with tdb.connection: cursor = tdb.connection.cursor() downloaded = cursor.execute( "SELECT category, item FROM tasks").fetchall() result = {} for category, item in downloaded: # condition below makes sure one category can have multiple items without repeating category for each item if category not in result: result.update( {category: item} ) # creates dict for category and item if category is not found in result else: