feat: HTTP API support
This commit is contained in:
+20
-3
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import sys
|
||||
|
||||
from creart import create
|
||||
@@ -6,9 +7,10 @@ from graia.broadcast import Broadcast
|
||||
from loguru import logger
|
||||
|
||||
from .datasource import DataSource
|
||||
from .server import http_init
|
||||
from ..exception.DataSourceException import DataSourceException
|
||||
from ..exception.RedisException import RedisException
|
||||
from ..utils import redis
|
||||
from ..utils import redis, config
|
||||
|
||||
|
||||
class StarBot:
|
||||
@@ -59,9 +61,24 @@ class StarBot:
|
||||
logger.error(ex.msg)
|
||||
return
|
||||
|
||||
# 启动 HTTP API 服务
|
||||
if config.get("USE_HTTP_API"):
|
||||
asyncio.get_event_loop().create_task(http_init(self.__datasource))
|
||||
|
||||
# 启动 Bot
|
||||
logger.info("开始启动 Ariadne 消息推送模块")
|
||||
Ariadne.options["default_account"] = 1499887988
|
||||
if not self.__datasource.bots:
|
||||
logger.error("不存在需要启动的 Bot 账号, 请先在数据源中配置完毕后再重新运行")
|
||||
return
|
||||
|
||||
Ariadne.options["default_account"] = self.__datasource.bots[0].qq
|
||||
|
||||
logger.info("开始运行 Ariadne 消息推送模块")
|
||||
logger.disable("graia.ariadne.service")
|
||||
logger.disable("launart")
|
||||
|
||||
for bot in self.__datasource.bots:
|
||||
bot.start_sender()
|
||||
|
||||
try:
|
||||
Ariadne.launch_blocking()
|
||||
except RuntimeError as ex:
|
||||
|
||||
Reference in New Issue
Block a user