-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
483 changed files
with
7,803 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import yaml | ||
|
||
|
||
def config() -> dict: | ||
with open("./config/system/config.yaml", "r", encoding="utf-8") as f: | ||
configs = yaml.load(f.read(), Loader=yaml.FullLoader) | ||
if configs["debug"] == 1: | ||
print(f"log:already reading config file: {configs}\n") | ||
return configs | ||
|
||
|
||
def set_config(config_family: str, config: dict) -> bool: | ||
""" | ||
设置插件的配置 | ||
""" | ||
try: | ||
with open(f"./config/plugin/{config_family}/config.yaml", "w", encoding="utf_8") as f: | ||
yaml.dump(data=config, stream=f, allow_unicode=True) | ||
except Exception as e: | ||
print(str(e)) | ||
return False | ||
finally: | ||
return True | ||
|
||
def read_config(config_family: str) -> dict: | ||
""" | ||
读取插件的配置 | ||
""" | ||
with open(f"./config/plugin/{config_family}/config.yaml", "r", encoding="utf_8") as f: | ||
configs = yaml.load(f.read(), Loader=yaml.FullLoader) | ||
return configs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2023 楚天寻箫(ictye) | ||
# | ||
# 此软件基于楚天寻箫非商业开源软件许可协议 1.0发布. | ||
# 您可以根据该协议的规定,在非商业或商业环境中使用、分发和引用此软件. | ||
# 惟分发此软件副本时,您不得以商业方式获利,并且不得限制用户获取该应用副本的体验. | ||
# 如果您修改或者引用了此软件,请按协议规定发布您的修改源码. | ||
# | ||
# 此软件由版权所有者提供,没有明确的技术支持承诺,使用此软件和源码造成的任何损失, | ||
# 版权所有者概不负责。如需技术支持,请联系版权所有者或社区获取最新版本。 | ||
# | ||
# 更多详情请参阅许可协议文档 | ||
from websockets.server import WebSocketServerProtocol | ||
|
||
|
||
class connect_wrapper: | ||
|
||
""" | ||
连接包装类 | ||
""" | ||
|
||
def __init__(self, connect: WebSocketServerProtocol): | ||
self.__connect__ = connect | ||
self.id = connect.id # 连接id | ||
self.open = connect.open # 连接状态 | ||
|
||
def refresh(self): | ||
""" | ||
刷新状态 | ||
""" | ||
self.id = self.__connect__.id | ||
self.open = self.__connect__.open | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import logging | ||
|
||
|
||
def setup_logging(config: dict): | ||
""" | ||
Setup logging configuration | ||
""" | ||
|
||
level_dic: dict = {"DEBUG": logging.DEBUG, | ||
"INFO": logging.INFO, | ||
"WARNING": logging.WARNING, | ||
"ERROR": logging.ERROR, | ||
"CRITICAL": logging.CRITICAL, | ||
"FATAL": logging.FATAL} | ||
logging.basicConfig(level=level_dic[config["loglevel"]], format="[%(asctime)s,%(name)s] %(levelname)s : %(message)s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
""" | ||
这个文件内定义全部的标准消息模板 | ||
所有的函数都应该又to_dict方法来将其转为字典,相反的这个函数能输出打包好的字典 | ||
别问我为啥,问就是不知道 | ||
""" | ||
|
||
|
||
class datas: | ||
def to_dict(self, cls: object): | ||
return dict(cls) | ||
|
||
|
||
class connect_ok: | ||
""" | ||
连接认证消息 | ||
""" | ||
code = 200 | ||
msg = "connect ok" | ||
|
||
def to_dict(self): | ||
return {"code": self.code, | ||
"msg": self.msg} | ||
|
||
|
||
class dm: | ||
def __init__(self, msg: str, who: dict): | ||
""" | ||
params: | ||
msg:str 消息主体 | ||
who:dict 消息发出者对象(其实是一个字典) | ||
成员方法: | ||
to_dict: 输出为字典 | ||
""" | ||
self.msg = msg | ||
self.who = who | ||
|
||
def to_dict(self): | ||
return {"msg": self.msg, | ||
"who": self.who} | ||
|
||
|
||
class info: | ||
def __init__(self, | ||
msg: str, | ||
who: str, | ||
pic: dict): | ||
self.msg = msg | ||
self.who = who | ||
self.pic = pic | ||
|
||
def to_dict(self): | ||
return {"msg": self.msg, | ||
"who": self.who, | ||
"pic": self.pic} | ||
|
||
|
||
class socket_responce: | ||
def __init__(self, config: dict): | ||
self.code = 200 | ||
self.local = "ws://{}:{}".format(config["host"], config["websocket"]["port"]) | ||
|
||
def to_dict(self): | ||
return {"code": self.code, | ||
"local": self.local} | ||
|
||
|
||
class msg_who: | ||
def __init__(self, type: int, | ||
name: str, | ||
face: str): | ||
self.type = type | ||
self.name = name | ||
self.face = face | ||
|
||
def to_dict(self): | ||
return {"name": self.name, | ||
"type": self.type, | ||
"face": self.face} | ||
|
||
|
||
class pic: | ||
def __init__(self, | ||
border: bool, | ||
pic_url: str): | ||
self.border = border | ||
self.pic_url = pic_url | ||
|
||
def to_dict(self): | ||
return {"border": self.border, | ||
"pic_url": self.pic_url} | ||
|
||
|
||
class msg_box: | ||
""" | ||
消息标准封装所用的类 | ||
""" | ||
|
||
def __init__(self, | ||
message_class: str, | ||
msg_type: str, | ||
message_body: dict): | ||
self.message_class = message_class | ||
self.msg_type = msg_type | ||
self.message_body = message_body | ||
|
||
def to_dict(self): | ||
return {"message_class": self.message_class, | ||
"msg_type": self.msg_type, | ||
"message_body": self.message_body} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class PluginTypeError(Exception): | ||
def __init__(self, message): | ||
self.message = message | ||
super().__init__(self.message) | ||
|
||
|
||
class UnexpectedPluginMessage(Exception): | ||
def __init__(self, message): | ||
super(UnexpectedPluginMessage, self).__init__(message) | ||
|
||
|
||
class UnexpectedPluginMather(Exception): | ||
def __init__(self, message): | ||
super(UnexpectedPluginMather, self).__init__(message) | ||
|
||
|
||
class NoMainMather(Exception): | ||
def __init__(self, message): | ||
super(NoMainMather, self).__init__(message) |
Oops, something went wrong.