aiobearychat.rtm
¶
-
class
aiobearychat.rtm.
RtmAPI
(requester: aiobearychat.abc.Requester, token: str = NOTHING, *, base_url: str = '')[源代码]¶ RTM HTTP 相关 API.
参数: - requester (aiobearychat.abc.Requester) – 实际进行请求操作的 requester
- token (str) – RTM token, 目前可以通过创建 hubot 机器人获得
- base_url (str) – RTM HTTP API
-
base_url
= 'https://rtm.bearychat.com'¶ RTM HTTP API 的基地址
-
message
(vchannel: str, text: str, *, markdown: bool = True, attachments: typing.Union[list, NoneType] = None, **requester_params: typing.Any) → aiobearychat.sansio.Response[源代码]¶ 发送富文本消息
官方文档地址: https://github.com/bearyinnovative/OpenAPI/blob/master/rtm/api_message.md
参数: - vchannel (str) – 目标会话 id,示例:
=bw52O
- text (str) – 消息正文
- markdown (bool) – 消息正文是否使用 markdown 格式?(默认值:
True
) - attachments (
list
) –消息 attachment 结构,示例:
[ { "title": "test_title", # attachment 标题,title / text 至少包含一个 "text": "test_text", # attachment 内容,title / text 至少包含一个 "images": [{ # attachment 图片列表,可选 "url": "http://example.com/1.jpg" }], "color": "#cb3f20" # attachment 颜色,可选 } ]
返回: response. 一个
aiobearychat.sansio.Response
实例返回类型: response.body
返回值示例:response.status 等于 200 时: { "code": 0, "result": null }
- vchannel (str) – 目标会话 id,示例:
-
start
(**requester_params: typing.Any) → aiobearychat.sansio.Response[源代码]¶ 获取 RTM 模式的连接地址和用户信息。
官方文档地址: https://github.com/bearyinnovative/OpenAPI/blob/master/rtm/api_start.md
返回: response. 一个 aiobearychat.sansio.Response
实例返回类型: aiobearychat.sansio.Response
response.body
返回值示例:response.status 等于 200 时: { "code": 0, "result": { // RTM token 对应用户结构 "user": {}, // RTM 连接地址 5 分钟内有效 "ws_host": "wss://rtm.bearychat.com/nimbus/ws:xxx" } }