def qqbot(host, port): nonebot.init() nonebot.load_plugins(os.path.join(os.path.dirname(__file__), 'plugins'), 'plugins') nonebot.run(host=host, port=port)
import nonebot from nonebot.adapters.cqhttp import Bot as CQHTTPBot from nonebot.log import logger nonebot.init() driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) # nonebot.load_builtin_plugins() nonebot.load_plugins("src/plugins") if __name__ == "__main__": nonebot.run() logger.add("file_1.log", rotation="4096 MB")
# -*- 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(_env_file=".env") driver = nonebot.get_driver() config = driver.config config.command_start = set("!!/#") nonebot.load_builtin_plugins() app = nonebot.get_asgi() driver.register_adapter("cqhttp", CQHTTPBot) # nonebot.load_plugins("src/plugins") nonebot.load_plugins("fundbot/plugins") # Modify some config / config depends on loaded configs if __name__ == "__main__":
from os import path import sys import nonebot import db import config import config_debug import argparse from utils import init if __name__ == "__main__": paser = argparse.ArgumentParser() paser.add_argument("-d", "--debug", action="store_true", default=False) args = paser.parse_args(sys.argv[1:]) if args.debug == True: nonebot.init(config_debug) else: nonebot.init(config) init() bot = nonebot.get_bot() bot.server_app.before_serving(db.initdb) nonebot.load_plugins( path.join(path.dirname(__file__), "Pzzzzz", "plugins"), "Pzzzzz.plugins") nonebot.run()
#!/home/qbprjENV/bin/python from os import path import nonebot as nb import config if __name__ == '__main__': # 加载配置文件 nb.init(config) # 加载插件 nb.load_plugins(path.join(path.dirname(__file__), 'ALLplugins', 'plugins'), 'ALLplugins.plugins') nb.run()
with open('./abot/_set.py', encoding='utf-8') as f: text = f.read() with open('./abot/_config.txt', encoding='utf-8') as f: config = f.read() config = 'dit=' + config text = re.sub(r'dit(\s*)=(\s*){.*}', config, text, flags=re.S) with open("./abot/_set.py", 'w', encoding='utf-8') as f: f.write(text) rep = requests.get('http://jwgl.cqjtu.edu.cn:80/app.do?method=authUser&xh=' + JwUid + '&pwd=' + JwPassword) if (json.loads(rep.text)['msg'] == '账号或密码错误'): print('教务网账号或密码错误,请在配置文件中重新输入!!!') else: token = json.loads(rep.text)['token'] f = open('./abot/_token.txt', 'w') f.write(token) f.close() nonebot.init() driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) #nonebot.load_builtin_plugins() nonebot.load_plugins("abot/") nonebot.init(custom_config1="", apscheduler_autostart=True, apscheduler_config={"apscheduler.timezone": "Asia/Shanghai"}) nonebot.run() if __name__ == "__main__": nonebot.run()
def main(): nonebot.init(config) # nonebot.load_builtin_plugins() nonebot.load_plugins(path.join(path.dirname(__file__), 'awesome', 'plugins'),'qqbot.awesome.plugins') nonebot.run()
import nonebot import config from os import path # 小心端口被占用 if __name__ == '__main__': nonebot.init(config) # 必须在使用NoneBot的任何功能之前调用 (必须要有) # nonebot.load_builtin_plugins() # 加载了NoneBot的内置插件,不是必须的 nonebot.load_plugins( path.join(path.dirname(__file__), 'awesome', 'plugins'), 'awesome.plugins') nonebot.run() # host='127.0.0.1', port='8080'
import os import nonebot import bot_config base_dir = "." plugins_dir = os.path.join(base_dir, "bot_plugins") sukyaru_plugins_dir = os.path.join(plugins_dir, "sukyaru_bot") if __name__ == "__main__": os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings') import django django.setup() nonebot.init(bot_config) nonebot.load_plugins( plugin_dir=sukyaru_plugins_dir, module_prefix="bot_plugins.sukyaru_bot" ) nonebot.run()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from uid_gid import init_workspace import nonebot from nonebot import drivers import subprocess drivers.BaseWebSocket = drivers.WebSocket from os import path from fastapi.middleware.cors import CORSMiddleware from nonebot.adapters.cqhttp import Bot as CQHTTPBot init_workspace() nonebot.init(command_start = {',', ','}) app = nonebot.get_asgi() driver = nonebot.get_driver() app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) driver.register_adapter("cqhttp", CQHTTPBot) nonebot.load_builtin_plugins() nonebot.load_plugin("nonebot_plugin_test")
#!/usr/bin/env python3 __author__ = "Yxzh" import nonebot as n import config if __name__ == "__main__": n.init(config) n.load_plugins("./PineBOT/plugin/", "PineBOT.plugin") n.run()
async def send_message(self, message: str) -> None: await nonebot.get_bot().send_private_msg( user_id=self._config.master_qq, message=message) _coolq_client: Optional[CoolqClient] = None _inited = False async def init(): config = await loadConfig() global _coolq_client _coolq_client = CoolqClient(config) global _inited _inited = True await _coolq_client.initialize() def get_coolq_client() -> CoolqClient: if not _inited: asyncio.get_event_loop().run_until_complete(init()) return _coolq_client if __name__ == '__main__': nonebot.init(coolq_config) nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'), 'app.coolq.plugins') nonebot.run()
import os import sys import nonebot import init nonebot.init(init) init.enable_plugins() nonebot.load_plugins( os.path.join(os.path.dirname(__file__), 'enabled', 'plugins'), 'enabled.plugins') enable_groups = init.getJson("enable_groups") ban_users = init.getJson("ban_users") bot = nonebot.get_bot() app = bot.asgi if __name__ == '__main__': bot.run() # pm2 start main.py -x --interpreter python --name mxbot
import nonebot from nonebot.adapters.onebot.v11 import Adapter as OneBotV11Adapter nonebot.init(command_start=[""]) app = nonebot.get_asgi() driver = nonebot.get_driver() driver.register_adapter(OneBotV11Adapter) nonebot.load_builtin_plugins("echo") # nonebot.load_plugin("nonebot_plugin_help") nonebot.load_plugins("src/plugins") if __name__ == "__main__": nonebot.run()
parser.add_argument('-d', '--dev', action='store_true', default=False, help='Enable the developing mode') args = parser.parse_args() if not args.dev: # save the logs to disk in non-developing mode logger.add("logs/errors_{time}.log", rotation="00:00", diagnose=False, level="ERROR", format=default_format) # initialize the bot nonebot.init(debug=args.dev, fastapi_reload_dirs=['littlefish'], command_start=['']) driver = nonebot.get_driver() driver.register_adapter("cqhttp", Bot) nonebot.load_plugin('nonebot_plugin_apscheduler') nonebot.load_plugins('littlefish') if args.dev: app = nonebot.get_asgi() # load the ASGI app nonebot.load_plugin( 'nonebot_plugin_test') # enable the test frontend in developing mode if __name__ == '__main__': nonebot.run(app='bot:app' * args.dev)
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()
import logging import nonebot from nonebot.log import logger import config_bot if __name__ == '__main__': nonebot.init(config_bot) logger.setLevel(logging.INFO) for dir_ in config_bot.root_path.joinpath('plugins').iterdir(): if dir_.is_dir() and dir_.name != 'disabled': nonebot.load_plugins(str(dir_), f'plugins.{dir_.name}') logger.info('Starting') nonebot.run()
import nonebot import config from os import path if __name__ == '__main__': nonebot.init(config) #初始化QQ机器人然后加载配置文件 nonebot.load_plugins(path.join(path.dirname(__file__), 'plugins'), 'plugins') #加载内置的插件 t = path.join(path.dirname(__file__), 'plugins') nonebot.run()
#!/usr/bin/python env # -*- coding:utf-8 -*- import nonebot from os import path import config if __name__ == '__main__': nonebot.init(config) #使用默认配置初始化 NoneBot 包 nonebot.load_plugins(path.join(path.dirname(__file__), 'QQbot'), 'QQbot') #加载 NoneBot 内置的插件 nonebot.run()
def start(): nonebot.init() nonebot.load_builtin_plugins() nonebot.run(host='127.0.0.1', port=8080)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import nonebot from nonebot.adapters.cqhttp import Bot gids = {} # 此处放入指定群聊 nonebot.init(apscheduler_autostart=True) nonebot.init(apscheduler_config={ "apscheduler.timezone": "Asia/Shanghai" }) app = nonebot.get_asgi() driver = nonebot.get_driver() driver.register_adapter("cqhttp", Bot) nonebot.load_plugins("src/plugins") config = nonebot.get_driver().config config.GroupList = gids if __name__ == "__main__": nonebot.run(app="bot:app")
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
# -*- coding = utf-8 -*- # @Time : 2020/5/11 9:28 # @Author : AX # @File : bot.py # @Software: PyCharm import nonebot import qqbot.config if __name__ == '__main__': nonebot.init(config_object=qqbot.config) nonebot.load_builtin_plugins() nonebot.run(host='127.0.0.1', port=8080)
import nonebot, sys, logging import config_dev, config_test, config_prod from os import path if __name__ == '__main__': logging.basicConfig(level=logging.WARNING) try: DEPLOYMENT_ENV = sys.argv[1] if DEPLOYMENT_ENV == 'dev': # 开发环境 logging.warning(f'部署成功!当前环境:{DEPLOYMENT_ENV}') nonebot.init(config_dev) elif DEPLOYMENT_ENV == 'test': # 测试环境 logging.warning(f'部署成功!当前环境:{DEPLOYMENT_ENV}') nonebot.init(config_test) elif DEPLOYMENT_ENV == 'prod': # 生产环境 logging.warning(f'部署成功!当前环境:{DEPLOYMENT_ENV}') nonebot.init(config_prod) else: logging.warning('参数错误!请输入正确的运行参数:\ndev:开发环境\nprod:生产环境\ntest:测试环境') sys.exit(1) nonebot.load_plugins( path.join(path.dirname(__file__), 'awesome', 'plugins'), 'awesome.plugins') nonebot.run() except Exception as e: logging.error(e)
import os import sys sys.path.insert(0, os.path.abspath("..")) import nonebot from nonebot.log import logger, default_format # test custom log logger.add("error.log", rotation="00:00", diagnose=False, level="ERROR", format=default_format) nonebot.init(custom_config2="config on init") app = nonebot.get_asgi() # load builtin plugin nonebot.load_builtin_plugins() # load local plugins nonebot.load_plugins("test_plugins") print(nonebot.require("test_export")) # modify some config / config depends on loaded configs config = nonebot.get_driver().config config.custom_config3 = config.custom_config1 config.custom_config4 = "New custom config"
time.sleep(1) CONFIG_PATH = Path('.') / 'config.yml' config = load_yaml(CONFIG_PATH) config = config['bot'] LOGGER_INFO_PATH = Path( '.' ) / 'logs' / 'info' / f"{datetime.datetime.now().strftime('%Y%m%d-%H%M%S')}-INFO.log" LOGGER_ERROR_PATH = Path( '.' ) / 'logs' / 'error' / f"{datetime.datetime.now().strftime('%Y%m%d-%H%M%S')}-ERROR.log" nonebot.init(debug=bool(config['debug']), superusers=set(config['superusers']), nickname=set(config['nickname']), command_start=set(config['command_start']), command_sep=set(config['command_sep'])) app = nonebot.get_asgi() driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) nonebot.load_plugins('ATRI/plugins') logger.add(LOGGER_INFO_PATH, rotation='10 MB', diagnose=False, level='INFO', format=default_format)
import nonebot import importlib if __name__ == '__main__': nonebot.init(importlib.import_module('config')) nonebot.load_plugins('./plugins', 'plugins') nonebot.run(host='0.0.0.0', port=6666)
import nonebot from nonebot.adapters.cqhttp import Bot as CQHTTPBot from src.utils.yaml_loader import yml_loader from src.utils.scheduler_job.epd_drawer import shutdown from pathlib import Path CONFIG_FILE = Path("./configs.yml") configs = yml_loader(CONFIG_FILE) bot_config = configs["bot"] nonebot.init(debug=bot_config["DEBUG"], superusers=set(bot_config["SUPERUSERS"]), nickname=set(bot_config["NICKNAME"]), command_start=set(bot_config["COMMAND_START"]), command_sep=set(bot_config["COMMAND_SEP"]), host=bot_config["HOST"], port=bot_config["PORT"], apscheduler_autostart=False) app = nonebot.get_asgi() driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) driver.on_shutdown(shutdown) nonebot.load_builtin_plugins() nonebot.load_plugin("nonebot_plugin_apscheduler") nonebot.load_plugins("src/plugins") if __name__ == "__main__":
#!/usr/bin/env python # -*- coding: utf-8 -*- # @auther : lockcy import nonebot from os import path import config if __name__ == '__main__': nonebot.init(config) nonebot.load_plugins( path.join(path.dirname(__file__), 'awesome', 'plugins'), 'awesome.plugins') nonebot.run()
import nonebot from nonebot.adapters.cqhttp import Bot nonebot.init(debug=True) nonebot.get_driver().register_adapter('cqhttp', Bot) nonebot.load_plugin('nonetrip') import nonetrip nonetrip.init() nonetrip.load_builtin_plugins() nonebot.run(port=2333)