mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-12-02 11:14:45 +08:00
edit readme
This commit is contained in:
parent
8eae6ee8aa
commit
fddbc732ef
70
src/api/canvas.py
Normal file
70
src/api/canvas.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# 写一个UINode基类,所有的UI节点都继承自这个基类
|
||||||
|
# 其他不同的基类例如文本,图像,面板都继承自UINode
|
||||||
|
# UI节点从任意树形节点可以被渲染通过Pillow
|
||||||
|
# UI节点可以被渲染成图片,也可以被渲染成PDF
|
||||||
|
# UI节点可以被渲染成图片,也可以被渲染成PDF
|
||||||
|
# UI节点可以被渲染成图片,也可以被渲染成PDF
|
||||||
|
|
||||||
|
# Path: src/api/canvas.py
|
||||||
|
class UINode:
|
||||||
|
def __init__(self):
|
||||||
|
self.children = []
|
||||||
|
self.parent = None
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0
|
||||||
|
self.width = 0
|
||||||
|
self.height = 0
|
||||||
|
self.visible = True
|
||||||
|
self.z_index = 0
|
||||||
|
self.background_color = None
|
||||||
|
self.background_image = None
|
||||||
|
self.border_color = None
|
||||||
|
self.border_width = 0
|
||||||
|
self.border_radius = 0
|
||||||
|
self.border_style = None
|
||||||
|
self.padding = 0
|
||||||
|
self.margin = 0
|
||||||
|
self.shadow = None
|
||||||
|
|
||||||
|
def add_child(self, child):
|
||||||
|
self.children.append(child)
|
||||||
|
child.parent = self
|
||||||
|
|
||||||
|
def remove_child(self, child):
|
||||||
|
self.children.remove(child)
|
||||||
|
child.parent = None
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
if not self.visible:
|
||||||
|
return
|
||||||
|
self.render_background(canvas)
|
||||||
|
self.render_border(canvas)
|
||||||
|
self.render_padding(canvas)
|
||||||
|
self.render_margin(canvas)
|
||||||
|
self.render_shadow(canvas)
|
||||||
|
self.render_self(canvas)
|
||||||
|
self.render_children(canvas)
|
||||||
|
|
||||||
|
def render_children(self, canvas):
|
||||||
|
for child in self.children:
|
||||||
|
child.render(canvas)
|
||||||
|
|
||||||
|
|
||||||
|
def render_background(self, canvas):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def render_border(self, canvas):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def render_padding(self, canvas):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def render_margin(self, canvas):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def render_shadow(self, canvas):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def render_self(self, canvas):
|
||||||
|
pass
|
@ -22,6 +22,7 @@ load_resource_from_index()
|
|||||||
async def detect_superuser(bot: Bot):
|
async def detect_superuser(bot: Bot):
|
||||||
db = Data('common', 'config')
|
db = Data('common', 'config')
|
||||||
db.remove('auth_code')
|
db.remove('auth_code')
|
||||||
|
# print a data to detect if there is superusers
|
||||||
if not len(bot.config.superusers):
|
if not len(bot.config.superusers):
|
||||||
auth_code = str(random.randint(1000, 9999))
|
auth_code = str(random.randint(1000, 9999))
|
||||||
db.set('auth_code', auth_code)
|
db.set('auth_code', auth_code)
|
||||||
@ -47,6 +48,42 @@ async def _(bot: Bot, event: MessageEvent, arg: Message = CommandArg(), ):
|
|||||||
logger.opt(colors=True).warning(Language().get('log.main.fail_to_reg_su', USER_ID=event.user_id))
|
logger.opt(colors=True).warning(Language().get('log.main.fail_to_reg_su', USER_ID=event.user_id))
|
||||||
|
|
||||||
|
|
||||||
|
@echo.handle()
|
||||||
|
async def _(bot: Bot, event: MessageEvent, arg: Message = CommandArg(), ):
|
||||||
|
await echo.send(arg)
|
||||||
|
|
||||||
|
|
||||||
@su_test.handle()
|
@su_test.handle()
|
||||||
async def _():
|
async def _():
|
||||||
await su_test.send('suc')
|
await su_test.send('suc')
|
||||||
|
|
||||||
|
|
||||||
|
@ban.handle()
|
||||||
|
async def _(bot: Bot, event: MessageEvent, arg: Message = CommandArg(), ):
|
||||||
|
await bot.call_api('set_group_ban', group_id=event.group_id, user_id=int(arg), duration=60 * 60 * 24 * 365 * 10)
|
||||||
|
await ban.send('suc')
|
||||||
|
|
||||||
|
|
||||||
|
def decode_text(text: str):
|
||||||
|
# input a string, output a string
|
||||||
|
# transfer cqcode to text
|
||||||
|
replace_data = {
|
||||||
|
'&': '&',
|
||||||
|
'[': '[',
|
||||||
|
']': ']',
|
||||||
|
',': ',',
|
||||||
|
'%20': ' '
|
||||||
|
}
|
||||||
|
for old, new in replace_data.items():
|
||||||
|
text = text.replace(old, new)
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def list_all_folder(path: str):
|
||||||
|
# input a path, output a list
|
||||||
|
# list all folder in the path
|
||||||
|
folder_list = []
|
||||||
|
for folder in os.listdir(path):
|
||||||
|
if os.path.isdir(os.path.join(path, folder)):
|
||||||
|
folder_list.append(folder)
|
||||||
|
return folder_list
|
||||||
|
Loading…
Reference in New Issue
Block a user