Code Monkey home page Code Monkey logo

lockbot's Introduction

Lockbot

Node.js CI Coverage Status Join Slack workspace MIT License

Demo: lockbot.app

Coordinate use of your team's shared resources, in Slack ๐Ÿค

Lockbot only lets each shared resource be locked by one person at a time - like a Mutex ๐Ÿ”’

Example use case: One person wants to deploy and test on a shared staging environment without someone else deploying and overwriting their deployed code, so they use /lock staging-env to lock the staging environment and notify the channel.

โš  Lockbot cannot physically prevent naughty or unaware users from using a resource whilst it's locked by someone else. Your team must agree to use Lockbot whenever they start or stop using a shared resource.

Add Lockbot to Slack

How to use Lockbot

Lockbot has three main commands:

  • /locks Get locked resources list ๐Ÿ“œ
  • /lock [resource-name] Lock a resource ๐Ÿ”’
  • /unlock [resource-name] [options] Unlock a resource ๐Ÿ”“
    • Set [options] to force if you need to unlock when someone is away on holiday โ›ฑ

Each Slack channel has its own list of resources.

When someone successfully locks or unlocks a resource, the channel is notified.

Lockbot API

It is possible to view, create and delete locks via the Lockbot HTTP API.

To explore the API take a look at the OpenAPI spec.

The API is secured using basic access authentication.

  • /lbtoken Learn about Lockbot API access tokens ๐Ÿ’ก
  • /lbtoken new Generate a new Lockbot API access token ๐ŸŽซ

Each access token is scoped to the Slack team and channel they were created in and to the user who created them.

Contributing

Don't be a stranger, contributions are welcome โœจ

See the Contributing Guide for development setup instructions.

Security

If you discover a security vulnerability, please send an e-mail to [email protected]

lockbot's People

Contributors

connorads avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lockbot's Issues

Error when bot is not in channel and tries to use `say`

image

bolt-app Error: An API error occurred: not_in_channel
    at Object.platformErrorFromResult (/var/task/node_modules/@slack/web-api/dist/errors.js:50:33)
    at WebClient.apiCall (/var/task/node_modules/@slack/web-api/dist/WebClient.js:486:28)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async respond (/var/task/src/index.js:24:17)
    at async /var/task/src/index.js:53:5
    at async Array.<anonymous> (/var/task/node_modules/@slack/bolt/dist/middleware/builtin.js:203:9)
    at async Array.exports.onlyCommands (/var/task/node_modules/@slack/bolt/dist/middleware/builtin.js:39:5) {
  code: 'slack_webapi_platform_error',
  data: {
    ok: false,
    error: 'not_in_channel',
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  }
}

Send message in channel when locking via API

When I lock via the API, I would like to see a message posted in the channel to indicate I've locked a resource. At the moment this just happens with no visibility to other users.

Public API with usage stats

Would be interesting to expose this data and perhaps measure it over time

  • No of teams/installs
  • Locks/unlocks per day

Feature: show the time a resource was locked in the slack message

When I run the /locks command in Slack I would love to see what time each resource was locked.

Screenshot 2021-02-05 at 09 55 01

The reason I want this is I want an easier way to tell whether a lock is stale (and someone's forgotten to clean it up) or if it's been recently locked. Other features requested include notifications and I'd prefer that setup too! But this seemed like an easier improvement so thought I'd suggest it here too ๐Ÿ˜‰

Idea: Access locks outside a channel

It might be nice to expand the command to work across channels e.g. /lock cazops dev or /locks cazops. Perhaps /mylocks or something to show everything I've locked.

Improve README.md

Usage

  • GIF to demonstrate usage
  • Explain channel segregation
  • What's it all for/about? Use cases? Why?
  • Link to website for demo
  • Test the app in a channel with yourself

Dev stuff

  • Tests run twice: 1) using in-memory (fast dev feedback 1ms) and 2) using local dynamodb (still fast feedback 40ms)
  • Explain core of bot logic is encapsulated in lock-bot.ts without reference to slack so could be ported to other chat platforms
  • Bot logic works against repository abstraction, easy to port to different database/storage
  • Can use other cloud cloud platform's serverless function offering, just need to adapt index.ts and serverless.yaml etc.
  • Forks and/or contributions are welcome

Deployment

Misc

  • Add to Slack button
  • Licence badge

Ack requests earlier

Slack docs suggests acking as soon as possible because you only have 3 seconds to respond

https://slack.dev/bolt-js/concepts#acknowledge

So after you validate input but before you start hitting databases etc.

Not currently getting any performance issues despite hitting the DB before acking in most cases.

But would need to refactor so that validation could be accessed early.

Is it worth it?

Add Lockbot branding/logo/avatar

Must have

  • Square icon/logo for bot avatar (and other icons)

image

Nice to have

  • Colour scheme
  • Logo with text for README.md and elsewhere

Some ideas ...

image

image

image

image

image

image

image

image

image

Error when unknown option is passed to /unlock

i.e. /unlock thingy please should say please is not a command
And maybe accept/suggest when people use nearby things like /unlock thingy --force instead of /unlock thingy force as this is currently silently ignoring the --force

Add force unlock command

What happens if your team mate goes on holiday but forgets to unlock something?
Force unlock to the rescue.

Should notify channel and probably at/mention both the force unlocker and the lock owner

Deploy to Prod

  • Setup AWS account(s)
  • Increase prod vs dev DynamoDB capacity
  • Create dev Slack App/environment

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.