Esempio n. 1
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
Esempio n. 2
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()
Esempio n. 3
0
def run():
    nonebot.init(config)
    nonebot.load_builtin_plugins()
    nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'),
                         'deltabot.plugins')

    nonebot.run()
Esempio n. 4
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()
Esempio n. 5
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()
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
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')
Esempio n. 9
0
# 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)

# 加载插件
nonebot.load_plugin("nonebot_plugin_biliav")
nonebot.load_builtin_plugins()
nonebot.load_from_toml("pyproject.toml")

# Modify some config / config depends on loaded configs
# 
# config = driver.config
# do something...


if __name__ == "__main__":
    nonebot.logger.warning("Always use `nb run` to start the bot instead of manually running!")
    nonebot.run(app="__mp_main__:app")
#
# 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(ONEBOT_V11Adapter)

nonebot.load_builtin_plugins("echo")

nonebot.load_plugins("nonebot_plugin_astrologian/plugins")

# Please DO NOT modify this file unless you know what you are doing!
# As an alternative, you should use command `nb` or modify `pyproject.toml` to load plugins
# nonebot.load_from_toml("pyproject.toml")

# Modify some config / config depends on loaded configs
#
# config = driver.config
# do something...

if __name__ == "__main__":
    logger.warning(
        "Always use `nb run` to start the bot instead of manually running!")
Esempio n. 11
0
from os import path

import nonebot

import config

if __name__ == '__main__':
    nonebot.init(config)  #将config作为配置对象传给noneot.init函数

    #加载插件
    nonebot.load_plugins(
        path.join(path.dirname(__file__), 'awesome', 'plugins'),
        'awesome.plugins')
    nonebot.load_builtin_plugins()  #加载notebot内置的插件

    nonebot.run()  #在地址127.0.0.1:8080运行notebot
Esempio n. 12
0
def start():
    nonebot.init()
    nonebot.load_builtin_plugins()
    nonebot.run(host='127.0.0.1', port=8080)
Esempio n. 13
0
IAIbot 初始化模块
初始化系统,连接数据库,加载插件

author: 16030199025 张俊华
"""

from os import path
import sys
import setup
import os

import nonebot as none

sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))

import IAI.iai.common.cache as cache

if __name__ == '__main__':
    sys.path.append(
        os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
    none.init(setup)

    bot = none.get_bot()
    bot.server_app.before_serving(cache.init)

    none.load_builtin_plugins()
    none.load_plugins(path.join(path.dirname(__file__), 'iai', 'plugins'),
                      'iai.plugins')
    none.run()
Esempio n. 14
0
'''
Author: your name
Date: 2021-03-02 00:05:07
LastEditTime: 2021-05-15 09:31:48
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \nonebot-test\bot.py
'''

import nonebot
from nonebot.adapters.cqhttp import Bot as CQHTTPBot

nonebot.init()                                  # 使用默认配置初始化 NoneBot
driver = nonebot.get_driver()
driver.register_adapter("cqhttp", CQHTTPBot)    # 加载 NoneBot 内置的 CQHTTP 协议适配组件
nonebot.load_builtin_plugins()                  # 加载 NoneBot 内置的插件

if __name__ == "__main__":
    nonebot.run(host='127.0.0.1', port=8083)
def main(config):
    init(config)
    load_builtin_plugins()
    load_plugins(path.join(path.dirname(__file__), 'plugins'),
                 'milktea.plugins')
    run()