automatica-team / plant

Declarative bots constructor
1 stars 0 forks source link

mods/version: implement #19

Closed demget closed 3 months ago

demget commented 3 months ago

A module that handles /version command that sends the bot version to the user.

mods:
  - import: plant/version
    repo: automatica-team/bots
func githubTags(repo string) ([]string, error) {
    resp, err := http.Get("https://api.github.com/repos/" + repo + "/tags")
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    var tags []struct {
        Name string `json:"name"`
    }
    if err := json.NewDecoder(resp.Body).Decode(&tags); err != nil {
        return nil, err
    }

    var names []string
    for _, tag := range tags {
        names = append(names, tag.Name)
    }

    return names, nil
}