nonebot-plugin-rollpig 0.2.4__py3-none-any.whl → 0.2.6__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.
@@ -1,33 +1,13 @@
1
1
  import json, random, datetime, asyncio, requests
2
2
  from pathlib import Path
3
3
 
4
- from nonebot import on_command, require, on_startup
4
+ from nonebot import on_command, require
5
5
  from nonebot.adapters.onebot.v11 import Event, MessageSegment
6
6
  from nonebot.log import logger
7
7
  from nonebot.plugin import PluginMetadata
8
8
 
9
9
  pig_images = []
10
10
 
11
- @on_startup
12
- async def load_pig_images():
13
- global pig_images
14
- try:
15
- data = await asyncio.to_thread(sync_fetch_pig_data, "https://pighub.top/api/all-images")
16
-
17
- if data and data.get("images"):
18
- pig_images = data["images"]
19
- logger.success(f"成功从 PigHub 缓存 {len(pig_images)} 头猪猪")
20
- else:
21
- logger.warning("PigHub 中找不到猪猪")
22
- except requests.exceptions.RequestException as e:
23
- logger.error(f"从PigHub中获取猪猪失败: {e}")
24
-
25
- def sync_fetch_pig_data(url: str):
26
- response = requests.get(url, timeout=30)
27
- response.raise_for_status()
28
-
29
- return response.json()
30
-
31
11
  # 确保依赖插件先被 NoneBot 注册
32
12
  require("nonebot_plugin_htmlrender")
33
13
  require("nonebot_plugin_localstore")
@@ -64,9 +44,6 @@ roll_pig = on_command("随机小猪", block=True)
64
44
  async def _(event: Event):
65
45
  global pig_images
66
46
  if not pig_images:
67
- await roll_pig.finish("猪圈空荡荡,猪猪还没加载出来或者加载失败了...")
68
-
69
- # 再次尝试
70
47
  try:
71
48
  data = await asyncio.to_thread(sync_fetch_pig_data, "https://pighub.top/api/all-images")
72
49
  if data and data.get("images"):
@@ -78,13 +55,18 @@ async def _(event: Event):
78
55
  logger.error(f"从PigHub中获取猪猪失败: {e}")
79
56
 
80
57
  if not pig_images:
81
- await roll_pig.finish("猪圈空荡荡,猪猪还是没加载出来...")
58
+ await roll_pig.finish("猪圈空荡荡...")
82
59
  return
83
60
 
84
61
  pig = random.choice(pig_images)
85
62
  image_url = "https://pighub.top/data/" + pig["thumbnail"].split("/")[-1]
86
63
  await roll_pig.finish(MessageSegment.image(image_url))
87
64
 
65
+ def sync_fetch_pig_data(url: str):
66
+ response = requests.get(url, timeout=30)
67
+ response.raise_for_status()
68
+
69
+ return response.json()
88
70
 
89
71
  def load_json(path, default):
90
72
  if not path.exists():
@@ -262,5 +262,47 @@
262
262
  "name": "隐形猪",
263
263
  "description": "擅长隐身的神秘小猪",
264
264
  "analysis": "你自带低调气场,擅长隐藏行踪。在人群中你虽不显眼,但总能默默观察一切,像个神秘的旁观者,拥有独特的洞察力。"
