通过管道将文本发送到hipchat
hipcat的Python项目详细描述
从命令行通过管道传送到hipchat!
灵感来自Slackcat!
安装
您将需要一个工作的Python 3安装(如果您 在Linux或OSX上)和 PIP。
pip3 install hipcat
转到https://www.hipchat.com/account/api并创建新令牌。它 只需要“发送消息”作用域,但将来可能会发生变化。
在~/.hipcat.ini处创建一个类似这样的文件:
[hipchat]access_token=<put-your-token here>
使用HIPCAT
您可以通过运行hipcat --help获得帮助,但基本功能如下 这个:
# Pipe output from one command to HipChat: echo'This is my message'| hipcat 'Room Name'
如果你不想通过管道传递消息,你可以 作为参数提供:
# Run a long running command and then notify on HipChat my-long-task && hipcat 'Notifications' -m "The long-running task is done"
如果发送给hipchat的文本是格式化的,请使用-q标志 以/quote作为前缀,如果它应该是语法突出显示的代码, 使用-c标志以/code作为前缀。
您可以使用用户的“提及名称”发送直接消息 而不是房间名称:
``` bash echo“你很棒”hipcat‘@FriendlyDave'
通知
您发送的消息也可能被视为room notification 通过--notification标志。以下附加选项和 然后HIPCAT识别标志:
- --color指定邮件的背景色。有效的 值:黄色、绿色、红色、紫色、灰色、随机。默认为 黄色。
- --sender指定除 发件人姓名。如果--notify(见下文)是hipcat 也有详细说明。
- --notify以确保此消息触发用户通知。
# Send a message "Message" with a purple background, from "BOT" and with a # user notification: hipcat 'Notifications' --notification --notify -m "Message" --color=purple --sender="BOT"
对HIPCAT的贡献
你想捐款吗?爱你!
有些事情你应该知道:
- 请不要将其反向移植到python 2。是的,我知道这很容易。我们 现在应该都在写python 3了。
- 请尊重其他投稿人和评论人。
- 请确保按照PEP-8进行任何更改。
- 当我添加测试时(还没有!)我打算用py.test。如果 如果你想通过附加测试来帮助你,我们先来谈谈。
待办事项
- 添加一个标志,将输出逐行发送到hipchat,而不是发送到 结束。
- 允许向个人和房间发送邮件。
- 允许将内容上载为文件而不是内联文本。
- 呃…如果你想看到一个新特性,发布一个github问题,然后 我们谈谈!