hyper-bot 0.79.5__tar.gz → 0.80.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 (53) hide show
  1. {hyper_bot-0.79.5 → hyper_bot-0.80.2}/PKG-INFO +3 -1
  2. {hyper_bot-0.79.5 → hyper_bot-0.80.2}/hyper_bot.egg-info/PKG-INFO +3 -1
  3. hyper_bot-0.80.2/hyper_bot.egg-info/SOURCES.txt +44 -0
  4. hyper_bot-0.80.2/hyper_bot.egg-info/requires.txt +1 -0
  5. hyper_bot-0.80.2/hyper_bot.egg-info/top_level.txt +1 -0
  6. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/Kritor.py +30 -31
  7. hyper_bot-0.80.2/hyperot/Adapters/KritorLib/Manager.py +1 -0
  8. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/Res.py +4 -4
  9. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/OneBot.py +67 -77
  10. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/OneBotLib/Manager.py +11 -12
  11. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/OneBotLib/Res.py +1 -2
  12. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/__init__.py +5 -5
  13. hyper_bot-0.79.5/Hyper/Comm.py → hyper_bot-0.80.2/hyperot/common.py +11 -12
  14. hyper_bot-0.79.5/Hyper/Configurator.py → hyper_bot-0.80.2/hyperot/configurator.py +1 -0
  15. hyper_bot-0.79.5/Hyper/Events.py → hyper_bot-0.80.2/hyperot/events.py +11 -23
  16. hyper_bot-0.80.2/hyperot/hyperogger.py +133 -0
  17. hyper_bot-0.79.5/Hyper/Listener.py → hyper_bot-0.80.2/hyperot/listener.py +7 -7
  18. hyper_bot-0.79.5/Hyper/Network.py → hyper_bot-0.80.2/hyperot/network.py +3 -3
  19. hyper_bot-0.79.5/Hyper/Segments.py → hyper_bot-0.80.2/hyperot/segments.py +7 -7
  20. {hyper_bot-0.79.5/Hyper/Utils → hyper_bot-0.80.2/hyperot/utils}/ArkSignHelper.py +2 -3
  21. hyper_bot-0.79.5/Hyper/Utils/APIRsp.py → hyper_bot-0.80.2/hyperot/utils/apiresponse.py +2 -2
  22. hyper_bot-0.79.5/Hyper/Utils/HyperTyping.py → hyper_bot-0.80.2/hyperot/utils/hypetyping.py +1 -1
  23. hyper_bot-0.79.5/Hyper/Utils/Logic.py → hyper_bot-0.80.2/hyperot/utils/logic.py +4 -112
  24. hyper_bot-0.79.5/Hyper/Utils/Screens.py → hyper_bot-0.80.2/hyperot/utils/screens.py +24 -1
  25. hyper_bot-0.79.5/Hyper/Utils/TypeExt.py → hyper_bot-0.80.2/hyperot/utils/typextensions.py +0 -19
  26. hyper_bot-0.80.2/setup.py +28 -0
  27. hyper_bot-0.79.5/Hyper/Adapters/KritorLib/Manager.py +0 -1
  28. hyper_bot-0.79.5/Hyper/Adapters/LagrangePy.py +0 -117
  29. hyper_bot-0.79.5/Hyper/Adapters/Satori.py +0 -107
  30. hyper_bot-0.79.5/Hyper/Logger.py +0 -226
  31. hyper_bot-0.79.5/hyper_bot.egg-info/SOURCES.txt +0 -45
  32. hyper_bot-0.79.5/hyper_bot.egg-info/top_level.txt +0 -1
  33. hyper_bot-0.79.5/setup.py +0 -26
  34. {hyper_bot-0.79.5 → hyper_bot-0.80.2}/LICENSE +0 -0
  35. {hyper_bot-0.79.5 → hyper_bot-0.80.2}/hyper_bot.egg-info/dependency_links.txt +0 -0
  36. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/__init__.py +0 -0
  37. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/authentication/__init__.py +0 -0
  38. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/common/__init__.py +0 -0
  39. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/core/__init__.py +0 -0
  40. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/customization/__init__.py +0 -0
  41. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/developer/__init__.py +0 -0
  42. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/event/__init__.py +0 -0
  43. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/file/__init__.py +0 -0
  44. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/friend/__init__.py +0 -0
  45. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/group/__init__.py +0 -0
  46. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/guild/__init__.py +0 -0
  47. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/message/__init__.py +0 -0
  48. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/process/__init__.py +0 -0
  49. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/reverse/__init__.py +0 -0
  50. {hyper_bot-0.79.5/Hyper → hyper_bot-0.80.2/hyperot}/Adapters/KritorLib/protos/web/__init__.py +0 -0
  51. /hyper_bot-0.79.5/Hyper/Service.py → /hyper_bot-0.80.2/hyperot/service.py +0 -0
  52. /hyper_bot-0.79.5/Hyper/Utils/Errors.py → /hyper_bot-0.80.2/hyperot/utils/errors.py +0 -0
  53. {hyper_bot-0.79.5 → hyper_bot-0.80.2}/setup.cfg +0 -0
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyper-bot
3
- Version: 0.79.5
3
+ Version: 0.80.2
4
4
  Summary: 稳定高效、易于开发的QQ Bot框架
