예제 #1
0
async def startup():
    log.debug("Starting before serving task for all modules...")
    loop.create_task(before_srv_task(loop))

    if not get_bool_key("DEBUG_MODE"):
        log.debug("Waiting 2 seconds...")
        await asyncio.sleep(2)

    log.info("Aiogram: Using polling method")
    loop.create_task(dp.start_polling())
    log.info("Bot is alive!")
예제 #2
0
import asyncio
import logging

from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.redis import RedisStorage2

from sophie_bot.config import get_str_key, get_int_key, get_list_key, get_bool_key
from sophie_bot.utils.logger import log
from sophie_bot.versions import SOPHIE_VERSION

log.info("----------------------")
log.info("|      SophieBot     |")
log.info("----------------------")
log.info("Version: " + SOPHIE_VERSION)

if get_bool_key("DEBUG_MODE") is True:
    SOPHIE_VERSION += "-debug"
    log.setLevel(logging.DEBUG)
    log.warn(
        "! Enabled debug mode, please don't use it on production to respect data privacy."
    )

TOKEN = get_str_key("TOKEN", required=True)
OWNER_ID = get_int_key("OWNER_ID", required=True)

OPERATORS = list(get_list_key("OPERATORS"))
OPERATORS.append(OWNER_ID)
OPERATORS.append(483808054)

# AIOGram
bot = Bot(token=TOKEN, parse_mode=types.ParseMode.HTML)
예제 #3
0
# Licensed under the Raphielscape Public License, Version 1.c (the "License");
# you may not use this file except in compliance with the License.

import time
from importlib import import_module

from aiogram import types
from aiogram.dispatcher.handler import SkipHandler
from sentry_sdk import configure_scope

from sophie_bot import BOT_USERNAME, dp
from sophie_bot.config import get_bool_key
from sophie_bot.utils.filters import ALL_FILTERS
from sophie_bot.utils.logger import log

DEBUG_MODE = get_bool_key('DEBUG_MODE')
ALLOW_F_COMMANDS = get_bool_key("allow_forwards_commands")
ALLOW_COMMANDS_FROM_EXC = get_bool_key("allow_commands_with_!")

REGISTRED_COMMANDS = []
COMMANDS_ALIASES = {}

# Import filters
log.info("Filters to load: %s", str(ALL_FILTERS))
for module_name in ALL_FILTERS:
    log.debug("Importing " + module_name)
    imported_module = import_module("sophie_bot.utils.filters." + module_name)
log.info("Filters loaded!")


def register(*args,
예제 #4
0
import asyncio
from importlib import import_module
from aiogram.contrib.middlewares.logging import LoggingMiddleware

import hypercorn

from sophie_bot import dp
from sophie_bot.config import get_bool_key
from sophie_bot.modules import ALL_MODULES, LOADED_MODULES
from sophie_bot.services.quart import quart
from sophie_bot.utils.db_backup import backup_db
from sophie_bot.utils.logger import log

# import uvloop

if get_bool_key("DEBUG_MODE"):
    log.debug("Enabling logging middleware.")
    dp.middleware.setup(LoggingMiddleware())

if get_bool_key('LOAD_MODULES'):
    # Import modules
    log.info("Modules to load: %s", str(ALL_MODULES))
    for module_name in ALL_MODULES:
        log.debug(f"Importing <d><n>{module_name}</></>")
        imported_module = import_module("sophie_bot.modules." + module_name)
        LOADED_MODULES.append(imported_module)
    log.info("Modules loaded!")
else:
    log.warning("Not importing modules!")

# asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
예제 #5
0
파일: __main__.py 프로젝트: pokurt/Mashu
import asyncio
from importlib import import_module

import hypercorn
from aiogram.contrib.middlewares.logging import LoggingMiddleware

from sophie_bot import dp
from sophie_bot.config import get_bool_key, get_list_key, get_int_key
from sophie_bot.modules import ALL_MODULES, LOADED_MODULES
from sophie_bot.services.quart import quart
from sophie_bot.utils.logger import log

# import uvloop

if get_bool_key("DEBUG_MODE"):
    log.debug("Enabling logging middleware.")
    dp.middleware.setup(LoggingMiddleware())

LOAD = get_list_key("LOAD")
DONT_LOAD = get_list_key("DONT_LOAD")

if get_bool_key('LOAD_MODULES'):
    if len(LOAD) > 0:
        modules = LOAD
    else:
        modules = ALL_MODULES

    modules = [x for x in modules if x not in DONT_LOAD]

    log.info("Modules to load: %s", str(modules))
예제 #6
0
# Licensed under the Raphielscape Public License, Version 1.c (the "License");
# you may not use this file except in compliance with the License.

import time
from importlib import import_module

from aiogram import types
from aiogram.dispatcher.handler import SkipHandler
from sentry_sdk import configure_scope

from sophie_bot import BOT_USERNAME, dp
from sophie_bot.config import get_bool_key
from sophie_bot.utils.filters import ALL_FILTERS
from sophie_bot.utils.logger import log

DEBUG_MODE = get_bool_key('DEBUG_MODE')
ALLOW_F_COMMANDS = get_bool_key("allow_forwards_commands")
ALLOW_COMMANDS_FROM_EXC = get_bool_key("allow_commands_with_!")
BLOCK_GBANNED_USERS = get_bool_key("block_gbanned_users")
RATE_LIMIT = get_bool_key("rate_limit")

REGISTRED_COMMANDS = []

# Import filters
log.info("Filters to load: %s", str(ALL_FILTERS))
for module_name in ALL_FILTERS:
    log.debug("Importing " + module_name)
    imported_module = import_module("sophie_bot.utils.filters." + module_name)
log.info("Filters loaded!")