Exemple #1
0
def main():
    # 初始化配置信息
    init(config)
    # 载入插件
    load_plugins(path.join(path.dirname(__file__), 'plugins'), 'plugins')
    # 运行bot
    run()
Exemple #2
0
def run():
    nonebot.init(config)
    nonebot.load_builtin_plugins()
    nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                         'deltabot.plugins')

    nonebot.run()
Exemple #3
0
def init(config_object: Any) -> nb.NoneBot:
    if config_object and \
            hasattr(config_object, 'APSCHEDULER_CONFIG') and \
            getattr(config_object, 'DATABASE_URL', None):
        # configure none.scheduler
        if 'apscheduler.jobstores.default' not in \
                config_object.APSCHEDULER_CONFIG:
            # use config_object.DATABASE_URL as default job store
            config_object.APSCHEDULER_CONFIG[
                'apscheduler.jobstores.default'] = {
                    'type': 'sqlalchemy',
                    'url': config_object.DATABASE_URL,
                    'tablename': db.make_table_name('core', 'apscheduler_jobs')
                }

    nb.init(config_object)
    bot = nb.get_bot()

    if bot.config.DEBUG:
        logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)

    bot.server_app.before_serving(cache.init)
    bot.server_app.before_serving(db.init)

    nb.load_builtin_plugins()
    nb.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                    'aki.plugins')

    return bot
Exemple #4
0
def main():
    nonebot.init(config)
    nonebot.load_builtin_plugins()
    nonebot.load_plugins(
        os.path.join(os.path.dirname(__file__), 'bot', 'plugins'),
        'bot.plugins')
    nonebot.run()
Exemple #5
0
 def real_run():
     nonebot.init(config)
     nonebot.load_plugins(path.join(config.ROOT, 'nalomu', 'plugins'),
                          'nalomu.plugins')
     nonebot.load_builtin_plugins()
     init_http_api(nonebot.get_bot().server_app)
     nonebot.run()
Exemple #6
0
def init():
    nonebot.init(**RUNTIME_CONFIG)
    driver().register_adapter("cqhttp", ATRIBot)
    nonebot.load_plugins("ATRI/plugins")
    if RUNTIME_CONFIG["debug"]:
        nonebot.load_plugin("nonebot_plugin_test")
    logger.info(f"Now running: {__version__}")
    sleep(3)
Exemple #7
0
def init(config) -> nonebot.NoneBot:
    nonebot.init(config)
    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'plugins'),
        'madao.plugins'
    )
    bot = nonebot.get_bot()
    return bot
Exemple #8
0
def bot_init():
    nonebot.init()
    driver = nonebot.get_driver()
    driver.register_adapter("cqhttp", CQHTTPBot)

    # loading plugins
    nonebot.load_plugins('plugins')
    nonebot.get_asgi()
Exemple #9
0
 def run(self):
     nonebot.init(base)
     # 导入插件
     for plugin in base.PLUGINS:
         nonebot.load_plugins(
             path.join(path.dirname(__file__), 'beanBot', 'plugins', plugin),
             f'beanBot.plugins.{plugin}'
         )
     nonebot.run()
Exemple #10
0
def init(config) -> nonebot.NoneBot:
    nonebot.init(config)
    bot = nonebot.get_bot()

    for module_name in MODULES_ON:
        module_path = path.join(path.dirname(__file__), module_name)
        nonebot.load_plugins(module_path, f'Chloe.{module_name}')

    return bot
Exemple #11
0
    def run(self):
        nonebot.init(self._get_config())
        nonebot.load_builtin_plugins()
        nonebot.load_plugins(
            os.path.join(os.path.dirname(__file__), 'plugins'),
            'sapphirebot.plugins')

        self.bot = nonebot.get_bot()
        nonebot.run()
Exemple #12
0
def main():
    nonebot.init(command_start={'/', '!', "!"})
    driver = nonebot.get_driver()
    driver.register_adapter("cqhttp", CQHTTPBot)
    nonebot.load_plugin('nonebot_plugin_sentry')
    nonebot.load_plugins('epicteller/bot/plugin')
    nonebot.get_driver().on_startup(redis.pool.init)
    nonebot.get_driver().on_startup(bus_init)

    nonebot.run(host='0.0.0.0', port=10090)
Exemple #13
0
def main():
    nonebot.init(config)
    nonebot.log.logger.setLevel('INFO')

    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'awesome', 'plugins'),
        'awesome.plugins')

    logger.warning('Plugins successfully installed.')
    nonebot.run()