5
5
  Home-page: https://github.com/HarcicYang/HypeR_Bot
6
6
  Author: Harcic
7
7
  Author-email: harcic@outlook.com
8
+ Provides: hyperot
8
9
  License-File: LICENSE
10
+ Requires-Dist: ucfgr
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyper-bot
3
- Version: 0.79.5
3
+ Version: 0.80.2
4
4
  Summary: 稳定高效、易于开发的QQ Bot框架
5
5
  Home-page: https://github.com/HarcicYang/HypeR_Bot
6
6
  Author: Harcic
7
7
  Author-email: harcic@outlook.com
8
+ Provides: hyperot
8
9
  License-File: LICENSE
10
+ Requires-Dist: ucfgr
@@ -0,0 +1,44 @@
1
+ LICENSE
2
+ setup.py
3
+ hyper_bot.egg-info/PKG-INFO
4
+ hyper_bot.egg-info/SOURCES.txt
5
+ hyper_bot.egg-info/dependency_links.txt
6
+ hyper_bot.egg-info/requires.txt
7
+ hyper_bot.egg-info/top_level.txt
8
+ hyperot/__init__.py
9
+ hyperot/common.py
10
+ hyperot/configurator.py
11
+ hyperot/events.py
12
+ hyperot/hyperogger.py
13
+ hyperot/listener.py
14
+ hyperot/network.py
15
+ hyperot/segments.py
16
+ hyperot/service.py
17
+ hyperot/Adapters/Kritor.py
18
+ hyperot/Adapters/OneBot.py
19
+ hyperot/Adapters/KritorLib/Manager.py
20
+ hyperot/Adapters/KritorLib/Res.py
21
+ hyperot/Adapters/KritorLib/protos/__init__.py
22
+ hyperot/Adapters/KritorLib/protos/authentication/__init__.py
23
+ hyperot/Adapters/KritorLib/protos/common/__init__.py
24
+ hyperot/Adapters/KritorLib/protos/core/__init__.py
25
+ hyperot/Adapters/KritorLib/protos/customization/__init__.py
26
+ hyperot/Adapters/KritorLib/protos/developer/__init__.py
27
+ hyperot/Adapters/KritorLib/protos/event/__init__.py
28
+ hyperot/Adapters/KritorLib/protos/file/__init__.py
29
+ hyperot/Adapters/KritorLib/protos/friend/__init__.py
30
+ hyperot/Adapters/KritorLib/protos/group/__init__.py
31
+ hyperot/Adapters/KritorLib/protos/guild/__init__.py
32
+ hyperot/Adapters/KritorLib/protos/message/__init__.py
33
+ hyperot/Adapters/KritorLib/protos/process/__init__.py
34
+ hyperot/Adapters/KritorLib/protos/reverse/__init__.py
35
+ hyperot/Adapters/KritorLib/protos/web/__init__.py
36
+ hyperot/Adapters/OneBotLib/Manager.py
37
+ hyperot/Adapters/OneBotLib/Res.py
38
+ hyperot/utils/ArkSignHelper.py
39
+ hyperot/utils/apiresponse.py
40
+ hyperot/utils/errors.py
41
+ hyperot/utils/hypetyping.py
42
+ hyperot/utils/logic.py
43
+ hyperot/utils/screens.py
44
+ hyperot/utils/typextensions.py
@@ -0,0 +1 @@
1
+ ucfgr
@@ -0,0 +1 @@
1
+ hyperot
@@ -4,27 +4,27 @@ import sys
4
4
  import threading
5
5
  import time
6
6
 
