示例#1
0
文件: standup.go 项目: plotly/slick
func (standup *Standup) ChatHandler(conv *slick.Conversation, msg *slick.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, "/quote "+smap.filterByEmail(msg.FromUser.Profile.Email).String())
			} else {
				conv.Reply(msg, "/quote "+smap.String())
			}
		}
	}
}
示例#2
0
文件: bugger.go 项目: Skarlso/slick
func (bugger *Bugger) ChatHandler(listen *slick.Listener, msg *slick.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.Config.Nickname

		msg.Reply(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, listen, 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, listen, func() string {
			reporter := bugger.makeBugReporter(days)
			return reporter.printCount(days)
		})

	}

	return

}