Exemple #1
0
func (standup *Standup) ChatHandler(conv *plotbot.Conversation, msg *plotbot.Message) {
	res := sectionRegexp.FindAllStringSubmatchIndex(msg.Text, -1)
	if res != nil {
		for _, section := range extractSectionAndText(msg.Text, res) {
			standup.TriggerReminders(msg, section.name)
			err := standup.StoreLine(msg, section.name, section.text)
			if err != nil {
				log.Println(err)
			}
		}
	} else if msg.MentionsMe && msg.Contains("standup report") {
		daysAgo := util.GetDaysFromQuery(msg.Text)
		smap, err := standup.getRange(getStandupDate(-daysAgo), getStandupDate(TODAY))
		if err != nil {
			log.Println(err)
			conv.Reply(msg, standup.bot.WithMood("Sorry, could not retrieve your report...",
				"I am the eggman and the walrus ate your report - Fzaow!"))
		} else {
			if msg.Contains(" my ") {
				conv.Reply(msg, "```"+smap.filterByEmail(msg.FromUser.Profile.Email).String()+"```")
			} else {
				conv.Reply(msg, "```"+smap.String()+"```")
			}
		}
	}
}
Exemple #2
0
func (bugger *Bugger) aggregateBugReporter(conv *plotbot.Conversation, msg *plotbot.Message) {
	if len(bugger.ghclient.Conf.Repos) == 0 {
		log.Println("No repos configured - can't produce a bug report")
		return
	}

	if !(msg.Contains("bug report")) && !(msg.Contains("bug count")) {
		return
	}

	days := util.GetDaysFromQuery(msg.Text)
	bugger.messageReport(days, msg, conv, func() string {

		var reportsBuffer bytes.Buffer

		for _, repo := range bugger.ghclient.Conf.Repos {

			reporter := bugger.makeBugReporter(days, repo)

			if msg.Contains("bug report") {
				reportsBuffer.WriteString(reporter.printReport(days))
			}

			if msg.Contains("bug count") {
				reportsBuffer.WriteString(reporter.printCount(days))
			}

		}

		return reportsBuffer.String()

	})

}
Exemple #3
0
func (bugger *Bugger) ChatHandler(conv *plotbot.Conversation, msg *plotbot.Message) {

	if !msg.MentionsMe {
		return
	}

	if msg.ContainsAny([]string{"bug report", "bug count"}) && msg.ContainsAny([]string{"how", "help"}) {

		var report string

		if msg.Contains("bug report") {
			report = "bug report"
		} else {
			report = "bug count"
		}
		mention := bugger.bot.MentionPrefix

		conv.Reply(msg, fmt.Sprintf(
			`*Usage:* %s [give me a | insert demand]  <%s>  [from the | syntax filler] [last | past] [n] [days | weeks]
*Examples:*
• %s please give me a %s over the last 5 days
• %s produce a %s   (7 day default)
• %s I want a %s from the past 2 weeks
• %s %s from the past week`, mention, report, mention, report, mention, report, mention, report, mention, report))

	} else if msg.Contains("bug report") {

		days := util.GetDaysFromQuery(msg.Text)
		bugger.messageReport(days, msg, conv, func() string {
			reporter := bugger.makeBugReporter(days)
			return reporter.printReport(days)
		})

	} else if msg.Contains("bug count") {

		days := util.GetDaysFromQuery(msg.Text)
		bugger.messageReport(days, msg, conv, func() string {
			reporter := bugger.makeBugReporter(days)
			return reporter.printCount(days)
		})

	}

	return

}