Exemple #14
0
def init() -> mikubot:
    global _bot
    nonebot.init(config)
    _bot = nonebot.get_bot()

    for module_name in config.MODULES_ON:
        nonebot.load_plugins(
            os.path.join(os.path.dirname(__file__), 'modules', module_name),
            f'miku.modules.{module_name}')
    return _bot
Exemple #15
0
def run():
    # toolmandir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
    # sys.path.append(toolmandir)
    toolmandir = os.path.dirname(os.path.abspath(__file__))
    sys.path.append(toolmandir)
    nonebot.init(config)
    # nonebot.load_builtin_plugins()
    nonebot.load_plugins(
        path.join(path.dirname(os.path.abspath(__file__)), 'plugins'),
        'plugins')
    nonebot.run(host='0.0.0.0', port=configJs['nonebotListen'])
Exemple #16
0
def init(config_object: Any) -> nb.NoneBot:
    nb.init(config_object)
    bot = nb.get_bot()

    # bot.server_app.before_serving(cache.init)
    # bot.server_app.before_serving(db.init)

    nb.load_builtin_plugins()
    nb.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                    'bot.plugins')

    return bot
Exemple #17
0
def run_nonebot():
    new_loop = asyncio.new_event_loop()
    asyncio.set_event_loop(new_loop)
    try:
        nonebot.init(config)
        nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                             'plugins')
        nonebot.run(host='127.0.0.1', port=8190)
    except:
        logger.critical('BOT状态异常')
        s = traceback.format_exc(limit=10)
        logger.critical(s)
        raise Exception(s)
Exemple #18
0
def run_nonebot(new_loop):
    asyncio.set_event_loop(new_loop)
    try:
        nonebot.init(config)
        nonebot.load_plugins(
            path.join(path.dirname(__file__), 'plugins'),
            'plugins'
        )
        nonebot.run(host='127.0.0.1', port = 8190)
    except:
        log_print(1,'BOT状态异常')
        s = traceback.format_exc(limit=10)
        log_print(2,s)
Exemple #19
0
def init(config) -> nonebot.NoneBot:

    nonebot.init(config)
    bot = nonebot.get_bot()

    logger.setLevel(logging.DEBUG if bot.config.DEBUG else logging.INFO)
    nonebot.logger.addHandler(error_handler)

    for module_name in config.MODULES_ON:
        nonebot.load_plugins(
            path.join(path.dirname(__file__), 'modules', module_name),
            f'hoshino.modules.{module_name}')

    return bot
Exemple #20
0
def init_bot() -> nb.NoneBot:
    config = load_config()
    nb.init(config)
    bot = nb.get_bot()

    nb.load_builtin_plugins()
    nb.load_plugins(path.join(path.dirname(__file__), "bot"), "app.bot")

    from .libs.gino import init_db
    from .libs.scheduler import init_scheduler

    bot.server_app.before_serving(init_db)
    bot.server_app.before_serving(init_scheduler)

    return bot
Exemple #21
0
def init(config) -> nonebot.NoneBot:
    nonebot.init(config)
    initLogConf()
    logging.getLogger('Azusa').info('<Init> Azusa initializes successfully.')
    bot = nonebot.get_bot()
    bot.config.resources = path.join(path.dirname(__file__), 'resources')
    import Azusa.common
    import Azusa.data
    for mod in config.LOAD_MODULES:
        if '.' in mod:
            t = sep.join(mod.split('.'))
        else:
            t = mod
        nonebot.load_plugins(path.join(path.dirname(__file__), 'modules', t),
                             f'Azusa.modules.{mod}')
    return bot
Exemple #22
0
def initApp() -> Quart:
    assert nonebot.scheduler  # Check if scheduler exists
    # Initialize logging
    loggingPath = os.path.join(LOG_FILE_DIR, "{time}.log")
    loguruHandler = _LoguruHandler()
    loguruLogger.add(loggingPath, enqueue=True, encoding="utf-8")
    botLogger.handlers.clear()
    botLogger.addHandler(loguruHandler)
    # Initialize settings
    nonebot.init(settings)
    nonebot.load_plugins("plugins", "plugins")
    nonebot.logger.debug(
        f"The robot is currently configured as: {convertSettingsToDict()}"
    )
    bot = nonebot.get_bot()
    bot.logger.handlers.clear()
    bot.logger.addHandler(_LoguruHandler())
    return bot.asgi
Exemple #23
0
def init() -> HoshinoBot:
    global _bot
    nonebot.init(config)
    _bot = nonebot.get_bot()
    _bot.finish = _finish

    from .log import error_handler, critical_handler
    nonebot.logger.addHandler(error_handler)
    nonebot.logger.addHandler(critical_handler)

    for module_name in config.MODULES_ON:
        nonebot.load_plugins(
            os.path.join(os.path.dirname(__file__), 'modules', module_name),
            f'hoshino.modules.{module_name}')

    from . import msghandler

    return _bot
