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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值