Post process information to the slack without clogging up the channel with a bunch of messages. Easily update status, see when operation started / finished and how much time it took.
$ pip install slackops
import slackops
slack = slackops.Operation(token=SLACK_BOT_TOKEN, channel=CHANNEL_NAME)
slack.start("Application update", "Backup")
slack.update("2. Updating application")
slack.update("3. Healthchecks")
slack.finish("4. Application successfully updated!")
Operation statuses also posted to thread:
Note: any formatting you see in 'Message' template (header, text, context), can also be used with 'Operation' template you seen before.
slack = slackops.Message(token=SLACK_BOT_TOKEN, channel=CHANNEL_NAME)
slack.post(
text="Example message",
severity="error", # info | success | warning | error
header="Header",
context=["from ip: 192.162.1.1"],
)
You can set default values:
slack.tmpl.default.set(context=["default context - from ip: 192.162.1.1"])
slack.tmpl.default.set(severity="success")
slack.post("If no value is passed, the default value will be used (if available).")
And persistent values:
slack.tmpl.persistent.set(header="API event: ")
slack.tmpl.persistent.set(text="*Details:*\n")
slack.post("username: haru\n ", header="new user!")
To use 'Operation' template beetwen different lamdas, you can do following:
- Export in first lambda:
packed_operation = slack.pack()
- And import in second lambda:
slack = slackops.Operation(packed_operation=packed_operation)