Coder Social home page Coder Social logo

commands's Introduction

Probot: Commands

A Probot extension that adds slash commands to GitHub.

For example, from a comment box someone could type:

Slash commands in a comment box

A Probot app could then use this extension to listen for the remind slash command.

Installation

$ npm install --save probot-commands

Usage

const commands = require('probot-commands')

module.exports = robot => {
  // Type `/label foo, bar` in a comment box for an Issue or Pull Request
  commands(robot, 'label', (context, command) => {
    const labels = command.arguments.split(/, */);
    return context.github.issues.addLabels(context.issue({labels}));
  });
}

commands's People

Contributors

bkeepers avatar dnldsht avatar gr2m avatar hiimbex avatar macklinu avatar sallycsy 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

commands's Issues

Allow commands to be wrapped in an HTML comment

@gr2m suggested using the trick that metadata uses to allow command to be concealed by HTML comments:

<!-- /command that nobody sees -->

The regex for commands just needs to be updated to optionally allow an html comment at the beginning of the line.

how to add assignees to issue

Capture
note: the end result of this code is to add assignees to issues based on `/assign @pk @ab' structured comment.
Problem : its not working(obviously). I have commented some(or a lot) of the code to see if at least the context.payload is getting logged(from which point i can make progress). The payload is not logged. However, the code taken from the probot-commands repo to assign labels using /label command is working perfectly(which i am using as the base to build the /assign command).

I checked and the issue_comment.created webhook is working fine. Its somehow not working. Down is the ss of my console.
c1
A line of thought: it seems that the server(where my codebase is hosted, local currently) is hanging when i try to run /assign command. As can be seen in the console screenshot, there is a gap between third-last timestamp and fourth last timestamp. The fourth last timestamp is where the server stopped responding, then i restarted nodemon using 'rs', then i posted a comment again on the github issue to check if everything is still working as expected.

TypeScript support

Will there be TypeScript support for probot-commands?

Since create-probot-app supports the typescript option, Probot apps can now be created with TypeScript.

Add TypeScript types

The support was done in this PRs
#15
#20
But both were automatically closed by the bot.

Could you accept one of these PRs please?

Similar issues:
#10
#19

Any command with "-" will not be recognized.

I am trying to create new commands but I need to have a dash between words, ex: /create-issue. For some reason this does not work but something like /create_issue will work.

Probot Crashes if PR Description Body is Empty

Probot, with the probot-commands extension installed, will crash if a PR is opened and the description is empty (set to null in the GitHub event).

Steps to reproduce:

  1. Configure probot-commands:
const probotCommands = require('probot-commands');
const handler = require('path/to/handler');

module.exports = (app) => {
    // Listen to slash commands
    // ['issue_comment.created', 'issues.opened', 'pull_request.opened']
    probotCommands(app, 'mycommand', handler);
};
  1. Go to GitHub (on a repo where the app is installed) and open a new pull request.
  2. Leave the PR description empty.
  3. Submit the PR
  4. Probot crashes with a 500 error:
INFO (http): POST / 500 - 3745ms
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at ServerResponse.onResFinished (/myapp/node_modules/pino-http/logger.js:77:38)
              at ServerResponse.emit (node:events:525:35)
              at ServerResponse.emit (node:domain:489:12)
              at onFinish (node:_http_outgoing:950:10)
              at callback (node:internal/streams/writable:555:21)
              at afterWrite (node:internal/streams/writable:500:5)
              at afterWriteTick (node:internal/streams/writable:487:10)
              at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
    }
ERROR (server): Internal Server Error
    Error: Internal Server Error
        at Request.callback (/myapp/node_modules/superagent/lib/node/index.js:921:17)
        at IncomingMessage.<anonymous> (/myapp/node_modules/superagent/lib/node/index.js:1165:20)
        at IncomingMessage.emit (node:events:525:35)
        at IncomingMessage.emit (node:domain:489:12)
        at endReadableNT (node:internal/streams/readable:1359:12)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
status: 500

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.