Instantly share code, notes, and snippets.

Embed
What would you like to do?
useful https://requesthub.xyz/ modifiers
# POST https://api.pushbullet.com/v2/pushes
# requires 'Access-Token' header
{
device_iden: "<pushbullet device id>",
type: "note",
title: "\(.Message | fromjson | .NewStateValue): \(.Message | fromjson | .AlarmName)",
body: "\(.Message | fromjson | .AlarmDescription) -- \(.Message | fromjson | .NewStateReason) -- \(.Message | fromjson | .StateChangeTime)"
}
# POST https://hooks.slack.com/services/<et cetera>
.payload | fromjson | {
fallback: "\(.events | length) events",
text: "results for \"\(.saved_search.name)\"",
pretext: "search query: \"\(.saved_search.query)\" (<\(.saved_search.html_search_url)|details>)",
color: "danger",
fields: .events | map({
title: "\(.hostname) - \(.program)",
value: .message,
short: false
})
}
# POST https://hooks.slack.com/services/<et cetera>
# I use it with a Trello list webhook (otherwise there would be too much webhooks).
# Trello board webhooks could be used too, but the last section of this script has
# an 'updateCard' handler that refers to a specific list name.
# Besides that, a lot of different handlers can be added/removed here.
.action | {
attachments: [
(if .type == "commentCard" then {
color: "#007FC9",
pretext: "comment on <https://trello.com/c/\(.data.card.shortLink)#comment-\(.id)|\(.data.card.name)>",
fallback: "\(.memberCreator.username) says on '\(.data.card.name)': '\(.data.text)'",
fields: [{
title: .memberCreator.username,
value: .data.text
}]
} elif .type == "updateCard" and .data.old.name then {
color: "#F2F2F2",
fallback: "Card '\(.data.old.name)' renamed to '\(.data.card.name)' by \(.memberCreator.username)",
pretext: "\(.memberCreator.username) renamed '\(.data.old.name)'",
fields: [{
title: "Name",
value: "<https://trello.com/c/\(.data.card.shortLink)|\(.data.card.name)>"
}]
} elif .type == "updateCard" and .data.old.desc then {
color: "#F2F2F2",
pretext: "\(.memberCreator.username) changed <https://trello.com/c/\(.data.card.shortLink)|\(.data.card.name)> description",
fallback: "\(.memberCreator.username) changed \(.data.card.name) description",
fields: [{
title: "Description",
value: .data.card.desc
}]
} elif .type == "createCard" then {
color: "#007FC9",
text: "\(.memberCreator.username) created <https://trello.com/c/\(.data.card.shortLink)|\(.data.card.name)>",
fallback: "\(.memberCreator.username) created \(.data.card.name)"
} elif .type == "updateCard" and .data.listAfter.name == "<This list name>" then {
color: "#007FC9",
text: "\(.memberCreator.username) moved <https://trello.com/c/\(.data.card.shortLink)|\(.data.card.name)> to this list",
fallback: "\(.memberCreator.username) moved \(.data.card.name) to this list"
} else {} end)
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment