hyper-bot 0.80.2__tar.gz → 0.80.7__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 (47) hide show
  1. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/PKG-INFO +1 -1
  2. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyper_bot.egg-info/PKG-INFO +1 -1
  3. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/OneBot.py +30 -1
  4. hyper_bot-0.80.7/hyperot/__init__.py +82 -0
  5. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/common.py +9 -9
  6. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/events.py +1 -0
  7. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/listener.py +10 -8
  8. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/network.py +31 -27
  9. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/segments.py +21 -14
  10. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/apiresponse.py +2 -3
  11. hyper_bot-0.80.2/hyperot/__init__.py +0 -87
  12. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/LICENSE +0 -0
  13. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyper_bot.egg-info/SOURCES.txt +0 -0
  14. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyper_bot.egg-info/dependency_links.txt +0 -0
  15. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyper_bot.egg-info/requires.txt +0 -0
  16. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyper_bot.egg-info/top_level.txt +0 -0
  17. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/Kritor.py +0 -0
  18. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/Manager.py +0 -0
  19. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/Res.py +0 -0
  20. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/__init__.py +0 -0
  21. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/authentication/__init__.py +0 -0
  22. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/common/__init__.py +0 -0
  23. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/core/__init__.py +0 -0
  24. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/customization/__init__.py +0 -0
  25. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/developer/__init__.py +0 -0
  26. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/event/__init__.py +0 -0
  27. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/file/__init__.py +0 -0
  28. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/friend/__init__.py +0 -0
  29. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/group/__init__.py +0 -0
  30. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/guild/__init__.py +0 -0
  31. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/message/__init__.py +0 -0
  32. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/process/__init__.py +0 -0
  33. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/reverse/__init__.py +0 -0
  34. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/KritorLib/protos/web/__init__.py +0 -0
  35. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/OneBotLib/Manager.py +0 -0
  36. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/Adapters/OneBotLib/Res.py +0 -0
  37. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/configurator.py +0 -0
  38. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/hyperogger.py +0 -0
  39. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/service.py +0 -0
  40. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/ArkSignHelper.py +0 -0
  41. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/errors.py +0 -0
  42. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/hypetyping.py +0 -0
  43. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/logic.py +0 -0
  44. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/screens.py +0 -0
  45. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/hyperot/utils/typextensions.py +0 -0
  46. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/setup.cfg +0 -0
  47. {hyper_bot-0.80.2 → hyper_bot-0.80.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hyper-bot
3
- Version: 0.80.2
3
+ Version: 0.80.7
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.80.2
3
+ Version: 0.80.7
4
4
  Summary: 稳定高效、易于开发的QQ Bot框架
5
5
  Home-page: https://github.com/HarcicYang/HypeR_Bot
6
6
  Author: Harcic
@@ -105,6 +105,26 @@ class Actions:
105
105
  packet.send_to(self.connection)
106
106
  return common.Ret.fetch(packet.echo, SendForwardRsp)
107
107
 
108
+ async def get_forward_msg(self, sid: str) -> common.Ret[common.Message]:
109
+ packet = common.Packet(
110
+ "get_forward_msg",
111
+ id=sid,
112
+ )
113
+ packet.send_to(self.connection)
114
+ ret = common.Ret.fetch(packet.echo, events.gen_message)
115
+ for i in ret.data:
116
+ if isinstance(i, segments.Node):
117
+ i.content = gen_message({"message": i.content})
118
+
119
+ return ret
120
+
121
+ async def forward_solve(self, message: common.Message) -> common.Message:
122
+ for i in message:
123
+ if isinstance(i, segments.Forward):
124
+ data = await self.get_forward_msg(i.id)
125
+ return data.data
126
+ raise ValueError("Incorrect message type")
127
+
108
128
  async def send_group_forward_msg(self, group_id: int, message: common.Message) -> common.Ret[SendGrpForwardRsp]:
109
129
  packet = common.Packet(
110
130
  "send_group_forward_msg",
@@ -114,7 +134,8 @@ class Actions:
114
134
  packet.send_to(self.connection)
115
135
  return common.Ret.fetch(packet.echo, SendForwardRsp)
116
136
 
117
- async def set_group_add_request(self, flag: str, sub_type: str, approve: bool, reason: str = "Not Mentioned") -> None:
137
+ async def set_group_add_request(self, flag: str, sub_type: str, approve: bool,
138
+ reason: str = "Not Mentioned") -> None:
118
139
  common.Packet(
119
140
  "set_group_add_request",
120
141
  flag=flag,
@@ -179,6 +200,14 @@ class Actions:
179
200
  packet.send_to(self.connection)
180
201
  return common.Ret.fetch(packet.echo, GetMsgRsp)
181
202
 
203
+ async def send_callback(self, group_id: int, bot_id: int, data: dict) -> None:
204
+ common.Packet(
205
+ "send_group_bot_callback",
206
+ group_id=group_id,
207
+ bot_id=bot_id,
208
+ **data
209
+ ).send_to(self.connection)
210
+
182
211
 
183
212
  async def tester(
184
213
  message_data: Union[Event, HyperNotify], actions: Actions
@@ -0,0 +1,82 @@
1
+ from . import configurator
2
+ from .utils import screens
3
+
4
+ from typing import Union
5
+ import asyncio
6
+ import sys
7
+ import os
8
+
9
+ HYPER_BOT_VERSION = "0.80.7"
10
+
11
+ # listener = None
12
+
13
+ screens.play_startup()
14
+ screens.play_info(HYPER_BOT_VERSION)
15
+
16
+
17
+ class Client:
18
+ def __init__(self):
19
+ self.records = {}
20
+ self.lis = None
21
+
22
+ def subscribe(
23
+ self,
24
+ func: callable,
25
+ event: Union[
26
+ "events.GroupMessageEvent",
27
+ "events.PrivateMessageEvent",
28
+ "events.GroupFileUploadEvent",
29
+ "events.GroupAdminEvent",
30
+ "events.GroupMemberDecreaseEvent",
31
+ "events.GroupMemberIncreaseEvent",
32
+ "events.GroupMuteEvent",
33
+ "events.FriendAddEvent",
34
+ "events.GroupRecallEvent",
35
+ "events.FriendRecallEvent",
36
+ "events.NotifyEvent",
37
+ "events.GroupEssenceEvent",
38
+ "events.MessageReactionEvent",
39
+ "events.GroupAddInviteEvent",
40
+ "events.HyperListenerStartNotify",
41
+ "events.HyperListenerStopNotify"
42
+ ]
43
+ ) -> None:
44
+ if not self.records.get(event):
45
+ self.records[event] = [func]
46
+ else:
47
+ self.records[event].append(func)
48
+
49
+ async def distributor(
50
+ self, message_data: Union["events.Event", "events.HyperNotify"], actions: "Listener.Actions"
51
+ ) -> None:
52
+ if type(message_data) in list(self.records.keys()):
53
+ tasks = []
54
+ for i in self.records[type(message_data)]:
55
+ tasks.append(asyncio.create_task(i(message_data, actions)))
56
+ await asyncio.gather(*tasks)
57
+ else:
58
+ return
59
+
60
+ def run(self):
61
+ from . import listener
62
+ self.lis = listener
63
+ self.lis.reg(self.distributor)
64
+ if self.records:
65
+ self.lis.run()
66
+
67
+ def restart(self) -> None:
68
+ self.lis.stop()
69
+ os.execv(sys.executable, [sys.executable] + sys.argv)
70
+ # os._exit(1)
71
+
72
+ def __enter__(self):
73
+ return self
74
+
75
+ def __exit__(self, exc_type, exc_val, exc_tb):
76
+ pass
77
+
78
+ async def __aenter__(self):
79
+ return self
80
+
81
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
82
+ pass
@@ -7,19 +7,19 @@ from typing import Generic, Type, Self
7
7
 
8
8
  config = configurator.BotConfig.get("hyper-bot")
9
9
 
10
- if config.protocol == "OneBot":
11
- from .Adapters.OneBotLib.Manager import *
12
- elif config.protocol == "Satori":
13
- raise NotImplementedError()
14
- elif config.protocol == "Lagrange":
15
- raise NotImplementedError()
16
- elif config.protocol == "Kritor":
17
- from .Adapters.KritorLib.Manager import *
10
+ # if config.protocol == "OneBot":
11
+ # from .Adapters.OneBotLib.Manager import *
12
+ # elif config.protocol == "Satori":
13
+ # raise NotImplementedError()
14
+ # elif config.protocol == "Lagrange":
15
+ # raise NotImplementedError()
16
+ # elif config.protocol == "Kritor":
17
+ # from .Adapters.KritorLib.Manager import *
18
18
 
19
+ from .Adapters.OneBotLib.Manager import *
19
20
 
20
21
  init()
21
22
 
22
-
23
23
  __all__ = ["Message", "MessageBuilder", "Packet", "Ret", "reports"]
24
24
 
25
25
 
@@ -36,6 +36,7 @@ class EventManager:
36
36
  return wrapper
37
37
 
38
38
  def new(self, data: dict) -> "Event":
39
+ logger.trace(str(data))
39
40
  try:
40
41
  return self.event_lis[data["post_type"]][data[f"{data['post_type']}_type"]](data)
41
42
  except KeyError:
@@ -4,14 +4,16 @@ config = configurator.BotConfig.get("hyper-bot")
4
4
 
5
5
  __all__ = ["run", "stop", "Actions"]
6
6
 
7
- if config.protocol == "OneBot":
8
- from .Adapters.OneBot import *
9
- elif config.protocol == "Satori":
10
- raise NotImplementedError()
11
- elif config.protocol == "Lagrange":
12
- raise NotImplementedError()
13
- elif config.protocol == "Kritor":
14
- from .Adapters.Kritor import *
7
+ # if config.protocol == "OneBot":
8
+ # from .Adapters.OneBot import *
9
+ # elif config.protocol == "Satori":
10
+ # raise NotImplementedError()
11
+ # elif config.protocol == "Lagrange":
12
+ # raise NotImplementedError()
13
+ # elif config.protocol == "Kritor":
14
+ # from .Adapters.Kritor import *
15
+
16
+ from .Adapters.OneBot import *
15
17
 
16
18
  events.init()
17
19
 
@@ -8,11 +8,11 @@ import traceback
8
8
  import json
9
9
  import logging
10
10
  import threading
11
- from grpclib.client import Channel
12
-
13
- from .Adapters.KritorLib.protos.authentication import AuthenticationServiceStub, AuthenticateRequest
14
- from .Adapters.KritorLib.protos.event import EventServiceStub
15
- from .Adapters.KritorLib.Res import EventService
11
+ # from grpclib.client import Channel
12
+ #
13
+ # from .Adapters.KritorLib.protos.authentication import AuthenticationServiceStub, AuthenticateRequest
14
+ # from .Adapters.KritorLib.protos.event import EventServiceStub
15
+ # from .Adapters.KritorLib.Res import EventService
16
16
 
17
17
 
18
18
  class WebsocketConnection:
@@ -131,35 +131,39 @@ class SatoriConnection:
131
131
  class KritorConnection:
132
132
  def __init__(self, host: str, port: int, account: str = None, ticket: str = None):
133
133
  # self.channel = grpc.insecure_channel(f"{host}:{port}")
134
- self.channel = Channel(host=host, port=port)
135
- self.account = account
136
- self.ticket = ticket
134
+ # self.channel = Channel(host=host, port=port)
135
+ # self.account = account
136
+ # self.ticket = ticket
137
+ raise NotImplementedError()
137
138
 
138
139
  def connect(self) -> None:
139
- if self.account and self.ticket:
140
- auth_stub = AuthenticationServiceStub(self.channel)
141
- response = asyncio.run(
142
- auth_stub.authenticate(
143
- AuthenticateRequest(
144
- account=self.account,
145
- ticket=self.ticket
146
- )
147
- )
148
- )
149
- if response.code != 0:
150
- raise ConnectionError("鉴权失败")
151
- else:
152
- pass
140
+ # if self.account and self.ticket:
141
+ # auth_stub = AuthenticationServiceStub(self.channel)
142
+ # response = asyncio.run(
143
+ # auth_stub.authenticate(
144
+ # AuthenticateRequest(
145
+ # account=self.account,
146
+ # ticket=self.ticket
147
+ # )
148
+ # )
149
+ # )
150
+ # if response.code != 0:
151
+ # raise ConnectionError("鉴权失败")
152
+ # else:
153
+ # pass
154
+ raise NotImplementedError()
153
155
  # threading.Thread(target=lambda: asyncio.run(self.event_service.run())).start()
154
156
 
155
157
  def send(self, stub, payload: dict, echo: str = None) -> None:
156
158
  raise NotImplementedError()
157
159
 
158
160
  def close(self) -> None:
159
- self.channel.close()
161
+ # self.channel.close()
162
+ raise NotImplementedError()
160
163
 
161
164
  async def recv(self) -> None:
162
- event_service = EventService(EventServiceStub(self.channel))
163
- # asyncio.run(event_service.run())
164
- # asyncio.get_running_loop().run_until_complete(event_service.run())
165
- await event_service.run()
165
+ # event_service = EventService(EventServiceStub(self.channel))
166
+ # # asyncio.run(event_service.run())
167
+ # # asyncio.get_running_loop().run_until_complete(event_service.run())
168
+ # await event_service.run()
169
+ raise NotImplementedError()
@@ -4,22 +4,24 @@ import typing
4
4
  import uuid
5
5
 
6
6
  from .utils.errors import *
7
+ from .utils.hypetyping import Union
7
8
  from . import configurator
8
9
 
9
10
  config = configurator.BotConfig.get("hyper-bot")
10
- if config.protocol == "OneBot":
11
- # from Hyper.Adapters.OneBotLib.Res import segment_builder, Base, message_types
12
- from .Adapters.OneBotLib.Res import SegmentBase, message_types
13
- elif config.protocol == "Satori":
14
- # from Hyper.Adapters.SatoriLib.Res import segment_builder, Base, message_types
15
- raise NotImplementedError()
16
- elif config.protocol == "Lagrange":
17
- # from Hyper.Adapters.LagrangeLib.Res import segment_builder, Base, message_types
18
- raise NotImplementedError()
19
- elif config.protocol == "Kritor":
20
- # from Hyper.Adapters.KritorLib.Res import segment_builder, Base, message_types
21
- from .Adapters.KritorLib.Res import SegmentBase, message_types
22
-
11
+ # if config.protocol == "OneBot":
12
+ # # from Hyper.Adapters.OneBotLib.Res import segment_builder, Base, message_types
13
+ # from .Adapters.OneBotLib.Res import SegmentBase, message_types
14
+ # elif config.protocol == "Satori":
15
+ # # from Hyper.Adapters.SatoriLib.Res import segment_builder, Base, message_types
16
+ # raise NotImplementedError()
17
+ # elif config.protocol == "Lagrange":
18
+ # # from Hyper.Adapters.LagrangeLib.Res import segment_builder, Base, message_types
19
+ # raise NotImplementedError()
20
+ # elif config.protocol == "Kritor":
21
+ # # from Hyper.Adapters.KritorLib.Res import segment_builder, Base, message_types
22
+ # from .Adapters.KritorLib.Res import SegmentBase, message_types
23
+
24
+ from .Adapters.OneBotLib.Res import SegmentBase, message_types
23
25
 
24
26
  class MediaSeg(SegmentBase):
25
27
  @classmethod
@@ -47,6 +49,9 @@ class Text(SegmentBase, st="text", su="<text>"):
47
49
  text: str
48
50
 
49
51
 
52
+ class StreamTest(SegmentBase, st="stream", su="[Stream] <text>"):
53
+ text: str
54
+
50
55
  class Image(MediaSeg, st="image", su="[Image]"):
51
56
  file: str
52
57
  url: str
@@ -99,7 +104,9 @@ class Forward(SegmentBase, st="forward", su="[Forward]"):
99
104
 
100
105
 
101
106
  class Node(SegmentBase, st="node", su="[Node]"):
102
- id: str
107
+ user_id: str
108
+ nickname: str
109
+ content: Union[dict, "common.Message"]
103
110
 
104
111
 
105
112
  class CustomNode:
@@ -185,7 +185,8 @@ class GetMsgRsp(BaseResponse):
185
185
 
186
186
  @classmethod
187
187
  def build(
188
- cls, time: int, message_type: Literal["private", "group"], message_id: int, real_id: int, sender: dict, message: dict
188
+ cls, time: int, message_type: Literal["private", "group"], message_id: int, real_id: int, sender: dict,
189
+ message: dict
189
190
  ):
190
191
  return cls(
191
192
  {
@@ -197,5 +198,3 @@ class GetMsgRsp(BaseResponse):
197
198
  "message": message
198
199
  }
199
200
  )
200
-
201
-
@@ -1,87 +0,0 @@
1
- from . import configurator
2
- from .utils import screens
3
-
4
- from typing import Union
5
- import asyncio
6
- import importlib
7
- import sys
8
- import os
9
-
10
- HYPER_BOT_VERSION = "0.80.2"
11
-
12
- listener: "Listener"
13
-
14
- screens.play_startup()
15
- screens.play_info(HYPER_BOT_VERSION)
16
-
17
-
18
- def _load_listener() -> None:
19
- global listener
20
- listener = importlib.import_module("Hyper.Listener")
21
-
22
-
23
- def restart() -> None:
24
- listener.stop()
25
- os.execv(sys.executable, [sys.executable] + sys.argv)
26
- # os._exit(1)
27
-
28
-
29
- class Client:
30
- def __init__(self):
31
- self.records = {}
32
-
33
- def subscribe(
34
- self,
35
- func: callable,
36
- event: Union[
37
- "Events.GroupMessageEvent",
38
- "Events.PrivateMessageEvent",
39
- "Events.GroupFileUploadEvent",
40
- "Events.GroupAdminEvent",
41
- "Events.GroupMemberDecreaseEvent",
42
- "Events.GroupMemberIncreaseEvent",
43
- "Events.GroupMuteEvent",
44
- "Events.FriendAddEvent",
45
- "Events.GroupRecallEvent",
46
- "Events.FriendRecallEvent",
47
- "Events.NotifyEvent",
48
- "Events.GroupEssenceEvent",
49
- "Events.MessageReactionEvent",
50
- "Events.GroupAddInviteEvent",
51
- "Events.HyperListenerStartNotify",
52
- "Events.HyperListenerStopNotify"
53
- ]
54
- ) -> None:
55
- if not self.records.get(event):
56
- self.records[event] = [func]
57
- else:
58
- self.records[event].append(func)
59
-
60
- async def distributor(
61
- self, message_data: Union["Events.Event", "Events.HyperNotify"], actions: "Listener.Actions"
62
- ) -> None:
63
- if type(message_data) in list(self.records.keys()):
64
- tasks = []
65
- for i in self.records[type(message_data)]:
66
- tasks.append(asyncio.create_task(i(message_data, actions)))
67
- await asyncio.gather(*tasks)
68
- else:
69
- return
70
-
71
- def run(self):
72
- _load_listener()
73
- listener.reg(self.distributor)
74
- if self.records:
75
- listener.run()
76
-
77
- def __enter__(self):
78
- return self
79
-
80
- def __exit__(self, exc_type, exc_val, exc_tb):
81
- pass
82
-
83
- async def __aenter__(self):
84
- return self
85
-
86
- async def __aexit__(self, exc_type, exc_val, exc_tb):
87
- pass
File without changes
File without changes
File without changes