Skip to content

Commit 919a566

Browse files
committed
1.20
1 parent a7ca097 commit 919a566

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: 安装依赖
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install setuptools wheel pillow build
24+
pip install setuptools wheel pillow build requests
2525
2626
- name: 构建
2727
run: |

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ $ pip install /path/to/mctoast-wheel.whl
1111
# 从github仓库安装 (有时候未经测试,也有可能无法运行)
1212
$ pip install git+https://github.com/SystemFileB/mctoast.git@main
1313
```
14+
推荐你额外安装requests,这样你就可以在`-i=`参数中使用URL了
15+
```shell
16+
$ pip install requests
17+
```
1418

1519
## 🖼️画廊
1620
原版效果:
@@ -29,6 +33,13 @@ mctoast模仿的效果:
2933
- 若遇到了相关的许可证问题,请第一时间[提交issue](https://github.com/SystemFileB/mctoast/issues)并加上 版权或许可证问题 标签
3034

3135
## 📰更新日志
36+
### 1.20
37+
- 命令行工具的修改
38+
- 如果你安装了requests,你就可以在`-i=`参数中使用网络图片
39+
- 库的修改
40+
- 放宽了`generate_image` `image`参数的类型,现在只要是Pillow支持的都可以,如果Pillow不支持Pillow就会报错,命令行工具也是
41+
- 所以遇到`PIL.UnidentifiedImageError: cannot identify image file`你也不必上传issue,否则我就会把它标为 不予理会
42+
3243
### 1.12
3344
- 紧急修复:setup.py并没有包含`__init__.py``__main__.py`文件,导致无法使用
3445
- 重新加入1.11的更改

mctoast/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
RETURN_BYTE=2
3030
RETURN_SAVETOFILE=3
3131

32-
def generate_image(toast=ADVANCEMENT, image_path:str=None, text1="进度已达成!", color1="yellow", text2="MCToast示例", color2="white", return_mode=RETURN_IMAGE, resize:bool=False, filename:str=None):
32+
def generate_image(toast=ADVANCEMENT, image_path=None, text1="进度已达成!", color1="yellow", text2="MCToast示例", color2="white", return_mode=RETURN_IMAGE, resize:bool=False, filename:str=None):
3333
"""生成Toast图片
3434
toast:str 背景图片(ADVANCEMENT,RECIPE,SYSTEM)
35-
image_path:str 图片路径(对应原版的物品位置)
35+
image_path:str 图片路径(对应原版的物品位置),你也可以试试BytesIO
3636
text1:str 第一行文本
3737
color1:str 第一行文本颜色
3838
text2:str 第二行文本
@@ -187,10 +187,10 @@ def init():
187187
while window==None:
188188
time.sleep(0.01)
189189

190-
def new_toast(toast=ADVANCEMENT, image_path:str=None, text1="一个弹窗", color1="yellow", text2="MCToast示例", color2="white"):
190+
def new_toast(toast=ADVANCEMENT, image_path=None, text1="一个弹窗", color1="yellow", text2="MCToast示例", color2="white"):
191191
"""新弹窗
192192
toast:str 背景图片(ADVANCEMENT,RECIPE,SYSTEM)
193-
image_path:str 图片路径(对应原版的物品位置)
193+
image_path:str 图片路径(对应原版的物品位置),你也可以试试BytesIO
194194
text1:str 第一行文本
195195
color1:str 第一行文本颜色
196196
text2:str 第二行文本

mctoast/__main__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import mctoast,sys
1+
import mctoast
2+
import sys
23
help="""
34
生成一个MCToast图片或者弹出一个Toast
45
用法:
@@ -69,7 +70,7 @@
6970
"""
7071
def mian():
7172
global help,moo
72-
print("MCToast 生成器 1.12\n")
73+
print("MCToast 生成器 1.13\n")
7374
toasts=(mctoast.ADVANCEMENT,mctoast.RECIPE,mctoast.SYSTEM)
7475
toast=mctoast.ADVANCEMENT
7576
image=None
@@ -89,7 +90,18 @@ def mian():
8990
exit(1)
9091
print(toast)
9192
elif arg.startswith("--image=") or arg.startswith("-i="):
92-
image=arg.split("=")[1]
93+
if arg.split("=")[1].startswith("http"):
94+
try:
95+
from requests import get
96+
import io
97+
except ImportError:
98+
print("ERROR: 未安装requests库,无法执行这个操作")
99+
exit(1)
100+
req=get(arg.split("=")[1])
101+
image=io.BytesIO(req.content)
102+
103+
else:
104+
image=arg.split("=")[1]
93105
elif arg.startswith("--title=") or arg.startswith("-t1="):
94106
text1=arg.split("=")[1]
95107
elif arg.startswith("--title-color=") or arg.startswith("-c1="):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="mctoast",
8-
version="1.12",
8+
version="1.20",
99
description="把Minecraft的Toast带到现实里!",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)