265
+ },
266
+ {
267
+ "id": "buddha-pig",
268
+ "name": "佛猪",
269
+ "description": "施猪,一切随缘",
270
+ "analysis": "你早已看破红尘,主打一个“佛系”。遇事不慌不忙,拒绝精神内耗。凡事不强求,顺其自然,是你应对纷扰世界的最高智慧。"
271
+ },
272
+ {
273
+ "id": "leek-pig",
274
+ "name": "韭菜猪",
275
+ "description": "春风吹又生,被割也不怕",
276
+ "analysis": "你拥有惊人的生命力和乐观精神。无论遭受多少次现实的“收割”和打击,你总能重整旗鼓,满怀希望地再次出发,主打一个坚韧不拔。"
277
+ },
278
+ {
279
+ "id": "lemon-pig",
280
+ "name": "柠檬猪",
281
+ "description": "我承认我酸了",
282
+ "analysis": "你容易化身柠檬精,见人晒幸福就泛酸。其实是因为向往美好,把这份酸味化为动力,去争取属于你的甜蜜吧!"
283
+ },
284
+ {
285
+ "id": "frozen-pig",
286
+ "name": "冷冻猪",
287
+ "description": "物理冷静,心如止水",
288
+ "analysis": "你自带“生人勿近”的高冷气场,习惯将情绪冷冻保存。面对纷扰,你选择像冰块一样坚守自我,虽外表冷硬,内心却渴望那个能融化你的温暖怀抱。"
289
+ },
290
+ {
291
+ "id": "taffy-pig",
292
+ "name": "永猪塔菲",
293
+ "description": "关注永猪塔菲谢谢喵",
294
+ "analysis": "你是猪圈里的顶流偶像,自带赛博天使光环。你精力旺盛,擅长用独特的抽象魅力吸引目光。"
295
+ },
296
+ {
297
+ "id": "dirty-pig",
298
+ "name": "脏猪",
299
+ "description": "洗洗还能要",
300
+ "analysis": "不拘小节,随性洒脱。你不在乎外界眼光,哪怕满身泥泞,也要追求最纯粹的快乐,是懂得自我解压的乐天派。"
301
+ },
302
+ {
303
+ "id": "cyberpunk-pig",
304
+ "name": "赛博朋克猪",
305
+ "description": "赛博猪猪 2077",
306
+ "analysis": "你走在科技与潮流的最前沿,自带炫酷霓虹光环。追求自我升级与进化,不仅拥有超前的思维,更是夜色中最亮眼的未来新星。"
265
307
  }
266
308
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot_plugin_rollpig
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: 今天是什么小猪
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,21 +1,27 @@
1
- nonebot_plugin_rollpig/__init__.py,sha256=BkTa4KmzREAFDwqm_VaEdQJIPxgzwe26lNcVFXmT7A0,5501
1
+ nonebot_plugin_rollpig/__init__.py,sha256=A58M1sibFY4ygSfAjgSfxpboemxDo18c7WZQBFfUtjE,4781
2
2
  nonebot_plugin_rollpig/resource/image/android-pig.png,sha256=WwY2rtsABH8YbDDIoQDR6WdHW8qpStm_lF8eXZ4K-Tc,37845
3
3
  nonebot_plugin_rollpig/resource/image/apple-pig.png,sha256=HSh8SRguD65ZZLnbnTgtNiAqqNzZKuFijtKIC3TLZDU,41533
4
4
  nonebot_plugin_rollpig/resource/image/bacon.png,sha256=7G86_W17C14qCRDKCGuRES4yfidIrIMz2gxOat3Gnn8,55722
5
5
  nonebot_plugin_rollpig/resource/image/big-lazy-pig.png,sha256=XA2Ln4fvdIMfuUcHv0CrQ-nmI09fuqwihlacKnuBR5w,47839
6
6
  nonebot_plugin_rollpig/resource/image/black-pig.png,sha256=f4kTgn_A7Mxr-Rk01cr2yEKO9X91CnyT6Meax9XgliQ,10722
7
7
  nonebot_plugin_rollpig/resource/image/black-white-pig.png,sha256=FJ6rWl2cXgd401Q9xfUQEjuP2Gz4E01dU_PymTjy1DI,19559
8
+ nonebot_plugin_rollpig/resource/image/buddha-pig.png,sha256=m7ToCOlsIBWSXC1iKlyvjSFreia_3EUUdoslAaxFV8c,42130
8
9
  nonebot_plugin_rollpig/resource/image/chained_crown_pig.png,sha256=PzshxnK2sHFFj9EFPvmTpvmcsWlCc0GeivVr-0dDGxo,70576