7
- from Hyper import Comm
8
- from Hyper.Adapters.OneBot import Actions as OneBotActions
9
- from Hyper.Adapters.KritorLib.Res import event_queue, to_protos, message_ids
10
- from Hyper.Events import Event, HyperNotify, HyperListenerStartNotify, em
11
- from Hyper.Service import FuncCall, IServiceStartUp, IServiceBase
12
- from Hyper.Network import KritorConnection
13
- from Hyper.Utils import Errors
14
- from Hyper.Utils.APIRsp import *
15
- from Hyper import Configurator, Logger
16
-
17
- from Hyper.Adapters.KritorLib.protos.common import Contact, Scene
18
- from Hyper.Adapters.KritorLib.protos.core import GetVersionRequest, CoreServiceStub
19
- from Hyper.Adapters.KritorLib.protos.message import (
7
+ from .. import common
8
+ from ..Adapters.OneBot import Actions as OneBotActions
9
+ from ..Adapters.KritorLib.Res import event_queue, to_protos, message_ids
10
+ from ..events import Event, HyperNotify, HyperListenerStartNotify, em
11
+ from ..service import FuncCall, IServiceStartUp, IServiceBase
12
+ from ..network import KritorConnection
13
+ from ..utils import errors
14
+ from ..utils.apiresponse import *
15
+ from .. import configurator, hyperogger
16
+
17
+ from ..Adapters.KritorLib.protos.common import Contact, Scene
18
+ from ..Adapters.KritorLib.protos.core import GetVersionRequest, CoreServiceStub
19
+ from ..Adapters.KritorLib.protos.message import (
20
20
  MessageServiceStub,
21
21
  SendMessageRequest,
22
22
  RecallMessageRequest,
23
23
  GetMessageRequest
24
24
  )
25
25
 
26
- config = Configurator.BotConfig.get("hyper-bot")
27
- logger = Logger.Logger()
26
+ config = configurator.BotConfig.get("hyper-bot")
27
+ logger = hyperogger.Logger()
28
28
  logger.set_level(config.log_level)
29
29
 
30
30
 
@@ -41,10 +41,9 @@ class Actions(OneBotActions):
41
41
  def __init__(self, cnt: KritorConnection):
42
42
  self.connection = cnt
43
43
 
44
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().send, logger)
45
44
  async def send(
46
- self, message: Comm.Message, group_id: int = None, user_id: int = None
47
- ) -> Comm.Ret[MsgSendRsp]:
45
+ self, message: common.Message, group_id: int = None, user_id: int = None
46
+ ) -> common.Ret[MsgSendRsp]:
48
47
  msg = to_protos(message.get_sync())
49
48
  if group_id is not None:
50
49
  contact = Contact(
@@ -63,19 +62,19 @@ class Actions(OneBotActions):
63
62
  )
64
63
  res = await MessageServiceStub(self.connection.channel).send_message(req)
65
64
  message_ids[res.message_id] = len(message_ids)
