Code Monkey home page Code Monkey logo

slackops's Introduction

SlackOps

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.

PyPI version

Installation

$ pip install slackops

Table of contents

Basic usage

import slackops

slack = slackops.Operation(token=SLACK_BOT_TOKEN, channel=CHANNEL_NAME)

slack.start("Application update", "Backup")

1. Start

slack.update("2. Updating application")

2. Updating application"

slack.update("3. Healthchecks")

3. Healthchecks

slack.finish("4. Application successfully updated!")

4. Application successfully updated!

Operation statuses also posted to thread:

Thread messages

Simple message

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"],
)

message

Formatting. Default and persistent values

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).")

default values

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!")

persistent values

AWS Lambda

To use 'Operation' template beetwen different lamdas, you can do following:

  1. Export in first lambda:
packed_operation = slack.pack()
  1. And import in second lambda:
slack = slackops.Operation(packed_operation=packed_operation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.