Skip to content

Can we use"*"to represent all events? #32

@HsiangNianian

Description

@HsiangNianian

Hi, @bloomberg-oss

Is your feature request related to a problem? Please describe.
In the process of using, I found that many agents need to write corresponding functions separately, especially @webhook.hook() every time. Can I express all events in some way and get the types of events?

Describe the solution you'd like
I hope to use the * parameter to represent all events and give an event_type label.

@webhook.hook("*") #when any event  happened, e. g.  `push`
def event(data, event_type): 
    return event_type # event_type = "push"

I wrote a json configuration file with the following fields:

{
  "star": {
    "created": "{sender.login} starred repo. "
    }
}

the template is:

{
  "event_type": {
      "data.action": "..."
      }
}

if I read the json as config:

@webhook.hook("*")
def event(data, event_type): 
    logging.info(f"{config[event_type]} happened: Action is {config[data['action']]}")
    return "hello"

This could be activate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions