一个构建开黑啦卡片的工具
Project description
KaiheilaCardBuilder
一个构造开黑啦卡片的工具
使用方法
from khl_card.card import Card
from khl_card.modules import *
from khl_card.accessory 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.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.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea6057effa397cac95b72030dbe2fff7d554d9dafaa5de81b67f75b4fb426491 |
|
MD5 | 89f434cbf9a71fedd3e604961e4c533b |
|
BLAKE2b-256 | 4f77444118f6a738eefebe934175b91dc65b5442dc93726ab5e8e56b9fd2a053 |
Close
Hashes for KaiHeiLaCardBuilder-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7fa67b551cd4cb5609ed247ac4767962c244e40a35b67498a468dc33f47cfe7 |
|
MD5 | 9dc71c10816be94077d56b1cb0ea0a7f |
|
BLAKE2b-256 | 731e993f63c0dc3b1f5087cf143cd708f15fe0bfa52e6c27550af45a95743531 |