66
- return Comm.Ret(
65
+ return common.Ret(
67
66
  {"data": {"message_id": message_ids[res.message_id]}},
68
67
  MsgSendRsp
69
68
  )
70
69
 
71
- async def get_version_info(self) -> Comm.Ret[GetVerInfoRsp]:
70
+ async def get_version_info(self) -> common.Ret[GetVerInfoRsp]:
72
71
  res = await CoreServiceStub(self.connection.channel).get_version(GetVersionRequest())
73
- return Comm.Ret(
72
+ return common.Ret(
74
73
  {"data": {"app_name": res.app_name, "app_version": res.version, "protocol_version": None}},
75
74
  GetVerInfoRsp
76
75
  )
77
76
 
78
- async def get_msg(self, msg_id: int) -> Comm.Ret[GetMsgRsp]:
77
+ async def get_msg(self, msg_id: int) -> common.Ret[GetMsgRsp]:
79
78
  try:
80
79
  mid = list(filter(lambda x: message_ids[x] == msg_id, message_ids))[1]
81
80
  except IndexError:
@@ -87,7 +86,7 @@ class Actions(OneBotActions):
87
86
  )
88
87
  res = await MessageServiceStub(self.connection.channel).get_message(GetMessageRequest(contact, mid))
89
88
  print(res)
90
- return Comm.Ret(
89
+ return common.Ret(
91
90
  {
92
91
  "time": res.message.time,
93
92
  "message_type": "group",
@@ -113,7 +112,7 @@ class Actions(OneBotActions):
113
112
  peer=str(mid_res(mid)[1]),
114
113
  )
115
114
  res = await MessageServiceStub(self.connection.channel).get_message(GetMessageRequest(contact, mid))
116
- return Comm.Ret(
115
+ return common.Ret(
117
116
  {
118
117
  "time": res.message.time,
119
118
  "message_type": "private",
@@ -178,7 +177,7 @@ def run():
178
177
  async def hy_i_runner():
179
178
  global connection
180
179
  if handler is tester:
181
- raise Errors.ListenerNotRegisteredError("No handler registered")
180
+ raise errors.ListenerNotRegisteredError("No handler registered")
182
181
  # connection = websocket.WebSocket()
183
182
  # if isinstance(config.connection, Configurator.WSConnectionC):
184
183
  # connection = Network.WebsocketConnection(f"ws://{config.connection.host}:{config.connection.port}")
@@ -198,15 +197,15 @@ def run():
198
197
  except ConnectionRefusedError or TimeoutError:
199
198
  if retried >= config.connection.retries:
200
199
  logger.log(f"重试次数达到最大值({config.connection.retries}),退出",
201
- level=Logger.levels.CRITICAL)
200
+ level=hyperogger.levels.CRITICAL)
202
201
  break
203
202
 
204
203
  logger.log(f"连接建立失败,3秒后重试({retried}/{config.connection.retries})",
205
- level=Logger.levels.WARNING)
204
+ level=hyperogger.levels.WARNING)
206
205
  retried += 1
207
206
  time.sleep(3)
208
207
  continue
209
- logger.log("成功建立连接", level=Logger.levels.INFO)
208
+ logger.log("成功建立连接", level=hyperogger.levels.INFO)
210
209
  retried = 0
211
210
  actions = Actions(connection)
212
211
  data = HyperListenerStartNotify(
@@ -223,7 +222,7 @@ def run():
223
222
  await task
224
223
  except ConnectionResetError:
225
224
  task = None
226
- logger.log("连接断开", level=Logger.levels.ERROR)
225
+ logger.log("连接断开", level=hyperogger.levels.ERROR)
227
226
  break
228
227
  # threading.Thread(target=lambda: asyncio.run(__handler(data, actions))).start()
229
228
  # threading.Thread(target=lambda: __handler(data, actions)).start()
@@ -232,7 +231,7 @@ def run():
232
231
  try:
233
232
  asyncio.get_event_loop().run_until_complete(hy_i_runner())
234
233
  except KeyboardInterrupt:
235
- logger.log("正在退出(Ctrl+C)", level=Logger.levels.WARNING)
234
+ logger.log("正在退出(Ctrl+C)", level=hyperogger.levels.WARNING)
236
235
  sys.exit()
237
236
 
238
237
 
@@ -241,4 +240,4 @@ def stop() -> None:
241
240
  connection.close()
242
241
  except:
243
242
  pass
244
- logger.log("停止运行监听器", level=Logger.levels.WARNING)
243
+ logger.log("停止运行监听器", level=hyperogger.levels.WARNING)
@@ -0,0 +1 @@
1
+ from ...Adapters.OneBotLib.Manager import *
@@ -1,4 +1,4 @@
1
- from Hyper.Adapters.KritorLib.protos.event import (
1
+ from ...Adapters.KritorLib.protos.event import (
2
2
  EventServiceStub,
3
3
  RequestPushEvent,
4
4
  EventType,
@@ -7,7 +7,7 @@ from Hyper.Adapters.KritorLib.protos.event import (
7
7
  GroupMemberDecreasedNoticeGroupMemberDecreasedType,
8
8
  GroupMemberIncreasedNoticeGroupMemberIncreasedType
9
9
  )
10
- from Hyper.Adapters.KritorLib.protos.common import (
10
+ from ...Adapters.KritorLib.protos.common import (
11
11
  ElementElementType,
12
12
  PushMessageBody,
13
13
  Scene, Element,
@@ -18,8 +18,8 @@ from Hyper.Adapters.KritorLib.protos.common import (
18
18
  VoiceElement,
19
19
  ImageElement
20
20
  )
21
- from Hyper.Configurator import BotConfig
22
- from Hyper.Utils.Logic import SimpleQueue
21
+ from ...configurator import BotConfig
22
+ from ...utils.logic import SimpleQueue
23
23
 
24
24
  import traceback
25
25
  import asyncio
@@ -5,33 +5,31 @@ import asyncio
5
5
  import sys
6
6
  import subprocess
7
7
  from typing import Any, NoReturn
8
- # from concurrent.futures import ThreadPoolExecutor
9
8
 
10
- from Hyper import Network, Events, Comm
11
- from Hyper.Service import FuncCall, IServiceBase, IServiceStartUp
12
- from Hyper.Utils import Errors, Logic
13
- from Hyper.Utils.APIRsp import *
14
- from Hyper.Adapters.OneBotLib.Manager import reports
15
- from Hyper.Events import *
9
+ from .. import network, events, common, segments
10
+ from ..service import FuncCall, IServiceBase, IServiceStartUp
11
+ from ..utils import errors, logic
12
+ from ..utils.apiresponse import *
13
+ from ..Adapters.OneBotLib.Manager import reports
14
+ from ..events import *
16
15
 
17
- config = Configurator.BotConfig.get("hyper-bot")
18
- logger = Logger.Logger()
16
+ config = configurator.BotConfig.get("hyper-bot")
17
+ logger = hyperogger.Logger()
19
18
  logger.set_level(config.log_level)
20
- # pool = ThreadPoolExecutor(max_workers=config.max_workers)
21
19
  listener_ran = False
22
20
 
23
21
 
24
22
  class Actions:
25
- def __init__(self, cnt: Union[Network.WebsocketConnection, Network.HTTPConnection]):
23
+ def __init__(self, cnt: Union[network.WebsocketConnection, network.HTTPConnection]):
26
24
  self.connection = cnt
27
25
 
28
26
  class CustomAction:
29
- def __init__(self, cnt_i: Union[Network.WebsocketConnection, Network.HTTPConnection]):
27
+ def __init__(self, cnt_i: Union[network.WebsocketConnection, network.HTTPConnection]):
30
28
  self.connection = cnt_i
31
29
 
32
30
  def __getattr__(self, item) -> callable:
33
31
  async def wrapper(**kwargs) -> str:
34
- packet = Comm.Packet(
32
+ packet = common.Packet(
35
33
  str(item),
36
34
  **kwargs
37
35
  )
@@ -42,148 +40,144 @@ class Actions:
42
40
 
43
41
  self.custom = CustomAction(self.connection)
44
42
 
45
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().send, logger)
46
43
  async def send(
47
- self, message: Comm.Message, group_id: int = None, user_id: int = None
48
- ) -> Comm.Ret[MsgSendRsp]:
44
+ self, message: Union[common.Message, str], group_id: int = None, user_id: int = None
45
+ ) -> common.Ret[MsgSendRsp]:
49
46
  if group_id is not None:
50
- packet = Comm.Packet(
47
+ if isinstance(message, str):
48
+ message = common.Message(segments.Text(message))
49
+ packet = common.Packet(
51
50
  "send_msg",
52
51
  group_id=group_id,
53
52
  message=await message.get()
54
53
  )
55
54
  elif user_id is not None:
56
- packet = Comm.Packet(
55
+ packet = common.Packet(
57
56
  "send_msg",
58
57
  user_id=user_id,
59
58
  message=await message.get()
60
59
  )
61
60
  else:
62
- raise Errors.ArgsInvalidError("'send' API requires 'group_id' or 'user_id' but none of them are provided.")
61
+ raise errors.ArgsInvalidError("'send' API requires 'group_id' or 'user_id' but none of them are provided.")
63
62
  packet.send_to(self.connection)
64
- return Comm.Ret.fetch(packet.echo, MsgSendRsp)
63
+ logger.info(f"向{(('群 ' + str(group_id)) if group_id else ('用户' + str(user_id))) + ' '}发送:{str(message)}")
64
+ return common.Ret.fetch(packet.echo, MsgSendRsp)
65
65
 
66
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().recall, logger)
67
66
  async def del_message(self, message_id: int) -> None:
68
- Comm.Packet(
67
+ common.Packet(
69
68
  "delete_msg",
70
69
  message_id=message_id,
71
70
  ).send_to(self.connection)
71
+ logger.info(f"撤回 {message_id}")
72
72
 
73
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().kick, logger)
74
73
  async def set_group_kick(self, group_id: int, user_id: int) -> None:
75
- Comm.Packet(
74
+ common.Packet(
76
75
  "set_group_kick",
77
76
  group_id=group_id,
78
77
  user_id=user_id,
79
78
  ).send_to(self.connection)
79
+ logger.info(f"将用户 {user_id} 移出群 {group_id}")
80
80
 
81
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().mute, logger)
82
81
  async def set_group_ban(self, group_id: int, user_id: int, duration: int = 60) -> None:
83
- Comm.Packet(
82
+ common.Packet(
84
83
  "set_group_ban",
85
84
  group_id=group_id,
86
85
  user_id=user_id,
87
86
  duration=duration,
88
87
  ).send_to(self.connection)
88
+ logger.info(f"在群 {group_id} 将用户 {user_id} 禁言 {duration}s")
89
89
 
90
- @Logic.Cacher().cache_async
91
- async def get_login_info(self) -> Comm.Ret[GetLoginInfoRsp]:
92
- packet = Comm.Packet("get_login_info")
90
+ async def get_login_info(self) -> common.Ret[GetLoginInfoRsp]:
91
+ packet = common.Packet("get_login_info")
93
92
  packet.send_to(self.connection)
94
- return Comm.Ret.fetch(packet.echo, GetLoginInfoRsp)
93
+ return common.Ret.fetch(packet.echo, GetLoginInfoRsp)
95
94
 
96
- @Logic.Cacher().cache_async
97
- async def get_version_info(self) -> Comm.Ret[GetVerInfoRsp]:
98
- packet = Comm.Packet("get_version_info")
95
+ async def get_version_info(self) -> common.Ret[GetVerInfoRsp]:
96
+ packet = common.Packet("get_version_info")
99
97
  packet.send_to(self.connection)
100
- return Comm.Ret.fetch(packet.echo, GetVerInfoRsp)
98
+ return common.Ret.fetch(packet.echo, GetVerInfoRsp)
101
99
 
102
- async def send_forward_msg(self, message: Comm.Message) -> Comm.Ret[SendForwardRsp]:
103
- packet = Comm.Packet(
100
+ async def send_forward_msg(self, message: common.Message) -> common.Ret[SendForwardRsp]:
101
+ packet = common.Packet(
104
102
  "send_forward_msg",
105
103
  messages=await message.get()
106
104
  )
107
105
  packet.send_to(self.connection)
108
- return Comm.Ret.fetch(packet.echo, SendForwardRsp)
106
+ return common.Ret.fetch(packet.echo, SendForwardRsp)
109
107
 
110
- async def send_group_forward_msg(self, group_id: int, message: Comm.Message) -> Comm.Ret[SendGrpForwardRsp]:
111
- packet = Comm.Packet(
108
+ async def send_group_forward_msg(self, group_id: int, message: common.Message) -> common.Ret[SendGrpForwardRsp]:
109
+ packet = common.Packet(
112
110
  "send_group_forward_msg",
113
111
  group_id=group_id,
114
112
  messages=await message.get()
115
113
  )
116
114
  packet.send_to(self.connection)
117
- return Comm.Ret.fetch(packet.echo, SendForwardRsp)
115
+ return common.Ret.fetch(packet.echo, SendForwardRsp)
118
116
 
119
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().set_req, logger)
120
- async def set_group_add_request(self, flag: str, sub_type: str, approve: bool, reason: str = "Refused") -> None:
121
- Comm.Packet(
117
+ async def set_group_add_request(self, flag: str, sub_type: str, approve: bool, reason: str = "Not Mentioned") -> None:
118
+ common.Packet(
122
119
  "set_group_add_request",
123
120
  flag=flag,
124
121
  sub_type=sub_type,
125
122
  approve=approve,
126
123
  reason=reason
127
124
  ).send_to(self.connection)
125
+ logger.info(f"由于 {reason},{'通过' if approve else '拒绝'} {flag} 请求")
128
126
 
129
- @Logic.Cacher().cache_async
130
- async def get_stranger_info(self, user_id: int) -> Comm.Ret[GetStrInfoRsp]:
131
- packet = Comm.Packet(
127
+ async def get_stranger_info(self, user_id: int) -> common.Ret[GetStrInfoRsp]:
128
+ packet = common.Packet(
132
129
  "get_stranger_info",
133
130
  user_id=user_id,
134
131
  no_cache=True,
135
132
  )
136
133
  packet.send_to(self.connection)
137
- return Comm.Ret.fetch(packet.echo, GetStrInfoRsp)
134
+ return common.Ret.fetch(packet.echo, GetStrInfoRsp)
138
135
 
139
- @Logic.Cacher().cache_async
140
- async def get_group_member_info(self, group_id: int, user_id: int) -> Comm.Ret[GetGrpMemInfoRsp]:
141
- packet = Comm.Packet(
136
+ async def get_group_member_info(self, group_id: int, user_id: int) -> common.Ret[GetGrpMemInfoRsp]:
137
+ packet = common.Packet(
142
138
  "get_group_member_info",
143
139
  group_id=group_id,
144
140
  user_id=user_id,
145
141
  no_cache=True
146
142
  )
147
143
  packet.send_to(self.connection)
148
- return Comm.Ret.fetch(packet.echo, GetGrpMemInfoRsp)
144
+ return common.Ret.fetch(packet.echo, GetGrpMemInfoRsp)
149
145
 
150
- @Logic.Cacher().cache_async
151
- async def get_group_info(self, group_id: int) -> Comm.Ret[GetGrpInfoRsp]:
152
- packet = Comm.Packet(
146
+ async def get_group_info(self, group_id: int) -> common.Ret[GetGrpInfoRsp]:
147
+ packet = common.Packet(
153
148
  "get_group_info",
154
149
  group_id=group_id,
155
150
  no_cache=True
156
151
  )
157
152
  packet.send_to(self.connection)
158
- return Comm.Ret.fetch(packet.echo, GetGrpInfoRsp)
153
+ return common.Ret.fetch(packet.echo, GetGrpInfoRsp)
159
154
 
160
- async def get_status(self) -> Comm.Ret:
161
- packet = Comm.Packet("get_status")
155
+ async def get_status(self) -> common.Ret:
156
+ packet = common.Packet("get_status")
162
157
  packet.send_to(self.connection)
163
- return Comm.Ret.fetch(packet.echo)
158
+ return common.Ret.fetch(packet.echo)
164
159
 
165
- @Logger.AutoLogAsync.register(Logger.AutoLog.templates().set_ess, logger)
166
160
  async def set_essence_msg(self, message_id: int) -> None:
167
- Comm.Packet(
161
+ common.Packet(
168
162
  "set_essence_msg",
169
163
  message_id=message_id
170
164
  ).send_to(self.connection)
171
165
 
172
166
  async def set_group_special_title(self, group_id: int, user_id: int, title: str) -> None:
173
- Comm.Packet(
167
+ common.Packet(
174
168
  "set_group_special_title",
175
169
  group_id=group_id,
176
170
  user_id=user_id,
177
171
  special_title=title,
178
172
  ).send_to(self.connection)
179
173
 
180
- async def get_msg(self, msg_id: int) -> Comm.Ret[GetMsgRsp]:
181
- packet = Comm.Packet(
174
+ async def get_msg(self, msg_id: int) -> common.Ret[GetMsgRsp]:
175
+ packet = common.Packet(
182
176
  "get_msg",
183
177
  message_id=msg_id
184
178
  )
185
179
  packet.send_to(self.connection)
186
- return Comm.Ret.fetch(packet.echo, GetMsgRsp)
180
+ return common.Ret.fetch(packet.echo, GetMsgRsp)
187
181
 
188
182
 
189
183
  async def tester(
@@ -199,7 +193,7 @@ def __handler(data: Union[dict, HyperNotify], actions: Actions) -> None:
199
193
  elif data.get("post_type") == "meta_event" or data.get("user_id") == data.get("self_id"):
200
194
  pass
201
195
  else:
202
- asyncio.run(handler(Events.em.new(data), actions))
196
+ asyncio.run(handler(events.em.new(data), actions))
203
197
  else:
204
198
  asyncio.run(handler(data, actions))
205
199
 
@@ -212,7 +206,7 @@ def reg(func: callable) -> None:
212
206
  handler = func
213
207
 
214
208
 
215
- connection: Union[Network.WebsocketConnection, Network.HTTPConnection]
209
+ connection: Union[network.WebsocketConnection, network.HTTPConnection]
216
210
 
217
211
 
218
212
  class LagrangeOneBotService(IServiceBase):
@@ -220,7 +214,7 @@ class LagrangeOneBotService(IServiceBase):
220
214
  def handler(self, func: FuncCall) -> Any:
221
215
  pass
222
216
 
223
- async def server(self, bot_config: Configurator.BotConfig) -> None:
217
+ async def server(self, bot_config: configurator.BotConfig) -> None:
224
218
  proc = subprocess.Popen(
225
219
  args=config.connection.ob_exec,
226
220
  cwd=config.connection.ob_startup_path,
@@ -236,12 +230,11 @@ def run() -> NoReturn:
236
230
  listener_ran = True
237
231
  try:
238
232
  if handler is tester:
239
- raise Errors.ListenerNotRegisteredError("No handler registered")
240
- # connection = websocket.WebSocket()
241
- if isinstance(config.connection, Configurator.BotWSC):
242
- connection = Network.WebsocketConnection(f"ws://{config.connection.host}:{config.connection.port}")
243
- elif isinstance(config.connection, Configurator.BotHTTPC):
244
- connection = Network.HTTPConnection(
233
+ raise errors.ListenerNotRegisteredError("No handler registered")
234
+ if isinstance(config.connection, configurator.BotWSC):
235
+ connection = network.WebsocketConnection(f"ws://{config.connection.host}:{config.connection.port}")
236
+ elif isinstance(config.connection, configurator.BotHTTPC):
237
+ connection = network.HTTPConnection(
245
238
  url=f"http://{config.connection.host}:{config.connection.port}",
246
239
  listener_url=f"http://{config.connection.listener_host}:{config.connection.listener_port}"
247
240
  )
@@ -270,7 +263,6 @@ def run() -> NoReturn:
270
263
  connection=connection
271
264
  )
272
265
  threading.Thread(target=lambda: __handler(data, actions), daemon=True).start()
273
- # asyncio.get_event_loop().run_in_executor(pool, __handler, data, actions)
274
266
  while True:
275
267
  try:
276
268
  data = connection.recv()
@@ -280,9 +272,7 @@ def run() -> NoReturn:
280
272
  except json.decoder.JSONDecodeError:
281
273
  logger.error("收到错误的JSON内容")
282
274
  continue
283
- # threading.Thread(target=lambda: asyncio.run(__handler(data, actions))).start()
284
275
  threading.Thread(target=lambda: __handler(data, actions), daemon=True).start()
285
- # asyncio.create_task(__handler(data, actions))
286
276
  except KeyboardInterrupt:
287
277
  logger.warning("正在退出(Ctrl+C)")
288
278
  try:
@@ -297,4 +287,4 @@ def stop() -> None:
297
287
  connection.close()
298
288
  except:
299
289
  pass
300
- logger.log("停止运行监听器", level=Logger.levels.WARNING)
290
+ logger.log("停止运行监听器", level=hyperogger.levels.WARNING)
@@ -1,22 +1,21 @@
1
- from Hyper import Configurator, Logger, Network
2
- from Hyper.Utils import Logic
3
- from Hyper.Utils.HyperTyping import OneBotJsonPacket
1
+ from ... import configurator, hyperogger, network
2
+ from ...utils import logic
3
+ from ...utils.hypetyping import OneBotJsonPacket
4
4
 
5
5
  from typing import Union
6
6
  import random
7
7
  import json
8
8
 
9
- # reports = queue.Queue()
10
- reports = Logic.KeyQueue()
9
+ reports = logic.KeyQueue()
11
10
 
12
- config: Configurator.BotConfig
13
- logger: Logger.Logger
11
+ config: configurator.BotConfig
12
+ logger: hyperogger.Logger
14
13
 
15
14
 
16
15
  def init() -> None:
17
16
  global config, logger
18
- config = Configurator.BotConfig.get("hyper-bot")
19
- logger = Logger.Logger()
17
+ config = configurator.BotConfig.get("hyper-bot")
18
+ logger = hyperogger.Logger()
20
19
  logger.set_level(config.log_level)
21
20
 
22
21
 
@@ -29,8 +28,8 @@ class Packet:
29
28
  self.paras = kwargs
30
29
  self.echo = f"{endpoint}_{random.randint(1000, 9999)}"
31
30
 
32
- def send_to(self, connection: Union[Network.WebsocketConnection, Network.HTTPConnection]) -> None:
33
- if isinstance(connection, Network.WebsocketConnection):
31
+ def send_to(self, connection: Union[network.WebsocketConnection, network.HTTPConnection]) -> None:
32
+ if isinstance(connection, network.WebsocketConnection):
34
33
  payload: OneBotJsonPacket = {
35
34
  "action": self.endpoint,
36
35
  "params": self.paras,
@@ -38,7 +37,7 @@ class Packet:
38
37
  }
39
38
  connection.send(json.dumps(payload))
40
39
 
41
- elif isinstance(connection, Network.HTTPConnection):
40
+ elif isinstance(connection, network.HTTPConnection):
42
41
  payload = self.paras
43
42
  connection.send(self.endpoint, payload, self.echo)
44
43
 
@@ -1,7 +1,6 @@
1
1
  from abc import ABC
2
- from typing import Self
3
2
 
4
- from Hyper.Utils.HyperTyping import OneBotSegReg
3
+ from ...utils.hypetyping import OneBotSegReg
5
4
 
6
5
 
7
6
  message_types = {}
@@ -1,5 +1,5 @@
1
- from Hyper import Configurator
2
- from Hyper.Utils import Screens
1
+ from . import configurator
2
+ from .utils import screens
3
3
 
4
4
  from typing import Union
5
5
  import asyncio
@@ -7,12 +7,12 @@ import importlib
7
7
  import sys
8
8
  import os
9
9
 
10
- HYPER_BOT_VERSION = "0.79.5"
10
+ HYPER_BOT_VERSION = "0.80.2"
11
11
 
12
12
  listener: "Listener"
13
13
 
14
- Screens.play_startup()
15
- Screens.play_info(HYPER_BOT_VERSION)
14
+ screens.play_startup()
15
+ screens.play_info(HYPER_BOT_VERSION)
16
16
 
17
17
 
18
18
  def _load_listener() -> None: