Example #1
0
func (h *Enable) ServeCommand(ctx context.Context, r slash.Responder, command slash.Command) (resp slash.Response, err error) {
	params := slash.Params(ctx)
	owner, repo := params["owner"], params["repo"]

	var hook *github.Hook
	hook, err = h.existingHook(owner, repo)
	if err != nil {
		return
	}

	if hook != nil {
		if _, _, err = h.EditHook(owner, repo, *hook.ID, h.Hook); err != nil {
			return
		}

		resp.Text = fmt.Sprintf("Updated webhook on %s/%s", owner, repo)
	} else {
		if _, _, err = h.CreateHook(owner, repo, h.Hook); err != nil {
			return
		}

		resp.Text = fmt.Sprintf("Added webhook to %s/%s", owner, repo)
	}

	return
}
Example #2
0
func (b *Build) ServeCommand(ctx context.Context, r slash.Responder, c slash.Command) (slash.Response, error) {
	params := slash.Params(ctx)

	owner, repo, branch := params["owner"], params["repo"], params["branch"]
	go b.build(ctx, r, owner, repo, branch)

	return slash.Reply("One moment..."), nil
}
Example #3
0
func (s *Slack) Enable(ctx context.Context, r slash.Responder, command slash.Command) error {
	params := slash.Params(ctx)
	owner, repo := params["owner"], params["repo"]

	if err := s.client.EnableRepo(ctx, fmt.Sprintf("%s/%s", owner, repo)); err != nil {
		return r.Respond(slash.Reply(fmt.Sprintf("error: %v", err)))
	}

	return r.Respond(slash.Reply(fmt.Sprintf("Installed webhook on %s/%s", owner, repo)))
}
Example #4
0
func (s *Slack) Build(ctx context.Context, r slash.Responder, command slash.Command) error {
	params := slash.Params(ctx)

	owner, repo, branch := params["owner"], params["repo"], params["branch"]

	r.Respond(slash.Reply("One moment..."))

	if err := s.build(ctx, r, owner, repo, branch); err != nil {
		return r.Respond(slash.Reply(fmt.Sprintf("error: %s", err)))
	}

	return nil
}
Example #5
0
// Zipcode is a slash handler that returns the weather for a zip code.
func Zipcode(ctx context.Context, command slash.Command) (string, error) {
	params := slash.Params(ctx)
	zip := params["zip"]
	return zip, nil
}
Example #6
0
// Zipcode is a slash handler that returns the weather for a zip code.
func Zipcode(ctx context.Context, r slash.Responder, command slash.Command) (slash.Response, error) {
	params := slash.Params(ctx)
	zip := params["zip"]
	return slash.Reply(zip), nil
}
Example #7
0
// Zipcode is a slash handler that returns the weather for a zip code.
func Zipcode(ctx context.Context, r slash.Responder, command slash.Command) error {
	params := slash.Params(ctx)
	zip := params["zip"]
	return r.Respond(slash.Reply(zip))
}