完成插件和blivechat连接
parent
f886506c39
commit
b0b38bf0f0
@ -1,2 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__version__ = '0.0.1'
|
||||
|
||||
from .handlers import *
|
||||
from .client import *
|
||||
from .exc import *
|
||||
from .api import *
|
||||
|
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__all__ = (
|
||||
'SdkError',
|
||||
'InitError',
|
||||
)
|
||||
|
||||
|
||||
class SdkError(Exception):
|
||||
"""SDK错误的基类"""
|
||||
|
||||
|
||||
class InitError(SdkError):
|
||||
"""初始化失败"""
|
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
BASE_PATH = os.path.realpath(os.getcwd())
|
||||
LOG_PATH = os.path.join(BASE_PATH, 'log')
|
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import __main__
|
||||
import logging
|
||||
from typing import *
|
||||
|
||||
import blcsdk
|
||||
import blcsdk.models as sdk_models
|
||||
from blcsdk import client as cli
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_msg_handler: Optional['MsgHandler'] = None
|
||||
|
||||
|
||||
async def init():
|
||||
global _msg_handler
|
||||
_msg_handler = MsgHandler()
|
||||
blcsdk.set_msg_handler(_msg_handler)
|
||||
|
||||
|
||||
class MsgHandler(blcsdk.BaseHandler):
|
||||
def on_client_stopped(self, client: cli.BlcPluginClient, exception: Optional[Exception]):
|
||||
logger.info('blivechat disconnected')
|
||||
__main__.start_shut_down()
|
||||
|
||||
def _on_add_text(self, client: cli.BlcPluginClient, message: sdk_models.AddTextMsg):
|
||||
"""收到弹幕"""
|
||||
|
||||
def _on_add_gift(self, client: cli.BlcPluginClient, message: sdk_models.AddGiftMsg):
|
||||
"""有人送礼"""
|
||||
|
||||
def _on_add_member(self, client: cli.BlcPluginClient, message: sdk_models.AddMemberMsg):
|
||||
"""有人上舰"""
|
||||
|
||||
def _on_add_super_chat(self, client: cli.BlcPluginClient, message: sdk_models.AddSuperChatMsg):
|
||||
"""醒目留言"""
|
||||
|
||||
def _on_del_super_chat(self, client: cli.BlcPluginClient, message: sdk_models.DelSuperChatMsg):
|
||||
"""删除醒目留言"""
|
||||
|
||||
def _on_update_translation(self, client: cli.BlcPluginClient, message: sdk_models.UpdateTranslationMsg):
|
||||
"""更新翻译"""
|
Loading…
Reference in New Issue