hyper-bot 0.82.1__tar.gz → 0.82.2__tar.gz

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.
Files changed (38) hide show
  1. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/PKG-INFO +1 -1
  2. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyper_bot.egg-info/PKG-INFO +1 -1
  3. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/Milky.py +12 -2
  4. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/OneBot.py +19 -8
  5. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/__init__.py +52 -24
  6. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/listener.py +12 -2
  7. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/LICENSE +0 -0
  8. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyper_bot.egg-info/SOURCES.txt +0 -0
  9. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyper_bot.egg-info/dependency_links.txt +0 -0
  10. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyper_bot.egg-info/requires.txt +0 -0
  11. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyper_bot.egg-info/top_level.txt +0 -0
  12. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/MilkyLib/Manager.py +0 -0
  13. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/MilkyLib/Res.py +0 -0
  14. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/MilkyLib/translator.py +0 -0
  15. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/OneBotLib/Manager.py +0 -0
  16. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/LecAdapters/OneBotLib/Res.py +0 -0
  17. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/__init__.py +0 -0
  18. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/builtins.py +0 -0
  19. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/common.py +0 -0
  20. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/obuilder.py +0 -0
  21. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/adapters/res.py +0 -0
  22. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/common.py +0 -0
  23. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/configurator.py +0 -0
  24. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/events.py +0 -0
  25. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/hyperogger.py +0 -0
  26. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/listener.py +0 -0
  27. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/network.py +0 -0
  28. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/segments.py +0 -0
  29. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/service.py +0 -0
  30. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/ArkSignHelper.py +0 -0
  31. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/apiresponse.py +0 -0
  32. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/errors.py +0 -0
  33. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/hypetyping.py +0 -0
  34. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/logic.py +0 -0
  35. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/screens.py +0 -0
  36. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/hyperot/utils/typextensions.py +0 -0
  37. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/setup.cfg +0 -0
  38. {hyper_bot-0.82.1 → hyper_bot-0.82.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyper-bot
3
- Version: 0.82.1
3
+ Version: 0.82.2
4
4
  Summary: 稳定高效、易于开发的QQ Bot框架
5
5
  Home-page: https://github.com/HarcicYang/HypeR_Bot
6
6
  Author: Harcic
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyper-bot
3
- Version: 0.82.1
3
+ Version: 0.82.2
4
4
  Summary: 稳定高效、易于开发的QQ Bot框架
5
5
  Home-page: https://github.com/HarcicYang/HypeR_Bot
6
6
  Author: Harcic
@@ -40,7 +40,7 @@ class Actions:
40
40
 
41
41
  self.custom = CustomAction(self.connection)
42
42
 
43
- async def send(
43
+ async def send_msg(
44
44
  self, message: Union[common.Message, str], group_id: int = None, user_id: int = None
45
45
  ) -> common.Ret[MsgSendRsp]:
46
46
  if group_id is None:
@@ -65,8 +65,18 @@ class Actions:
65
65
  ret = common.Ret(res)
66
66
  ret.data = MsgSendRsp({"message_id": msg_enid(1, res["message_seq"], group_id)})
67
67
  return ret
68
+
69
+ async def send_group_msg(
70
+ self, message: Union[common.Message, str], group_id: int = None
71
+ ) -> common.Ret[MsgSendRsp]:
72
+ return await self.send_msg(message, group_id=group_id)
68
73
 
69
- async def del_message(self, message_id: int) -> None:
74
+ async def send_private_msg(
75
+ self, message: Union[common.Message, str], user_id: int = None
76
+ ) -> common.Ret[MsgSendRsp]:
77
+ return await self.send_msg(message, user_id=user_id)
78
+
79
+ async def del_msg(self, message_id: int) -> None:
70
80
  ...
71
81
 
72
82
  async def set_group_kick(self, group_id: int, user_id: int) -> None:
@@ -1,5 +1,4 @@
1
1
  import json
2
- import threading
3
2
  import time
4
3
  import asyncio
5
4
  import sys
@@ -11,7 +10,7 @@ from ..utils import errors, logic
11
10
  from ..utils.apiresponse import *
12
11
  from ..LecAdapters.OneBotLib.Manager import reports, Packet
13
12
  from ..events import *
14
- from ..utils.hypetyping import Any, Union, NoReturn
13
+ from ..utils.hypetyping import Any, Union, NoReturn, Callable
15
14
 
16
15
  config = configurator.BotConfig.get("hyper-bot")
17
16
  logger = hyperogger.Logger()
@@ -27,7 +26,7 @@ class Actions:
27
26
  def __init__(self, cnt_i: Union[network.WebsocketConnection, network.HTTPConnection]):
28
27
  self.connection = cnt_i
29
28
 
30
- def __getattr__(self, item) -> callable:
29
+ def __getattr__(self, item) -> Callable:
31
30
  async def wrapper(**kwargs) -> str:
32
31
  packet = Packet(
33
32
  str(item),
@@ -40,7 +39,7 @@ class Actions:
40
39
 
41
40
  self.custom = CustomAction(self.connection)
42
41
 
43
- async def send(
42
+ async def send_msg(
44
43
  self, message: Union[common.Message, str], group_id: int = None, user_id: int = None
45
44
  ) -> common.Ret[MsgSendRsp]:
46
45
  if isinstance(message, str):
@@ -63,7 +62,17 @@ class Actions:
63
62
  logger.info(f"向{(('群 ' + str(group_id)) if group_id else ('用户' + str(user_id))) + ' '}发送:{str(message)}")
64
63
  return await common.Ret.fetch(packet.echo, MsgSendRsp)
65
64
 
66
- async def del_message(self, message_id: int) -> None:
65
+ async def send_group_msg(
66
+ self, message: Union[common.Message, str], group_id: int = None
67
+ ) -> common.Ret[MsgSendRsp]:
68
+ return await self.send_msg(message, group_id=group_id)
69
+
70
+ async def send_private_msg(
71
+ self, message: Union[common.Message, str], user_id: int = None
72
+ ) -> common.Ret[MsgSendRsp]:
73
+ return await self.send_msg(message, user_id=user_id)
74
+
75
+ async def del_msg(self, message_id: int) -> None:
67
76
  await Packet(
68
77
  "delete_msg",
69
78
  message_id=message_id,
@@ -227,10 +236,10 @@ async def __handler(data: Union[dict, HyperNotify], actions: Actions) -> None:
227
236
  await handler(data, actions)
228
237
 
229
238
 
230
- handler: callable = tester
239
+ handler: Callable = tester
231
240
 
232
241
 
233
- def reg(func: callable) -> None:
242
+ def reg(func: Callable) -> None:
234
243
  global handler
235
244
  handler = func
236
245
 
@@ -244,6 +253,8 @@ class LagrangeOneBotService(IServiceBase):
244
253
  pass
245
254
 
246
255
  async def server(self, bot_config: configurator.BotConfig) -> None:
256
+ if isinstance(config.connection, dict):
257
+ raise errors.ListenerNotRegisteredError("未注册接收器")
247
258
  proc = subprocess.Popen(
248
259
  args=config.connection.ob_exec,
249
260
  cwd=config.connection.ob_startup_path,
@@ -274,7 +285,7 @@ async def run() -> NoReturn:
274
285
  while True:
275
286
  try:
276
287
  connection.connect()
277
- except ConnectionRefusedError or TimeoutError:
288
+ except (ConnectionRefusedError, TimeoutError):
278
289
  if retried >= config.connection.retries:
279
290
  logger.critical(f"重试次数达到最大值({config.connection.retries}),退出")
280
291
  break
@@ -1,19 +1,38 @@
1
- import signal
2
1
  from . import configurator
3
2
  from .utils import screens
4
3
 
5
- from typing import Union
4
+ from typing import Union, Callable
6
5
  import asyncio
7
6
  import sys
8
7
  import os
8
+ import signal
9
9
 
10
- HYPER_BOT_VERSION = "0.82.1"
10
+ HYPER_BOT_VERSION = "0.82.2"
11
11
 
12
12
  # listener = None
13
13
 
14
14
  screens.play_startup()
15
15
  screens.play_info(HYPER_BOT_VERSION)
16
16
 
17
+ ANY_EVENT = Union[
18
+ "events.GroupMessageEvent",
19
+ "events.PrivateMessageEvent",
20
+ "events.GroupFileUploadEvent",
21
+ "events.GroupAdminEvent",
22
+ "events.GroupMemberDecreaseEvent",
23
+ "events.GroupMemberIncreaseEvent",
24
+ "events.GroupMuteEvent",
25
+ "events.FriendAddEvent",
26
+ "events.GroupRecallEvent",
27
+ "events.FriendRecallEvent",
28
+ "events.NotifyEvent",
29
+ "events.GroupEssenceEvent",
30
+ "events.MessageReactionEvent",
31
+ "events.GroupAddInviteEvent",
32
+ "events.HyperListenerStartNotify",
33
+ "events.HyperListenerStopNotify"
34
+ ]
35
+
17
36
 
18
37
  class Client:
19
38
  def __init__(self):
@@ -22,26 +41,16 @@ class Client:
22
41
 
23
42
  def subscribe(
24
43
  self,
25
- func: callable,
26
- event: Union[
27
- "events.GroupMessageEvent",
28
- "events.PrivateMessageEvent",
29
- "events.GroupFileUploadEvent",
30
- "events.GroupAdminEvent",
31
- "events.GroupMemberDecreaseEvent",
32
- "events.GroupMemberIncreaseEvent",
33
- "events.GroupMuteEvent",
34
- "events.FriendAddEvent",
35
- "events.GroupRecallEvent",
36
- "events.FriendRecallEvent",
37
- "events.NotifyEvent",
38
- "events.GroupEssenceEvent",
39
- "events.MessageReactionEvent",
40
- "events.GroupAddInviteEvent",
41
- "events.HyperListenerStartNotify",
42
- "events.HyperListenerStopNotify"
43
- ]
44
+ func: Callable,
45
+ event: Union[ANY_EVENT, list[ANY_EVENT]]
44
46
  ) -> None:
47
+ if isinstance(event, list):
48
+ for e in event:
49
+ self._subscribe(func, e)
50
+ else:
51
+ self._subscribe(func, event)
52
+
53
+ def _subscribe(self, func: Callable, event: ANY_EVENT) -> None:
45
54
  if not self.records.get(event):
46
55
  self.records[event] = [func]
47
56
  else:
@@ -65,10 +74,29 @@ class Client:
65
74
  if self.records:
66
75
  stop = asyncio.Event()
67
76
  loop = asyncio.get_running_loop()
68
- for i in (signal.SIGINT, signal.SIGTERM):
69
- loop.add_signal_handler(i, stop.set)
77
+ _wakeup_task = None
78
+ if sys.platform == "win32":
79
+ def _win32_handler(signum, frame):
80
+ stop.set()
81
+
82
+ signal.signal(signal.SIGINT, _win32_handler)
83
+ try:
84
+ signal.signal(signal.SIGBREAK, _win32_handler)
85
+ except AttributeError:
86
+ pass
87
+
88
+ async def _win32_wakeup():
89
+ while 1:
90
+ await asyncio.sleep(0.1)
91
+
92
+ _wakeup_task = asyncio.create_task(_win32_wakeup())
93
+ else:
94
+ for i in (signal.SIGINT, signal.SIGTERM):
95
+ loop.add_signal_handler(i, stop.set)
70
96
  task = asyncio.create_task(self.lis.run())
71
97
  await stop.wait()
98
+ if _wakeup_task:
99
+ _wakeup_task.cancel()
72
100
  task.cancel()
73
101
  try:
74
102
  await task
@@ -12,12 +12,22 @@ class Actions:
12
12
  def __init__(self):
13
13
  self.custom: type
14
14
 
15
- async def send(
15
+ async def send_msg(
16
16
  self, message: Union[common.Message, str], group_id: int = None, user_id: int = None
17
17
  ) -> common.Ret[MsgSendRsp]:
18
18
  ...
19
19
 
20
- async def del_message(self, message_id: int) -> None:
20
+ async def send_group_msg(
21
+ self, message: Union[common.Message, str], group_id: int = None
22
+ ) -> common.Ret[MsgSendRsp]:
23
+ ...
24
+
25
+ async def send_private_msg(
26
+ self, message: Union[common.Message, str], user_id: int = None
27
+ ) -> common.Ret[MsgSendRsp]:
28
+ ...
29
+
30
+ async def del_msg(self, message_id: int) -> None:
21
31
  ...
22
32
 
23
33
  async def set_group_kick(self, group_id: int, user_id: int) -> None:
File without changes
File without changes
File without changes
File without changes
File without changes