Skip to content

Instantly share code, notes, and snippets.

@daxanya2
Created February 8, 2014 05:00
Show Gist options
  • Save daxanya2/8876919 to your computer and use it in GitHub Desktop.
Save daxanya2/8876919 to your computer and use it in GitHub Desktop.
Hipchatに入力した内容をAPIで取得してDay Oneにワンライナーで貼付ける ref: http://qiita.com/daxanya1/items/da15ce1853465e262ba8
https://api.hipchat.com/v1/rooms/history?room_id={room_id}&date={date}&timezone=JST&format=json&auth_token={token}
{"messages":[{"date":"2014-02-06T10:01:07+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"https:\/\/github.com\/bowery\/orchestrate.js"},{"date":"2014-02-06T10:01:11+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"orchestrate.js"},{"date":"2014-02-06T10:01:18+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"http:\/\/www.slideshare.net\/who_you_me\/neo4j-24294061"},{"date":"2014-02-06T10:01:22+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"\u30b0\u30e9\u30d5\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u300cNeo4j\u300d\u306e \u5c0e\u5165\u306e\u5c0e\u5165"}]}
$ cat example.json | jq '.messages[] | [.date, " ", .message] | add' | sed -e "s/^\"[0-9-]\{10\}T//" | sed -e "s/^\([0-9:]\{8\}\)+0900/\1/" | sed s/\"$//
10:01:07 https://github.com/bowery/orchestrate.js
10:01:11 orchestrate.js
10:01:18 http://www.slideshare.net/who_you_me/neo4j-24294061
10:01:22 グラフデータベース「Neo4j」の 導入の導入
$ cat example.json | jq '.messages[] | [.date, " ", .message] | add' | sed -e "s/^\"[0-9-]\{10\}T//" | sed -e "s/^\([0-9:]\{8\}\)+0900/\1/" | sed s/\"$// | awk -v p=`date -v-1d +%Y-%m-%d` -F'\t' 'BEGIN{print "# hipchat-log",p} {print}'
# hipchat-log 2014-02-07
10:01:07 https://github.com/bowery/orchestrate.js
10:01:11 orchestrate.js
10:01:18 http://www.slideshare.net/who_you_me/neo4j-24294061
10:01:22 グラフデータベース「Neo4j」の 導入の導入
$ curl -s -X GET 'https://api.hipchat.com/v1/rooms/history?room_id={room_id}&date='`date -v-1d +%Y-%m-%d`'&timezone=JST&format=json&auth_token={token}' | jq '.messages[] | [.date, " ", .message] | add' | sed -e "s/^\"[0-9-]\{10\}T//" | sed -e "s/^\([0-9:]\{8\}\)+0900/\1/" | sed s/\"$// | awk -v p=`date -v-1d +%Y-%m-%d` -F'\t' 'BEGIN{print "# hipchat-log",p} {print}' | dayone new
$ cat example.json | jq '.messages[]'
{
"message": "https://github.com/bowery/orchestrate.js",
"from": {
"user_id": 544xxx,
"name": "daxanya (-v-)"
},
"date": "2014-02-06T10:01:07+0900"
}
{
"message": "orchestrate.js",
"from": {
"user_id": 544xxx,
"name": "daxanya (-v-)"
},
"date": "2014-02-06T10:01:11+0900"
}
{
"message": "http://www.slideshare.net/who_you_me/neo4j-24294061",
"from": {
"user_id": 544xxx,
"name": "daxanya (-v-)"
},
"date": "2014-02-06T10:01:18+0900"
}
{
"message": "グラフデータベース「Neo4j」の 導入の導入",
"from": {
"user_id": 544xxx,
"name": "daxanya (-v-)"
},
"date": "2014-02-06T10:01:22+0900"
}
$ cat example.json | jq '.messages[] | [.date, .message]'
[
"2014-02-06T10:01:07+0900",
"https://github.com/bowery/orchestrate.js"
]
[
"2014-02-06T10:01:11+0900",
"orchestrate.js"
]
[
"2014-02-06T10:01:18+0900",
"http://www.slideshare.net/who_you_me/neo4j-24294061"
]
[
"2014-02-06T10:01:22+0900",
"グラフデータベース「Neo4j」の 導入の導入"
]
$ cat example.json | jq '.messages[] | [.date, .message] | add'
"2014-02-06T10:01:07+0900https://github.com/bowery/orchestrate.js"
"2014-02-06T10:01:11+0900orchestrate.js"
"2014-02-06T10:01:18+0900http://www.slideshare.net/who_you_me/neo4j-24294061"
"2014-02-06T10:01:22+0900グラフデータベース「Neo4j」の 導入の導入"
$ cat example.json | jq '.messages[] | [.date, ' ', .message] | add'
"2014-02-06T10:01:07+0900 https://github.com/bowery/orchestrate.js"
"2014-02-06T10:01:11+0900 orchestrate.js"
"2014-02-06T10:01:18+0900 http://www.slideshare.net/who_you_me/neo4j-24294061"
"2014-02-06T10:01:22+0900 グラフデータベース「Neo4j」の 導入の導入"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment