Пример #1
0
func settings(c *integram.Context) error {
	btns := integram.InlineButtons{}

	btns.Append("ci", "CI")
	btns.Append("mr", "Merge requests")

	return c.NewMessage().SetText("Tune the notifications").SetInlineKeyboard(btns.Markup(1, "categories")).SetCallbackAction(settingsKeyboardPressed).Send()
}
Пример #2
0
func prInlineKeyboard(pr *api.PullRequest) integram.InlineKeyboard {
	but := integram.InlineButtons{}

	but.Append("assign", "Assign")
	but.Append("commits", "Commits")

	return but.Markup(4, "actions")
}
Пример #3
0
func issueInlineKeyboard(issue *api.Issue) integram.InlineKeyboard {
	but := integram.InlineButtons{}
	// wating for api endpoints..

	if issue.Votes > 0 {
		but.Append("vote", fmt.Sprintf("👍 %d", issue.Votes))
	} else {
		but.Append("vote", "👍")
	}

	return but.Markup(4, "actions")
}
Пример #4
0
func commitInlineKeyboard(commit *api.Commit) integram.InlineKeyboard {
	but := integram.InlineButtons{}
	// wating for api endpoints..

	if len(commit.ApprovedActorsUUID) > 0 {
		but.Append("vote", fmt.Sprintf("✅ Approved (%d)", len(commit.ApprovedActorsUUID)))
	} else {
		but.Append("vote", "✅ Approve")
	}

	return but.Markup(4, "actions")
}
Пример #5
0
func settingsKeyboardPressed(c *integram.Context) error {
	cs := chatSettings(c)

	state := c.Callback.Message.InlineKeyboardMarkup.State

	if state == "categories" {
		state = c.Callback.Data
	}

	btns := integram.InlineButtons{}

	if c.Callback.Data == "back" {
		btns.Append("ci", "CI")
		btns.Append("mr", "Merge requests")
		state = "categories"
	} else if state == "mr" {
		btns.Append("back", "← Back")
		switch c.Callback.Data {
		case "open":
			cs.MR.Open = !stateToBool(c.Callback.State)
		case "close":
			cs.MR.Close = !stateToBool(c.Callback.State)
		case "update":
			cs.MR.Update = !stateToBool(c.Callback.State)
		case "merge":
			cs.MR.Merge = !stateToBool(c.Callback.State)
		}

		c.Chat.SaveSettings(cs)

		btns.AppendWithState(boolToState(cs.MR.Open), "open", boolToMark(cs.MR.Open)+"Open")
		btns.AppendWithState(boolToState(cs.MR.Update), "update", boolToMark(cs.MR.Update)+"Update")
		btns.AppendWithState(boolToState(cs.MR.Merge), "merge", boolToMark(cs.MR.Merge)+"Merge")
		btns.AppendWithState(boolToState(cs.MR.Close), "close", boolToMark(cs.MR.Close)+"Close")

	} else if state == "ci" {
		btns.Append("back", "← Back")
		switch c.Callback.Data {
		case "success":
			cs.CI.Success = !stateToBool(c.Callback.State)
		case "fail":
			cs.CI.Fail = !stateToBool(c.Callback.State)
		case "cancel":
			cs.CI.Cancel = !stateToBool(c.Callback.State)
		}

		c.Chat.SaveSettings(cs)

		btns.AppendWithState(boolToState(cs.CI.Success), "success", boolToMark(cs.CI.Success)+"Success")
		btns.AppendWithState(boolToState(cs.CI.Fail), "fail", boolToMark(cs.CI.Fail)+"Fail")
		btns.AppendWithState(boolToState(cs.CI.Cancel), "cancel", boolToMark(cs.CI.Cancel)+"Cancel")
	}
	return c.EditPressedInlineKeyboard(btns.Markup(1, state))
}