9
10
  nonebot_plugin_rollpig/resource/image/crystal-pig.png,sha256=MvAGfbJk7YpnG1YAObHldW16Lk7aJj4ym4G91b1nnvI,69523
11
+ nonebot_plugin_rollpig/resource/image/cyberpunk-pig.png,sha256=PhHW6VjZ0a_4aRY-HYd34djfRB-eLqbsmRo7xaT0-w8,2838967
10
12
  nonebot_plugin_rollpig/resource/image/demon-pig.png,sha256=ewUMk7LwztZaf51V7K0C1psiYlr4le6yLbUqOoUpo-Q,12841
13
+ nonebot_plugin_rollpig/resource/image/dirty-pig.png,sha256=LS9MzEYyeApMRobDGxCKhRyUZcUFuZYH08mcp_6oa5c,73711
11
14
  nonebot_plugin_rollpig/resource/image/doll-pig.png,sha256=ZQ3P2temwzlLW78hAxhQjnPiLZqfu94bSA0sbQ_CA_0,66837
12
15
  nonebot_plugin_rollpig/resource/image/explosive-pig.png,sha256=XRM33JxTbQ1Bqw2WgNbMc7IQPVZxObSk8iDXvbZredE,27206
16
+ nonebot_plugin_rollpig/resource/image/frozen-pig.png,sha256=C5aPlWCTldblnqEEOdtYD2Ksld0N_BCzOowTjNAPUoo,51778
13
17
  nonebot_plugin_rollpig/resource/image/goblin-pig.png,sha256=if1Zvs70PIxDKWhhXACvhC1iBkESTg_cLCXvazXfQXc,59660
14
18
  nonebot_plugin_rollpig/resource/image/heaven-pig.png,sha256=040-bRaWpqBRNos1ZJtCK4nex63538JYI0gH99zUQLY,16832
15
19
  nonebot_plugin_rollpig/resource/image/human.png,sha256=y2MZg0Ccf5ixRHDx4fF6UIra6BI2HS5Ta_KRmbWULTI,5318
16
20
  nonebot_plugin_rollpig/resource/image/invisible_pig.png,sha256=GjzA7fGZO7YS-nUqs4TqYh5Di3YupB-mGzzXf4Q0j44,16190
17
21
  nonebot_plugin_rollpig/resource/image/landmine-pig.png,sha256=UD3OMdPLushgE2GloIMyilut0QPoW3ui8_komc4xV-0,66099
18
22
  nonebot_plugin_rollpig/resource/image/lao_zhu_li.png,sha256=qvQvyd1seC1-DDIdtDAlc3vPVxNGCLpcZc6uzmhqZgU,30435
23
+ nonebot_plugin_rollpig/resource/image/leek-pig.png,sha256=oeMtRF0IKs6TDJPI9hRp74A2WRtpfqrs_Aio3SYqTmM,46971
24
+ nonebot_plugin_rollpig/resource/image/lemon-pig.png,sha256=VDthITEwkppJV77eHbXwOC-3DdNq5uNR-ZWCCqMxY5Q,52314
19
25
  nonebot_plugin_rollpig/resource/image/magic-pig.png,sha256=QOA-_NYiVU-9tFDvL1-YrPnyoOshO3VDMNm5nflVWcY,45549
20
26
  nonebot_plugin_rollpig/resource/image/mc_porkchop.png,sha256=M8HF032rs9bbH-3TPB3go-WCrWwtbdZ6QTJamrPfaqM,35825
21
27
  nonebot_plugin_rollpig/resource/image/mechanical-pig.png,sha256=fy0WZeg-P0XDaQlKwYoGeZ3x-yVJ92M8VKLshr9R1qY,27301
