XMWAI 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of XMWAI might be problematic. Click here for more details.
- XMWAI/__init__.py +3 -2
- XMWAI/bomb_core.py +50 -0
- XMWAI/core.py +4 -2
- XMWAI/idiom_core.py +64 -0
- {xmwai-0.1.0.dist-info → xmwai-0.1.2.dist-info}/METADATA +3 -2
- xmwai-0.1.2.dist-info/RECORD +10 -0
- {xmwai-0.1.0.dist-info → xmwai-0.1.2.dist-info}/WHEEL +1 -1
- xmwai-0.1.0.dist-info/RECORD +0 -8
- {xmwai-0.1.0.dist-info → xmwai-0.1.2.dist-info/licenses}/LICENSE.txt +0 -0
- {xmwai-0.1.0.dist-info → xmwai-0.1.2.dist-info}/top_level.txt +0 -0
XMWAI/__init__.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .core import story, photo, reply, poem, get_access_token # 从子模块导入函数到顶层
|
|
2
|
-
from .magic_core import birthday
|
|
2
|
+
from .magic_core import birthday # 从子模块导入函数到顶层
|
|
3
|
+
from .bomb_core import bomb # 从子模块导入函数到顶层
|
|
3
4
|
|
|
4
|
-
__all__ = ["story", "photo", "reply", "poem", "get_access_token", 'birthday'] # 可选:明确导出的内容
|
|
5
|
+
__all__ = ["story", "photo", "reply", "poem", "get_access_token", 'birthday', 'bomb'] # 可选:明确导出的内容
|
XMWAI/bomb_core.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import turtle
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def bomb(screen, x, y):
|
|
6
|
+
"""显示炸弹爆炸动画(包含坐标检查和自动预加载)"""
|
|
7
|
+
# 检查是否为(0,0)坐标
|
|
8
|
+
if x == 0 and y == 0:
|
|
9
|
+
screen.tracer(False)
|
|
10
|
+
warn = turtle.Turtle()
|
|
11
|
+
warn.hideturtle()
|
|
12
|
+
warn.penup()
|
|
13
|
+
warn.goto(0, 0)
|
|
14
|
+
warn.color("#B39F2F") # 使用指定的金色/橄榄色
|
|
15
|
+
warn.write("不能打击自己", align="center", font=("微软雅黑", 16, "bold"))
|
|
16
|
+
screen.update()
|
|
17
|
+
time.sleep(1.5)
|
|
18
|
+
warn.clear()
|
|
19
|
+
screen.update()
|
|
20
|
+
screen.tracer(True)
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
# 预加载所有炸弹GIF形状(首次调用时执行)
|
|
24
|
+
if not hasattr(bomb, "_gif_loaded"):
|
|
25
|
+
for i in range(86):
|
|
26
|
+
screen.addshape(f"gif/bomb-{i:02d}.gif")
|
|
27
|
+
bomb._gif_loaded = True
|
|
28
|
+
|
|
29
|
+
# 正常爆炸动画流程
|
|
30
|
+
screen.tracer(False)
|
|
31
|
+
b = turtle.Turtle()
|
|
32
|
+
b.penup()
|
|
33
|
+
b.goto(x, y + 70)
|
|
34
|
+
|
|
35
|
+
for i in range(86):
|
|
36
|
+
b.shape(f"gif/bomb-{i:02d}.gif")
|
|
37
|
+
time.sleep(0.01)
|
|
38
|
+
screen.update()
|
|
39
|
+
|
|
40
|
+
b.hideturtle()
|
|
41
|
+
text = f" 💥 成功打击\n坐标({x}, {y})"
|
|
42
|
+
b.pencolor("white")
|
|
43
|
+
b.goto(x, y - 35)
|
|
44
|
+
b.write(text, align="center", font=("微软雅黑", 12))
|
|
45
|
+
|
|
46
|
+
screen.update()
|
|
47
|
+
time.sleep(1.5)
|
|
48
|
+
b.clear()
|
|
49
|
+
screen.update()
|
|
50
|
+
screen.tracer(True)
|
XMWAI/core.py
CHANGED
|
@@ -61,9 +61,10 @@ def photo(content, style, size, key=""):
|
|
|
61
61
|
if key == "":
|
|
62
62
|
print("没有秘钥!请提供秘钥!")
|
|
63
63
|
return "没有秘钥!请提供秘钥!"
|
|
64
|
-
elif key != "
|
|
64
|
+
elif key != "CaJQ":
|
|
65
65
|
print("秘钥错误!请重新输入!")
|
|
66
66
|
return "秘钥错误!请重新输入!"
|
|
67
|
+
key = "image"
|
|
67
68
|
url = "https://gateway.xiaomawang.com/pythonUILibApi/api/text2" + key
|
|
68
69
|
|
|
69
70
|
# 请求的头部
|
|
@@ -180,9 +181,10 @@ def poem(title, key=""):
|
|
|
180
181
|
if key == "":
|
|
181
182
|
print("没有秘钥!请提供秘钥!")
|
|
182
183
|
return "没有秘钥!请提供秘钥!"
|
|
183
|
-
elif key != "
|
|
184
|
+
elif key != "CaJQ":
|
|
184
185
|
print("秘钥错误!请重新输入!")
|
|
185
186
|
return "秘钥错误!请重新输入!"
|
|
187
|
+
key = "ZZC"
|
|
186
188
|
access_token = get_access_token(key)
|
|
187
189
|
if access_token:
|
|
188
190
|
url = f"https://aip.baidubce.com/rpc/2.0/nlp/v1/poem?access_token={access_token}"
|
XMWAI/idiom_core.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import random
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def idiom(word, mode=0):
|
|
7
|
+
"""
|
|
8
|
+
查询成语信息
|
|
9
|
+
:param word: 要查询的成语
|
|
10
|
+
:param mode: 查询模式
|
|
11
|
+
0 - 判断是否是成语,返回 True/False
|
|
12
|
+
1 - 返回拼音
|
|
13
|
+
2 - 返回解释
|
|
14
|
+
3 - 返回出处
|
|
15
|
+
:return: 查询结果或 None
|
|
16
|
+
"""
|
|
17
|
+
if mode == 0:
|
|
18
|
+
with open("idiom.json", "r", encoding="utf-8") as f:
|
|
19
|
+
data = json.load(f)
|
|
20
|
+
for i in data:
|
|
21
|
+
if word == i["word"]:
|
|
22
|
+
return True
|
|
23
|
+
return False
|
|
24
|
+
elif mode == 1:
|
|
25
|
+
with open("idiom.json", "r", encoding="utf-8") as f:
|
|
26
|
+
data = json.load(f)
|
|
27
|
+
for i in data:
|
|
28
|
+
if word == i["word"]:
|
|
29
|
+
return i["pinyin"]
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
elif mode == 2:
|
|
33
|
+
with open("idiom.json", "r", encoding="utf-8") as f:
|
|
34
|
+
data = json.load(f)
|
|
35
|
+
for i in data:
|
|
36
|
+
if word == i["word"]:
|
|
37
|
+
return i["explanation"]
|
|
38
|
+
return None
|
|
39
|
+
elif mode == 3:
|
|
40
|
+
with open("idiom.json", "r", encoding="utf-8") as f:
|
|
41
|
+
data = json.load(f)
|
|
42
|
+
for i in data:
|
|
43
|
+
if word == i["word"]:
|
|
44
|
+
return i["derivation"]
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def searchIdiom(text, num=1):
|
|
49
|
+
"""
|
|
50
|
+
模糊查询成语
|
|
51
|
+
:param text: 要查询的字
|
|
52
|
+
:param mode: 第几个字
|
|
53
|
+
:return: 查询结果 或 None
|
|
54
|
+
"""
|
|
55
|
+
wordList = []
|
|
56
|
+
with open("idiom.json", "r", encoding="utf-8") as f:
|
|
57
|
+
data = json.load(f)
|
|
58
|
+
for i in data:
|
|
59
|
+
if text == i["word"][num-1]:
|
|
60
|
+
wordList.append(i["word"])
|
|
61
|
+
if wordList:
|
|
62
|
+
return random.choice(wordList)
|
|
63
|
+
else:
|
|
64
|
+
return False
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: XMWAI
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Small code King AI related library
|
|
5
5
|
Home-page: https://github.com/Tonykai88/XMWAI.git
|
|
6
6
|
Author: pydevelopment
|
|
@@ -18,6 +18,7 @@ Dynamic: classifier
|
|
|
18
18
|
Dynamic: description
|
|
19
19
|
Dynamic: description-content-type
|
|
20
20
|
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
21
22
|
Dynamic: requires-dist
|
|
22
23
|
Dynamic: requires-python
|
|
23
24
|
Dynamic: summary
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
XMWAI/__init__.py,sha256=22xWIf68Fub64LGW_EB7WBvhuc5DWyzusEm3I2EjBFA,360
|
|
2
|
+
XMWAI/bomb_core.py,sha256=SPM9OpUgPi9BomGRB-KKeONJESy680rHr8qbJafjKNk,1402
|
|
3
|
+
XMWAI/core.py,sha256=C4pntTFPOpMuFhJCEVoAlrJEizNSHOWZcB1dwCdkl6w,7396
|
|
4
|
+
XMWAI/idiom_core.py,sha256=PPBBXYj_jJV1SnU5NROHiFkukmZDpZJgjZyuTiZondA,1774
|
|
5
|
+
XMWAI/magic_core.py,sha256=XU7K4Ta7EAvwBLk20_Hlu18E6Kz8B0HxUBq0YsawikE,3441
|
|
6
|
+
xmwai-0.1.2.dist-info/licenses/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
|
|
7
|
+
xmwai-0.1.2.dist-info/METADATA,sha256=aBJclqyzYxgRSosGRW848Ztzk6t2iZ7BbJtTT4ON8Xc,1033
|
|
8
|
+
xmwai-0.1.2.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
9
|
+
xmwai-0.1.2.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
|
|
10
|
+
xmwai-0.1.2.dist-info/RECORD,,
|
xmwai-0.1.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
XMWAI/__init__.py,sha256=zvm0-Odgjqsbf5O6HU7nuzrFxUVh-iDZyETj_u9jBgI,285
|
|
2
|
-
XMWAI/core.py,sha256=FLNokTW9CG94p44ja7FhILKs7KaPIy6oRmt-M8pbhqA,7360
|
|
3
|
-
XMWAI/magic_core.py,sha256=XU7K4Ta7EAvwBLk20_Hlu18E6Kz8B0HxUBq0YsawikE,3441
|
|
4
|
-
xmwai-0.1.0.dist-info/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
|
|
5
|
-
xmwai-0.1.0.dist-info/METADATA,sha256=8vb5ui-PQHXi1-PIqyBvAbg533x9Dl5ag8CXPF0TarI,1010
|
|
6
|
-
xmwai-0.1.0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
7
|
-
xmwai-0.1.0.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
|
|
8
|
-
xmwai-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|