Exemple #24
0
def init():
    seconds_offset = time.localtime().tm_gmtoff
    local_utc = _format_offset(seconds_offset)
    if local_utc != 'UTC+8':
        logger.warning('当前时区不是东8区,请修改到正确的时区后再运行本程序')
        os._exit(0)
    kwargs = {
        'superusers': config.SUPERUSERS,
        'nickname': config.NICKNAME,
        'command_start': config.COMMAND_START,
        'command_sep': config.COMMAND_SEP,
        'debug': config.DEBUG
    }
    nonebot.init(**kwargs)
    driver = nonebot.get_driver()
    driver.register_adapter('cqhttp', CQHTTPBot)

    config_ = driver.config
    config_.savedata = 'data/service'

    nonebot.load_builtin_plugins()
    nonebot.load_plugin("nonebot_plugin_apscheduler")
    nonebot.load_plugin('nonebot_plugin_rauthman')
    if config.DEBUG:
        nonebot.load_plugin('nonebot_plugin_docs')
        nonebot.load_plugin('nonebot_plugin_test')
    nonebot.load_plugins('cheru/plugin')

    logger.add(error_log_file,
               rotation='0:00',
               format=default_format,
               compression='zip',
               enqueue=True,
               backtrace=True,
               diagnose=True,
               level='ERROR')
Exemple #25
0
async def reloadplugins(session: CommandSession):
    # Reload config
    get_bot().config = config
    logger.info("Config reloaded.")

    # Reload plugins
    plugins = nonebot.plugin.get_loaded_plugins()
    for plugin in plugins:
        module_path = plugin.module.__name__
        nonebot.plugin.PluginManager.remove_plugin(module_path)
        for module in list(
                filter(lambda x: x.startswith(module_path),
                       sys.modules.keys())):
            del sys.modules[module]

    reloaded_plugins = nonebot.load_plugins(path.dirname(__file__),
                                            'deltabot.plugins')
    logger.info(f"{len(reloaded_plugins)} plugin(s) reloaded.")
    await session.send(f"已成功重载{len(reloaded_plugins)}个插件")
Exemple #26
0
from os import path

import nonebot

import config

if __name__ == '__main__':
    nonebot.init(config)
    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'awesome', 'plugins'),
        'awesome.plugins')
    nonebot.run()
Exemple #27
0
from os import path

import nonebot
from demo import config

nonebot.init(config)


@nonebot.scheduler.scheduled_job('interval', seconds=20)
async def cb():
    bot_ = nonebot.get_bot()
    try:
        await bot_.send_private_msg(user_id=1002647525, message='哇')
    except Exception as e:
        nonebot.logger.exception(e)


if __name__ == '__main__':
    nonebot.load_builtin_plugins()
    nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                         'demo.plugins')
    nonebot.run(host=config.HOST, port=config.PORT)
Exemple #28
0
from os import path
import nonebot
import config

if __name__ == '__main__':
    
    nonebot.init(config)

    ######################
    #导入本插件
    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'twitter'),
        'twitter'
    )
    ######################
    
    nonebot.run()

Exemple #29
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import nonebot
from nonebot.adapters.cqhttp import Bot as CQHTTPBot
# Custom your logger
#
# from nonebot.log import logger, default_format
# logger.add("error.log",
#            rotation="00:00",
#            diagnose=False,
#            level="ERROR",
#            format=default_format)

# You can pass some keyword args config to init function
nonebot.init()
app = nonebot.get_asgi()
driver = nonebot.get_driver()
driver.register_adapter("cqhttp", CQHTTPBot)
config = driver.config
nonebot.load_builtin_plugins()
nonebot.load_plugins("src/plugins")

# Modify some config / config depends on loaded configs
#
# config = nonebot.get_driver().config
# do something...

# https://v2.nonebot.dev/guide/basic-configuration.html
if __name__ == "__main__":
    nonebot.run(app="bot:app")
Exemple #30
0
import nonebot 
from nonebot import on_command, scheduler, CommandSession, message, on_startup
import config 
import os

import asyncio

from models.model import * 
from database.mysql import *
from database.tables import *


    
if __name__ == '__main__':
    nonebot.init(config)

    nonebot.load_builtin_plugins()

    nonebot.load_plugins(os.path.join('.', 'plugins'), 'plugins')
    nonebot.run(host='0.0.0.0', port=8000)