@@ -35,6 +41,7 @@ nonebot_plugin_rollpig/resource/image/roasted-pig.png,sha256=KsIVHZslhVP0e3aklKw
35
41
  nonebot_plugin_rollpig/resource/image/skeleton-pig.png,sha256=hAKL6v5W2gyjuHKciEAigIYTlVaMBmASjyYu9gtNdac,38607
36
42
  nonebot_plugin_rollpig/resource/image/snow-pig.png,sha256=IYvo1qUUsKC5JLGcHEcMWroyONO1L4Xcf15eBel-l90,18550
37
43
  nonebot_plugin_rollpig/resource/image/soul-pig.png,sha256=PlAp7k_DneuLpmN79NHqdsd_dM_o9bjmnTN7htzUaDE,13984
44
+ nonebot_plugin_rollpig/resource/image/taffy-pig.png,sha256=9Ttpg0VoqDGV-ldBGOmvBdBNe0T5xMaRNoe7SzSrqD8,59711
38
45
  nonebot_plugin_rollpig/resource/image/tangyuan_pig.png,sha256=igvJN9grj_hBDeKampFa6WJTg4VjrkyxpUdWzq4AoNk,1640768
39
46
  nonebot_plugin_rollpig/resource/image/tank_pig.png,sha256=tKJ7Lowe1zo3eRH1N7ngKIPretGMW5UV7EaTVmbUYkg,52611
40
47
  nonebot_plugin_rollpig/resource/image/taxi-pig.png,sha256=d75kqIQbQK7U64SV4oKwnXMxKTCgmheo14gP1kmu7Zg,54313
@@ -43,9 +50,9 @@ nonebot_plugin_rollpig/resource/image/watermelon-pig.png,sha256=Fuoe-svB661glzMe
43
50
  nonebot_plugin_rollpig/resource/image/wild-boar.png,sha256=daBhmLS0SFVqhYtn12QsNjg1KzNh5oiuI7wFN-J4xbM,13378
44
51
  nonebot_plugin_rollpig/resource/image/zhuge-liang.png,sha256=yvF5hNUzBXJIHi-vwg5f4YD_aEtqUJeIarpyiNReios,49905
45
52
  nonebot_plugin_rollpig/resource/image/zombie-pig.png,sha256=fKQlp_kI3x8wMlVUT6U-rilMLpH0TpT_-ViNVWBSbcM,20797
46
- nonebot_plugin_rollpig/resource/pig.json,sha256=0YHz5eLZOSwo-3Yh44UgXrZ4vTmpvSDMx9Ejh0htlxM,13236
53
+ nonebot_plugin_rollpig/resource/pig.json,sha256=FIuYbjzEfUPwbIBgAYLIovByKOn3fU2HGdkda9KIPyI,15408
47
54
  nonebot_plugin_rollpig/resource/template.html,sha256=vX7vbT3BmmsXhswiUIHqHNLds_CcUQIuZKdnz5bVthc,1060
48
- nonebot_plugin_rollpig-0.2.4.dist-info/licenses/LICENSE,sha256=zn7XqavdCw11Nln_m8Eu0S7C3rZ9C-VGbqbrVGeSTGg,1087
49
- nonebot_plugin_rollpig-0.2.4.dist-info/METADATA,sha256=Ewp0ze1G1_24hTqyDlWkcA-xYhgRH_i9_igiBFRlAng,2720
50
- nonebot_plugin_rollpig-0.2.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
51
- nonebot_plugin_rollpig-0.2.4.dist-info/RECORD,,
55
+ nonebot_plugin_rollpig-0.2.6.dist-info/licenses/LICENSE,sha256=zn7XqavdCw11Nln_m8Eu0S7C3rZ9C-VGbqbrVGeSTGg,1087
56
+ nonebot_plugin_rollpig-0.2.6.dist-info/METADATA,sha256=PP8rkuqyn6dehQelL1_Gyc3MDijW7kGwzQeNw0mThNk,2720
57
+ nonebot_plugin_rollpig-0.2.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
58
+ nonebot_plugin_rollpig-0.2.6.dist-info/RECORD,,