rocket.chat python api wrapper示例

rocket.chat python api wrapper示例

阅读原文

建议阅读原文,始终查看最新文档版本,获得最佳阅读体验:《rocket.chat python api wrapper示例》

rocket.chat详细介绍

请看此文:《rocket.chat--开源的跨平台即时通讯软件》

rocket.chat HTTP API示例

请看此文:《rocket.chat HTTP API示例》

官方网站

jadolg/rocketchat_API: Python API wrapper for Rocket.Chat

安装库

pip3 install rocketchat_API
#注意rocketchat_API依赖requests

最简单的示例--获取当前授权用户的基本信息

from pprint import pprint
from rocketchat_API.rocketchat import RocketChat

rocket = RocketChat(user_id='<此处替换为你的user id>', auth_token='<此处替换为你的auth token>', server_url='http://10.65.37.237:3000')

pprint(rocket.me().json())

输出

image.png

发送消息给channel

pprint(rocket.chat_post_message('good news everyone!', channel='GENERAL', alias='Farnsworth').json())

image.png

相应的channel确实出现了刚刚用api发送的消息

image.png

发送消息给room或者某个用户

#注意:The room ID or an array of room IDs where the message is to be sent. You can use channel name or username. The channel name must have the # prefix. @ refers to username.
pprint(rocket.chat_post_message('wow!', room_id='@bob', alias='API-user').json())

image.pngimage.png

关于作者和DreamAI

https://docs.dingtalk.com/i/nodes/Amq4vjg890AlRbA6Td9ZvlpDJ3kdP0wQ?iframeQuery=utm_source=portal&utm_medium=portal_recent

关注微信公众号“AI发烧友”,获取更多IT开发运维实用工具与技巧,还有很多AI技术文档!

梦幻智能logo-01(无水印).png

posted @ 2025-06-23 09:21  iamtornado  阅读(24)  评论(0)    收藏  举报