hipchat / hipchat-cli Goto Github PK
View Code? Open in Web Editor NEWCommand line scripts for working with the HipChat REST API
Home Page: http://www.hipchat.com
License: MIT License
Command line scripts for working with the HipChat REST API
Home Page: http://www.hipchat.com
License: MIT License
There seems to be some strange processing of HTML data for even basic messages:
echo "<a href='http://a.com'>A</a>" | hipchat-cli/hipchat_room_message
produces:
A
">http://a.com'>A
within the HipChat client. Is there something invalid about this HTML message?
Would be nice for OS X.
According to the Hipchat API docs, the img
tag is supported in html-formatted notification messages. Unfortunately, if the message input includes an img
tag, this script will attempt to convert the value of the src
attribute to an HTML anchor element. This is obviously undesirable, as it results in the posting of a malformed message.
The simplest fix would involve a tweak to the URL replacement regex to prevent it from acting on img
tags. The following should suffice (though it could certainly be made more terse):
# replace bare URLs with real hyperlinks
INPUT=$(echo -n "${INPUT}" | perl -p -e "s/(?<!href=\"|href='|src=\"|src=')((?:https?|ftp|mailto)\:\/\/[^ \n]*)/\<a href=\"\1\"\>\1\<\/a>/g")
I'm happy to submit a patch to accomplish this, but I wanted to suggest a possible alternative first. I'm wondering if perhaps the URL replacement should be disabled for html-formatted messages. It's definitely helpful for text-formatted messages, but it seems more intuitive that an html-formatted message should be required to build links explicitly.
This would be a breaking change of course, but I'm not sure whether that is a concern for the use case of this script.
I have a Ruby program that sets the HipChat user's presence/show attribute (AKA, status). Would you be interested in pulling this if I submitted a PR?
When sending message with new lines ( \n
) the content is not completely cleared resulting on non valid json send, and you get this message back :
{
"error": {
"code": 400,
"message": "The request body cannot be parsed as valid JSON: Invalid control character at: line 1 column 121 (char 121)",
"type": "Bad Request"
}
}
Here is a quick fix. Replace this block line 100
# replace newlines with XHTML <br>
if [ $FORMAT == 'html' ]; then
INPUT=$(echo -n "${INPUT}" | sed "s/$/\<br\>/")
INPUT=$(echo -n "${INPUT}" | tr '\n' ' ')
fi
There is some processing/cleanup done using Perl. However, there are cases where Perl might not be available. Is there a SED or AWK alternative for the use of Perl?
Example:
perl -p -e "s/(?<!href=\"|href=')((?:https?|ftp|mailto)\:\/\/[^ \n]*)/\<a href=\"\1\"\>\1\<\/a>/g")
i am hoping to use the script. where do i let the script know about the location of the hip chat server ?
The api v2 didn't need the From name switch but for the script is always mandatory.
I've simply modified the check at line 73
if [[ -z $TOKEN ]] || [[ -z $ROOM_ID ]] || [[ -z $FROM && $API == "v1" ]] ; then
in order to keep the check only for v1 api.
I'm having issues with getting the script to read the config file in /etc/hipchat, is there anything I need to do in order to get it to read the config file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.