示例#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
}
示例#2
0
文件: build.go 项目: emmetog/conveyor
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
}
示例#3
0
文件: slack.go 项目: atmos/conveyor
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)))
}
示例#4
0
文件: slack.go 项目: atmos/conveyor
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
}
示例#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
}
示例#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
}
示例#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))
}