imbot-sdk-python 0.1.0__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.
@@ -0,0 +1,55 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: connect.proto
5
+ # Protobuf Python Version: 7.34.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 7,
15
+ 34,
16
+ 0,
17
+ '',
18
+ 'connect.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rconnect.proto\"x\n\x0e\x43onnectMsgBody\x12\x0f\n\x07protoId\x18\x01 \x01(\t\x12\x12\n\nsdkVersion\x18\x02 \x01(\t\x12\x0e\n\x06\x61ppkey\x18\x03 \x01(\t\x12\r\n\x05token\x18\x04 \x01(\t\x12\x10\n\x08\x64\x65viceId\x18\x05 \x01(\t\x12\x10\n\x08platform\x18\x06 \x01(\t\"b\n\x11\x43onnectAckMsgBody\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0e\n\x06userId\x18\x02 \x01(\t\x12\x0f\n\x07session\x18\x03 \x01(\t\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12\x0b\n\x03\x65xt\x18\x05 \x01(\t\"A\n\x11\x44isconnectMsgBody\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x0b\n\x03\x65xt\x18\x03 \x01(\t\"a\n\x0ePublishMsgBody\x12\r\n\x05index\x18\x01 \x01(\x05\x12\r\n\x05topic\x18\x02 \x01(\t\x12\x10\n\x08targetId\x18\x03 \x01(\t\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12\x0c\n\x04\x64\x61ta\x18\x05 \x01(\x0c\"\xb7\x01\n\x11PublishAckMsgBody\x12\r\n\x05index\x18\x01 \x01(\x05\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x05\x12\r\n\x05msgId\x18\x03 \x01(\t\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12\x10\n\x08msgSeqNo\x18\x05 \x01(\x03\x12\x13\n\x0bmemberCount\x18\x06 \x01(\x05\x12\x13\n\x0b\x63lientMsgId\x18\x07 \x01(\t\x12\'\n\x0bmodifiedMsg\x18\x08 \x01(\x0b\x32\x12.SimplifiedDownMsg\"8\n\x11SimplifiedDownMsg\x12\x0f\n\x07msgType\x18\x03 \x01(\t\x12\x12\n\nmsgContent\x18\x07 \x01(\x0c\"_\n\x0cQueryMsgBody\x12\r\n\x05index\x18\x01 \x01(\x05\x12\r\n\x05topic\x18\x02 \x01(\t\x12\x10\n\x08targetId\x18\x03 \x01(\t\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12\x0c\n\x04\x64\x61ta\x18\x05 \x01(\x0c\"O\n\x0fQueryAckMsgBody\x12\r\n\x05index\x18\x01 \x01(\x05\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x05\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\x0c\"$\n\x13QueryConfirmMsgBody\x12\r\n\x05index\x18\x01 \x01(\x05\"\xbe\x03\n\x0eImWebsocketMsg\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12\x0b\n\x03\x63md\x18\x02 \x01(\x05\x12\x0b\n\x03qos\x18\x03 \x01(\x05\x12\x0f\n\x07payload\x18\x04 \x01(\x0c\x12)\n\x0e\x63onnectMsgBody\x18\x0b \x01(\x0b\x32\x0f.ConnectMsgBodyH\x00\x12/\n\x11\x43onnectAckMsgBody\x18\x0c \x01(\x0b\x32\x12.ConnectAckMsgBodyH\x00\x12/\n\x11\x64isconnectMsgBody\x18\r \x01(\x0b\x32\x12.DisconnectMsgBodyH\x00\x12)\n\x0epublishMsgBody\x18\x0e \x01(\x0b\x32\x0f.PublishMsgBodyH\x00\x12+\n\rpubAckMsgBody\x18\x0f \x01(\x0b\x32\x12.PublishAckMsgBodyH\x00\x12#\n\nqryMsgBody\x18\x10 \x01(\x0b\x32\r.QueryMsgBodyH\x00\x12)\n\rqryAckMsgBody\x18\x11 \x01(\x0b\x32\x10.QueryAckMsgBodyH\x00\x12\x31\n\x11qryConfirmMsgBody\x18\x12 \x01(\x0b\x32\x14.QueryConfirmMsgBodyH\x00\x42\x08\n\x06testofB\x08Z\x06pbobjsb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'connect_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'Z\006pbobjs'
35
+ _globals['_CONNECTMSGBODY']._serialized_start=17
36
+ _globals['_CONNECTMSGBODY']._serialized_end=137
37
+ _globals['_CONNECTACKMSGBODY']._serialized_start=139
38
+ _globals['_CONNECTACKMSGBODY']._serialized_end=237
39
+ _globals['_DISCONNECTMSGBODY']._serialized_start=239
40
+ _globals['_DISCONNECTMSGBODY']._serialized_end=304
41
+ _globals['_PUBLISHMSGBODY']._serialized_start=306
42
+ _globals['_PUBLISHMSGBODY']._serialized_end=403
43
+ _globals['_PUBLISHACKMSGBODY']._serialized_start=406
44
+ _globals['_PUBLISHACKMSGBODY']._serialized_end=589
45
+ _globals['_SIMPLIFIEDDOWNMSG']._serialized_start=591
46
+ _globals['_SIMPLIFIEDDOWNMSG']._serialized_end=647
47
+ _globals['_QUERYMSGBODY']._serialized_start=649
48
+ _globals['_QUERYMSGBODY']._serialized_end=744
49
+ _globals['_QUERYACKMSGBODY']._serialized_start=746
50
+ _globals['_QUERYACKMSGBODY']._serialized_end=825
51
+ _globals['_QUERYCONFIRMMSGBODY']._serialized_start=827
52
+ _globals['_QUERYCONFIRMMSGBODY']._serialized_end=863
53
+ _globals['_IMWEBSOCKETMSG']._serialized_start=866
54
+ _globals['_IMWEBSOCKETMSG']._serialized_end=1312
55
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: rtcroom.proto
5
+ # Protobuf Python Version: 7.34.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 7,
15
+ 34,
16
+ 0,
17
+ '',
18
+ 'rtcroom.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from . import appmessages_pb2 as appmessages__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rrtcroom.proto\x1a\x11\x61ppmessages.proto\"\xd5\x01\n\nRtcRoomReq\x12\x1e\n\x08roomType\x18\x01 \x01(\x0e\x32\x0c.RtcRoomType\x12\x0e\n\x06roomId\x18\x02 \x01(\t\x12\x1e\n\njoinMember\x18\x03 \x01(\x0b\x32\n.RtcMember\x12\x1f\n\nrtcChannel\x18\x04 \x01(\x0e\x32\x0b.RtcChannel\x12#\n\x0crtcMediaType\x18\x05 \x01(\x0e\x32\r.RtcMediaType\x12\x0b\n\x03\x65xt\x18\x06 \x01(\t\x12$\n\x0e\x61ttachedConver\x18\x07 \x01(\x0b\x32\x0c.ConverIndex\"\x81\x02\n\x07RtcRoom\x12\x1e\n\x08roomType\x18\x01 \x01(\x0e\x32\x0c.RtcRoomType\x12\x0e\n\x06roomId\x18\x02 \x01(\t\x12\x18\n\x05owner\x18\x03 \x01(\x0b\x32\t.UserInfo\x12\x1f\n\nrtcChannel\x18\x04 \x01(\x0e\x32\x0b.RtcChannel\x12#\n\x0crtcMediaType\x18\x05 \x01(\x0e\x32\r.RtcMediaType\x12\x0b\n\x03\x65xt\x18\x06 \x01(\t\x12\x16\n\x04\x61uth\x18\x07 \x01(\x0b\x32\x08.RtcAuth\x12$\n\x0e\x61ttachedConver\x18\x08 \x01(\x0b\x32\x0c.ConverIndex\x12\x1b\n\x07members\x18\x33 \x03(\x0b\x32\n.RtcMember\"\x9a\x01\n\tRtcMember\x12\x19\n\x06member\x18\x01 \x01(\x0b\x32\t.UserInfo\x12\x1b\n\x08rtcState\x18\x02 \x01(\x0e\x32\t.RtcState\x12\x10\n\x08\x63\x61llTime\x18\x03 \x01(\x03\x12\x13\n\x0b\x63onnectTime\x18\x04 \x01(\x03\x12\x12\n\nhangupTime\x18\x05 \x01(\x03\x12\x1a\n\x07inviter\x18\x06 \x01(\x0b\x32\t.UserInfo\"~\n\x0bMemberState\x12\x0e\n\x06roomId\x18\x01 \x01(\t\x12\x1e\n\x08roomType\x18\x02 \x01(\x0e\x32\x0c.RtcRoomType\x12\x10\n\x08memberId\x18\x03 \x01(\t\x12\x10\n\x08\x64\x65viceId\x18\x04 \x01(\t\x12\x1b\n\x08rtcState\x18\x05 \x01(\x0e\x32\t.RtcState\"D\n\x12SyncMemberStateReq\x12\x10\n\x08isDelete\x18\x01 \x01(\x08\x12\x1c\n\x06member\x18\x02 \x01(\x0b\x32\x0c.MemberState\"\xa4\x01\n\x0cRtcRoomEvent\x12(\n\rroomEventType\x18\x01 \x01(\x0e\x32\x11.RtcRoomEventType\x12\x1b\n\x07members\x18\x02 \x03(\x0b\x32\n.RtcMember\x12\x16\n\x04room\x18\x03 \x01(\x0b\x32\x08.RtcRoom\x12\"\n\x06reason\x18\x04 \x01(\x0e\x32\x12.RtcRoomQuitReason\x12\x11\n\teventTime\x18\x05 \x01(\x03\"\xca\x01\n\x0cRtcInviteReq\x12\x11\n\ttargetIds\x18\x01 \x03(\t\x12\x1e\n\x08roomType\x18\x02 \x01(\x0e\x32\x0c.RtcRoomType\x12\x0e\n\x06roomId\x18\x03 \x01(\t\x12\x1f\n\nrtcChannel\x18\x04 \x01(\x0e\x32\x0b.RtcChannel\x12#\n\x0crtcMediaType\x18\x05 \x01(\x0e\x32\r.RtcMediaType\x12\x0b\n\x03\x65xt\x18\x06 \x01(\t\x12$\n\x0e\x61ttachedConver\x18\x07 \x01(\x0b\x32\x0c.ConverIndex\"/\n\x0eRtcMemberRooms\x12\x1d\n\x05rooms\x18\x01 \x03(\x0b\x32\x0e.RtcMemberRoom\"\xce\x01\n\rRtcMemberRoom\x12\x1e\n\x08roomType\x18\x01 \x01(\x0e\x32\x0c.RtcRoomType\x12\x0e\n\x06roomId\x18\x02 \x01(\t\x12\x18\n\x05owner\x18\x03 \x01(\x0b\x32\t.UserInfo\x12\x1b\n\x08rtcState\x18\x04 \x01(\x0e\x32\t.RtcState\x12\x1f\n\nrtcChannel\x18\x05 \x01(\x0e\x32\x0b.RtcChannel\x12\x10\n\x08\x64\x65viceId\x18\x06 \x01(\t\x12#\n\x0crtcMediaType\x18\x07 \x01(\x0e\x32\r.RtcMediaType\"\x95\x01\n\x07RtcAuth\x12\x1b\n\x08zegoAuth\x18\x01 \x01(\x0b\x32\t.ZegoAuth\x12\'\n\x0elivekitRtcAuth\x18\x02 \x01(\x0b\x32\x0f.LivekitRtcAuth\x12\x1d\n\tagoraAuth\x18\x03 \x01(\x0b\x32\n.AgoraAuth\x12%\n\rjuggleRtcAuth\x18\x0b \x01(\x0b\x32\x0e.JuggleRtcAuth\"\x19\n\x08ZegoAuth\x12\r\n\x05token\x18\x01 \x01(\t\"\x1e\n\rJuggleRtcAuth\x12\r\n\x05token\x18\x01 \x01(\t\"\x1a\n\tAgoraAuth\x12\r\n\x05token\x18\x01 \x01(\t\"3\n\x0eLivekitRtcAuth\x12\r\n\x05token\x18\x01 \x01(\t\x12\x12\n\nserviceUrl\x18\x02 \x01(\t\"\x95\x01\n\x0eRtcInviteEvent\x12\x1f\n\ninviteType\x18\x01 \x01(\x0e\x32\x0b.InviteType\x12\x17\n\x04user\x18\x02 \x01(\x0b\x32\t.UserInfo\x12\x16\n\x04room\x18\x03 \x01(\x0b\x32\x08.RtcRoom\x12\x1e\n\x0btargetUsers\x18\x04 \x03(\x0b\x32\t.UserInfo\x12\x11\n\teventTime\x18\x05 \x01(\x03\"\x1b\n\tRtcAnswer\x12\x0e\n\x06roomId\x18\x01 \x01(\t*@\n\nRtcChannel\x12\x08\n\x04Zego\x10\x00\x12\x0e\n\nLivekitRtc\x10\x01\x12\t\n\x05\x41gora\x10\x02\x12\r\n\tJuggleRtc\x10\x0b*&\n\x0bRtcRoomType\x12\n\n\x06OneOne\x10\x00\x12\x0b\n\x07OneMore\x10\x01*f\n\x08RtcState\x12\x13\n\x0fRtcStateDefault\x10\x00\x12\x0f\n\x0bRtcIncoming\x10\x01\x12\x0f\n\x0bRtcOutgoing\x10\x02\x12\x11\n\rRtcConnecting\x10\x03\x12\x10\n\x0cRtcConnected\x10\x04*f\n\x10RtcRoomEventType\x12\x17\n\x13\x44\x65\x66\x61ultRtcRoomEvent\x10\x00\x12\x0b\n\x07RtcJoin\x10\x01\x12\x0b\n\x07RtcQuit\x10\x02\x12\x0e\n\nRtcDestroy\x10\x03\x12\x0f\n\x0bRtcStateChg\x10\x04*A\n\x11RtcRoomQuitReason\x12\n\n\x06\x41\x63tive\x10\x00\x12\x0f\n\x0b\x43\x61llTimeout\x10\x01\x12\x0f\n\x0bPingTimeout\x10\x02**\n\x0cRtcMediaType\x12\x0c\n\x08RtcAudio\x10\x00\x12\x0c\n\x08RtcVideo\x10\x01*9\n\nInviteType\x12\r\n\tRtcInvite\x10\x00\x12\r\n\tRtcAccept\x10\x01\x12\r\n\tRtcHangup\x10\x02\x42\x08Z\x06pbobjsb\x06proto3')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rtcroom_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ _globals['DESCRIPTOR']._loaded_options = None
35
+ _globals['DESCRIPTOR']._serialized_options = b'Z\006pbobjs'
36
+ _globals['_RTCCHANNEL']._serialized_start=1970
37
+ _globals['_RTCCHANNEL']._serialized_end=2034
38
+ _globals['_RTCROOMTYPE']._serialized_start=2036
39
+ _globals['_RTCROOMTYPE']._serialized_end=2074
40
+ _globals['_RTCSTATE']._serialized_start=2076
41
+ _globals['_RTCSTATE']._serialized_end=2178
42
+ _globals['_RTCROOMEVENTTYPE']._serialized_start=2180
43
+ _globals['_RTCROOMEVENTTYPE']._serialized_end=2282
44
+ _globals['_RTCROOMQUITREASON']._serialized_start=2284
45
+ _globals['_RTCROOMQUITREASON']._serialized_end=2349
46
+ _globals['_RTCMEDIATYPE']._serialized_start=2351
47
+ _globals['_RTCMEDIATYPE']._serialized_end=2393
48
+ _globals['_INVITETYPE']._serialized_start=2395
49
+ _globals['_INVITETYPE']._serialized_end=2452
50
+ _globals['_RTCROOMREQ']._serialized_start=37
51
+ _globals['_RTCROOMREQ']._serialized_end=250
52
+ _globals['_RTCROOM']._serialized_start=253
53
+ _globals['_RTCROOM']._serialized_end=510
54
+ _globals['_RTCMEMBER']._serialized_start=513
55
+ _globals['_RTCMEMBER']._serialized_end=667
56
+ _globals['_MEMBERSTATE']._serialized_start=669
57
+ _globals['_MEMBERSTATE']._serialized_end=795
58
+ _globals['_SYNCMEMBERSTATEREQ']._serialized_start=797
59
+ _globals['_SYNCMEMBERSTATEREQ']._serialized_end=865
60
+ _globals['_RTCROOMEVENT']._serialized_start=868
61
+ _globals['_RTCROOMEVENT']._serialized_end=1032
62
+ _globals['_RTCINVITEREQ']._serialized_start=1035
63
+ _globals['_RTCINVITEREQ']._serialized_end=1237
64
+ _globals['_RTCMEMBERROOMS']._serialized_start=1239
65
+ _globals['_RTCMEMBERROOMS']._serialized_end=1286
66
+ _globals['_RTCMEMBERROOM']._serialized_start=1289
67
+ _globals['_RTCMEMBERROOM']._serialized_end=1495
68
+ _globals['_RTCAUTH']._serialized_start=1498
69
+ _globals['_RTCAUTH']._serialized_end=1647
70
+ _globals['_ZEGOAUTH']._serialized_start=1649
71
+ _globals['_ZEGOAUTH']._serialized_end=1674
72
+ _globals['_JUGGLERTCAUTH']._serialized_start=1676
73
+ _globals['_JUGGLERTCAUTH']._serialized_end=1706
74
+ _globals['_AGORAAUTH']._serialized_start=1708
75
+ _globals['_AGORAAUTH']._serialized_end=1734
76
+ _globals['_LIVEKITRTCAUTH']._serialized_start=1736
77
+ _globals['_LIVEKITRTCAUTH']._serialized_end=1787
78
+ _globals['_RTCINVITEEVENT']._serialized_start=1790
79
+ _globals['_RTCINVITEEVENT']._serialized_end=1939
80
+ _globals['_RTCANSWER']._serialized_start=1941
81
+ _globals['_RTCANSWER']._serialized_end=1968
82
+ # @@protoc_insertion_point(module_scope)
imbot_sdk/py.typed ADDED
File without changes
@@ -0,0 +1,296 @@
1
+ Metadata-Version: 2.4
2
+ Name: imbot-sdk-python
3
+ Version: 0.1.0
4
+ Summary: JuggleIM Python Bot SDK — WebSocket long-connection IM client for bots and server-side agents
5
+ Author-email: Tyler <tyler@juggle.im>
6
+ Maintainer-email: Tyler <tyler@juggle.im>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/juggleim/imbot-sdk-python
9
+ Project-URL: Repository, https://github.com/juggleim/imbot-sdk-python
10
+ Project-URL: Issues, https://github.com/juggleim/imbot-sdk-python/issues
11
+ Project-URL: Documentation, https://github.com/juggleim/imbot-sdk-python#readme
12
+ Keywords: juggleim,im,instant-messaging,chat,bot,websocket,sdk
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Communications :: Chat
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: protobuf>=5.0
29
+ Requires-Dist: websocket-client>=1.6
30
+ Provides-Extra: dev
31
+ Requires-Dist: build; extra == "dev"
32
+ Requires-Dist: twine; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # imbot-sdk-python
36
+
37
+ [![PyPI version](https://img.shields.io/pypi/v/imbot-sdk-python.svg)](https://pypi.org/project/imbot-sdk-python/)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/imbot-sdk-python.svg)](https://pypi.org/project/imbot-sdk-python/)
39
+ [![License](https://img.shields.io/pypi/l/imbot-sdk-python.svg)](https://github.com/juggleim/imbot-sdk-python/blob/main/LICENSE)
40
+
41
+ `imbot-sdk-python` 是 JuggleIM 的 Python SDK,基于 WebSocket 与 IM 服务建立长连接,适合 Bot、服务端消息代理或需要主动收发消息的 Python 程序。覆盖连接管理、消息收发、会话查询、历史消息、聊天室、用户状态、RTC 房间和文件凭证查询等常用能力。
42
+
43
+ - 源码:<https://github.com/juggleim/imbot-sdk-python>
44
+ - 包名:`imbot-sdk-python`;导入名:`import imbot_sdk`
45
+
46
+ ## 安装
47
+
48
+ ```bash
49
+ pip install imbot-sdk-python
50
+ ```
51
+
52
+ 依赖(`protobuf>=5.0`、`websocket-client>=1.6`)会自动安装。Python 3.8+。
53
+
54
+ 从源码安装:
55
+
56
+ ```bash
57
+ git clone https://github.com/juggleim/imbot-sdk-python.git
58
+ cd imbot-sdk-python
59
+ pip install .
60
+ ```
61
+
62
+ ## 测试环境
63
+
64
+ | 项目 | 值 |
65
+ | --- | --- |
66
+ | Server API | `http://127.0.0.1` |
67
+ | WebSocket | `wss://127.0.0.1` |
68
+ | AppKey | `AppKey` |
69
+
70
+ > Token 由你的 JuggleIM 应用服务端 / 控制台用 AppKey + AppSecret 通过 Server API 颁发。SDK 本身只负责建立长连接与收发消息。
71
+
72
+ ## 能力概览
73
+
74
+ - 连接管理:`connect`、`disconnect`、`logout`、心跳保活、断线自动重连
75
+ - 消息收发:单聊、群聊、聊天室、公共频道消息发送与接收
76
+ - 消息管理:历史消息查询、撤回、修改、已读标记、搜索、置顶消息
77
+ - 会话管理:会话列表、未读数、置顶、免打扰、标签
78
+ - 用户与群信息:用户资料、好友资料、群信息、在线状态订阅
79
+ - 聊天室:加入/退出聊天室、聊天室消息、聊天室属性同步
80
+ - RTC:创建/加入/查询/退出 RTC 房间
81
+ - 文件:文件凭证查询 `get_file_cred`
82
+
83
+ ## 快速说明
84
+
85
+ ### 1. 创建客户端
86
+
87
+ ```python
88
+ from imbot_sdk import ImBotClient
89
+
90
+ client = ImBotClient("wss://127.0.0.1", "your-appkey")
91
+ ```
92
+
93
+ 说明:
94
+
95
+ - `address` 传基础地址即可,SDK 会自动拼接为 `ws://host/imbot` 或 `wss://host/imbot`
96
+ - `client.platform` 默认是 `"Bot"`
97
+ - `client.auto_reconnect` 默认是 `True`
98
+
99
+ ### 2. 建立连接
100
+
101
+ ```python
102
+ code, ack = client.connect("your-token")
103
+ ```
104
+
105
+ 说明:
106
+
107
+ - 连接成功时 `code == ClientErrorCode.SUCCESS`
108
+ - 成功后 `ack.userId` 会写入 `client.user_id`
109
+ - `connect` 只能在断开状态下调用;重复连接会返回 `ClientErrorCode.CONNECT_EXISTED`
110
+ - 主动调用 `disconnect()` 或 `logout()` 后,不会继续自动重连
111
+
112
+ ### 3. 接收消息的两种方式
113
+
114
+ 推荐优先使用高层监听(拿到的是已经解码后的 `Message`):
115
+
116
+ ```python
117
+ from imbot_sdk import MessageListener, messages
118
+
119
+ class MyListener(MessageListener):
120
+ def on_message_receive(self, msg):
121
+ if isinstance(msg.msg_content, messages.TextMessage):
122
+ print("text:", msg.msg_content.content)
123
+
124
+ client.add_message_listener(MyListener())
125
+ ```
126
+
127
+ 如果你想拿到底层 protobuf 数据:
128
+
129
+ ```python
130
+ client.on_message_callback = lambda down_msg: print(down_msg)
131
+ client.on_stream_msg_callback = lambda stream_msg: print(stream_msg)
132
+ ```
133
+
134
+ ### 4. 发送消息
135
+
136
+ ```python
137
+ from imbot_sdk import Conversation, messages
138
+ from imbot_sdk.pb import appmessages_pb2 as pb
139
+
140
+ text = messages.TextMessage("hello from imbot-sdk-python")
141
+ up = client.build_up_msg(text, client_uid="bot-1")
142
+
143
+ conv = Conversation(conversation_type=pb.Private, conversation="target-user-id")
144
+ code, ack = client.send_message(conv, up)
145
+ # ack.msgId / ack.msgSeqNo 为服务端确认结果
146
+ ```
147
+
148
+ `build_up_msg` 会把内容模型编码进 `UpMsg.msgType / msgContent / flags`;你也可以直接构造 `pb.UpMsg`。
149
+
150
+ ## 完整示例:连接、监听、回声
151
+
152
+ ```python
153
+ import time
154
+ from imbot_sdk import ImBotClient, Conversation, MessageListener, ClientErrorCode, messages
155
+ from imbot_sdk.pb import appmessages_pb2 as pb
156
+
157
+ class Echo(MessageListener):
158
+ def __init__(self, client):
159
+ self.client = client
160
+ def on_message_receive(self, msg):
161
+ c = msg.msg_content
162
+ if isinstance(c, messages.TextMessage) and msg.sender_id != self.client.user_id:
163
+ up = self.client.build_up_msg(messages.TextMessage("echo: " + c.content),
164
+ client_uid="echo-%d" % time.time_ns())
165
+ self.client.send_message(msg.conversation, up)
166
+
167
+ client = ImBotClient("wss://127.0.0.1", "AppKey")
168
+ client.add_message_listener(Echo(client))
169
+
170
+ code, ack = client.connect("your-token")
171
+ assert code == ClientErrorCode.SUCCESS
172
+ print("connected:", ack.userId)
173
+
174
+ # 主动给某用户发一条单聊
175
+ up = client.build_up_msg(messages.TextMessage("hi"), client_uid="greet-1")
176
+ client.send_message(Conversation(conversation_type=pb.Private, conversation="target-user-id"), up)
177
+
178
+ try:
179
+ while True:
180
+ time.sleep(1)
181
+ except KeyboardInterrupt:
182
+ client.disconnect()
183
+ ```
184
+
185
+ 可运行的版本见 [`examples/echo_bot.py`](examples/echo_bot.py)。推荐用 `.env` + 启动脚本:
186
+
187
+ ```bash
188
+ cp examples/.env.example examples/.env
189
+ # 编辑 examples/.env,至少填入 IMBOT_TOKEN(可选 IMBOT_TARGET)
190
+ bash examples/run.sh
191
+ ```
192
+
193
+ `run.sh` 会自动加载 `examples/.env` 并启动 echo bot,多余参数会透传给脚本(如
194
+ `bash examples/run.sh --target some-user-id`)。也可以不用脚本,直接传参或导出环境变量:
195
+
196
+ ```bash
197
+ python examples/echo_bot.py --token <your-token> --target <target-user-id>
198
+ ```
199
+
200
+ 配置项(环境变量 / `.env`):
201
+
202
+ | 变量 | 说明 | 必填 |
203
+ | --- | --- | --- |
204
+ | `IMBOT_TOKEN` | 用户 Token | 是 |
205
+ | `IMBOT_TARGET` | 启动时打招呼的目标用户 ID | 否 |
206
+ | `IMBOT_ADDRESS` | WebSocket 基础地址 | 否 |
207
+ | `IMBOT_APPKEY` | 应用 AppKey | 否 |
208
+
209
+ 补充说明:
210
+
211
+ - 单聊发送使用 `pb.Private`,群聊使用 `pb.Group`,聊天室使用 `pb.Chatroom`,公共频道使用 `pb.PublicChannel`
212
+ - 聊天室消息也可以直接 `client.send_chatroom_msg(chatroom_id, up_msg)`
213
+ - 接收到的 `msg.msg_content` 已按消息类型解码,可直接 `isinstance` 判断
214
+
215
+ ## 消息类型
216
+
217
+ 内置的消息内容模型位于 `imbot_sdk.messages`:
218
+
219
+ | 类型 | 标识 | 类 |
220
+ | --- | --- | --- |
221
+ | 文本 | `jg:text` | `TextMessage` |
222
+ | 图片 | `jg:img` | `ImageMessage` |
223
+ | 文件 | `jg:file` | `FileMessage` |
224
+ | 视频 | `jg:video` | `VideoMessage` |
225
+ | 语音 | `jg:voice` | `VoiceMessage` |
226
+ | 流式文本 | `jg:streamtext` | `StreamTextMessage` |
227
+ | 撤回通知 | `jg:recallinfo` | `RecallInfoMessage` |
228
+ | 合并消息 | `jg:merge` | `MergeMessage` |
229
+ | 缩略图打包图片 | `jg:tpimg` | `ThumbnailPackedImageMessage` |
230
+ | 快照打包视频 | `jg:spvideo` | `SnapshotPackedVideoMessage` |
231
+
232
+ 收到未内置支持的消息类型时,SDK 会回落为 `messages.UnknownMessage`。这些模型的 JSON 编解码字段保持稳定,因此消息可与其它 JuggleIM 客户端互通。
233
+
234
+ ## 常用 API
235
+
236
+ > 完整方法清单见 [`docs/API.md`](docs/API.md)。命名采用 Python 风格(snake_case)。
237
+
238
+ ### 连接与状态
239
+
240
+ `connect(token)`、`reconnect()`、`disconnect()`、`logout()`、`ping()`、`add_connection_status_change_listener(listener)`
241
+
242
+ ### 消息
243
+
244
+ `send_message(conversation, up_msg)`、`qry_history_msgs(req)`、`recall_msg(req)`、`modify_msg(req)`、`mark_read_msg(req)`、`msg_search(req)`、`msg_global_search(req)`、`set_top_msg(req)`、`del_top_msg(req)`
245
+
246
+ ### 会话
247
+
248
+ `get_conversation(req)`、`get_conversations(req)`、`sync_conversations(req)`、`clear_unread_count(req)`、`set_conversation_top(req)`、`set_mute(req)`、`delete_conversations(req)`
249
+
250
+ ### 用户、群组、状态
251
+
252
+ `fetch_user_info(user_id)`、`fetch_group_info(group_id)`、`fetch_friend_info(friend_user_id)`、`get_user_status(req)`、`subscribe_user_status(req)`、`unsubscribe_user_status(req)`
253
+
254
+ ### 聊天室
255
+
256
+ `join_chatroom(chatroom_id)`、`quit_chatroom(chatroom_id)`、`send_chatroom_msg(chatroom_id, up_msg)`、`set_attributes(chatroom_id, attributes)`、`remove_attributes(chatroom_id, keys)`
257
+
258
+ ### RTC
259
+
260
+ `create_rtc_room(req)`、`join_rtc_room(req)`、`qry_rtc_room(room_id)`、`quit_rtc_room(room_id)`、`rtc_invite(req)`
261
+
262
+ ### 文件
263
+
264
+ `get_file_cred(req)`
265
+
266
+ > 当前 SDK 提供文件凭证查询能力,文件上传/下载流程需由业务侧结合存储服务自行处理。
267
+
268
+ ## 使用注意事项
269
+
270
+ - `publish` 和 `query` 都要求当前连接状态为 `CONNECTED`,否则返回 `ClientErrorCode.CONNECT_CLOSED`
271
+ - 发送和查询默认等待 10 秒 ACK,超时分别返回 `ClientErrorCode.SEND_TIMEOUT`、`ClientErrorCode.QUERY_TIMEOUT`
272
+ - SDK 内部会自动处理心跳;连续超过两个心跳周期(约 20 秒)未收到下行数据,会断开并尝试自动重连
273
+ - 消息监听回调运行在内部线程上,请避免长时间阻塞操作,必要时投递到工作队列
274
+ - 图片、文件、语音、视频等消息体只负责内容编解码,不负责上传文件本身
275
+
276
+ ## 重新生成 protobuf
277
+
278
+ `.proto` 源文件位于 [`proto/`](proto/)。修改后重新生成:
279
+
280
+ ```bash
281
+ bash proto/gen.sh
282
+ ```
283
+
284
+ ## 模块结构
285
+
286
+ | 模块 | 说明 |
287
+ | --- | --- |
288
+ | `imbot_sdk.ImBotClient` | 客户端主入口 |
289
+ | `imbot_sdk.ClientErrorCode` / `ConnectState` | 错误码与连接状态 |
290
+ | `imbot_sdk.models` | 领域模型(`Conversation` / `Message` / `UserInfo` …)|
291
+ | `imbot_sdk.messages` | 消息内容模型 |
292
+ | `imbot_sdk.pb` | protobuf 类型(`appmessages_pb2` / `connect_pb2` / `chatroom_pb2` / `rtcroom_pb2`)|
293
+
294
+ ## 许可证
295
+
296
+ [LICENSE](LICENSE)
@@ -0,0 +1,20 @@
1
+ imbot_sdk/__init__.py,sha256=04mbVzRjopiXkSBc5Q-rKO0HI-a9vJn7bH3IHlg0fEc,1456
2
+ imbot_sdk/client.py,sha256=qOG3BZOBZH_JA_0iDpxrFVQGgfwdyRJ2NZzWNop2Y2M,46357
3
+ imbot_sdk/consts.py,sha256=EQhnWoc0RFDMIpZl7posvVwFDblnpQ0VJaW-bgAC6IQ,754
4
+ imbot_sdk/data_accessor.py,sha256=om_UzAAgCGtNqWZbLcpU0VFq_Tmi-Xi3lkwv-E-unHw,1018
5
+ imbot_sdk/listeners.py,sha256=ff7fK0j9tMNuC1on6oPgVTROnHJR-bjHkaYhlewoLjU,1900
6
+ imbot_sdk/models.py,sha256=zG3twrJGUE64bcTR9L2Bd6yot4ihRJvkZh_OmRbYJE8,2427
7
+ imbot_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ imbot_sdk/messages/__init__.py,sha256=92XXBJ3bEwX1XS6Mmfdwlkw7rTPPPt3qN7cwnaAqZ20,2773
9
+ imbot_sdk/messages/base.py,sha256=RgPpA7lqSUUYVs1CNksHA1IxEz-359TTQOo9rLJ0l_c,1694
10
+ imbot_sdk/messages/contents.py,sha256=7UhMDz32qmq7cHqEMAqLAM8-s_jQGIOpde2n6LqV2Zg,14588
11
+ imbot_sdk/pb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ imbot_sdk/pb/appmessages_pb2.py,sha256=7yyt_KqDs7rO8TtYO88AJIqfB5yLfoPV3PwRSpidues,58696
13
+ imbot_sdk/pb/chatroom_pb2.py,sha256=2SD6pyFKZuFhOvvZbDffX591OrYqv8q7eNm4SA-7s9o,9452
14
+ imbot_sdk/pb/connect_pb2.py,sha256=k3QU7PAaYL_umjV5WXloxgWlYvKrM7CSV6Fj0eBxhzo,4777
15
+ imbot_sdk/pb/rtcroom_pb2.py,sha256=v9uuWxbEvsmwHHt9OLuDvE4w1v0wQX7e1Xxv0mKFQPo,8037
16
+ imbot_sdk_python-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ imbot_sdk_python-0.1.0.dist-info/METADATA,sha256=EIbaMnjWWsczumOZ8wsZZs3_od7syuMxnESSuFf6jp8,11119
18
+ imbot_sdk_python-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
19
+ imbot_sdk_python-0.1.0.dist-info/top_level.txt,sha256=Q636V3MNhiMZGfV2FfiBcNaYh4bHlVB0iXVMQgVuoeo,10
20
+ imbot_sdk_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+