一个构建开黑啦卡片的工具
Project description
KaiheilaCardBuilder
一个构造开黑啦卡片的工具
使用方法
from khl_card.card import Card
from khl_card.modules import *
from khl_card import *
# 新建卡片
# 这里构建了一个卡片,带有一个模块
card = Card([Section(Kmarkdown('测试卡片'))])
# 给卡片添加模块,这里是分割线
card.append(Divider())
# 拥有的模块列表,具体用法参考开黑啦官方文档
['Header', 'Section', 'ImageGroup', 'Container', 'Context', 'ActionGroup', 'File', 'Audio', 'Video', 'Divider',
'Invite', 'Countdown']
# 拥有的元素列表,具体用法参考开黑啦官方文档
['PlainText', 'Kmarkdown', 'Paragraph', 'Image', 'Button', '_BaseAccessory']
# 倒计时模块的简便创建
card.append(Countdown.new_day_countdown('2022-05-05 08:00:00'))
card.append(Countdown.new_hour_countdown('2022-05-05 08:00:00'))
card.append(Countdown.new_second_countdown('2022-05-05 08:00:00'))
# 构建卡片,返回的卡片的字典
card.build()
# 构建卡片,返回官方编辑器可以用的 json 文本
card.build_to_json()
# 输出:
{
"type": "card",
"theme": "primary",
"size": "lg",
"modules": [
{
"type": "section",
"mode": "right",
"text": {
"type": "kmarkdown",
"content": "测试卡片"
}
},
{
"type": "divider"
},
{
"type": "countdown",
"mode": "day",
"endTime": 1651708800000,
"startTime": 1647088354584
},
{
"type": "countdown",
"mode": "hour",
"endTime": 1651708800000,
"startTime": 1647088354584
},
{
"type": "countdown",
"mode": "second",
"endTime": 1651708800000,
"startTime": 1647088354588
}
],
"color": "#ffffff"
}
更新日志
1.1.1
卡片按钮现在使用 PlainText
或 Kmarkdown
1.1.0
添加 Card
的一些方法
修复 Button
的构建 bug
修复 Color
中 __str__
的问题
为倒计时模块添加快速创建方法
from khl_card.modules import *
Countdown.new_day_countdown('2022-05-05 08:00:00')
Countdown.new_hour_countdown('2022-05-05 08:00:00')
Countdown.new_second_countdown('2022-05-05 08:00:00')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for KaiHeiLaCardBuilder-1.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aa3860319991596fccb39be3d5f234fa79cac7c389e841186b31097412041fa |
|
MD5 | 4811ca3ac9966a5e019cddac999ea51a |
|
BLAKE2b-256 | f5966ede83ccf0e964375802ed4e10c96879ad1581a4068d9880cbddbd43d849 |
Close
Hashes for KaiHeiLaCardBuilder-1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e0e032516c3060f5c792dc227312398fd109b48ed0dfd5f01a5432c6dfa6ae8 |
|
MD5 | 4ee967e7548c913a89a07c8a68b50f45 |
|
BLAKE2b-256 | e3484f04c846ee7c1c06a9598201fbded1f863c22674acae221c2f65da946fb3 |