Пример #1
0
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

}
Пример #2
0
func (funny *Funny) ChatHandler(listen *slick.Listener, msg *slick.Message) {
	bot := listen.Bot

	if msg.Contains("mama") {
		listen.Bot.Listen(&slick.Listener{
			ListenDuration: time.Duration(10 * time.Second),
			MessageHandlerFunc: func(listen *slick.Listener, msg *slick.Message) {
				if strings.Contains(msg.Text, "papa") {
					msg.Reply("3s", "yo rocker").DeleteAfter("3s")
					msg.AddReaction("wink")
					go func() {
						time.Sleep(3 * time.Second)
						msg.AddReaction("beer")
						time.Sleep(1 * time.Second)
						msg.RemoveReaction("wink")
					}()
				}
			},
		})
	}

	if msg.MentionsMe {
		if msg.Contains("you're funny") {

			if bot.Mood == slick.Happy {
				msg.Reply("/me blushes")
			} else {
				msg.Reply("here's another one")
				msg.Reply(slick.RandomString("robot jokes"))
			}

		} else if msg.ContainsAny([]string{"dumb ass", "dumbass"}) {

			msg.Reply("don't say such things")

		} else if msg.ContainsAny([]string{"thanks", "thank you", "thx", "thnks"}) {
			msg.Reply(bot.WithMood("my pleasure", "any time, just ask, I'm here for you, ffiieeewww!get a life"))

		} else if msg.Contains("how are you") && msg.MentionsMe {
			msg.ReplyMention(bot.WithMood("good, and you ?", "I'm wild today!! wadabout you ?"))
			bot.Listen(&slick.Listener{
				ListenDuration: 60 * time.Second,
				FromUser:       msg.FromUser,
				FromChannel:    msg.FromChannel,
				MentionsMeOnly: true,
				MessageHandlerFunc: func(listen *slick.Listener, msg *slick.Message) {
					msg.ReplyMention(bot.WithMood("glad to hear it!", "zwweeeeeeeeet !"))
					listen.Close()
				},
				TimeoutFunc: func(listen *slick.Listener) {
					msg.ReplyMention("well, we can catch up later")
					listen.Close()
				},
			})
		}
	}

	if msg.ContainsAny([]string{"lot of excitement", "that's exciting", "how exciting", "much excitement"}) {

		msg.Reply("http://static.fjcdn.com/gifs/Japanese+kids+spongebob+toys_0ad21b_3186721.gif")

	} else if msg.ContainsAny([]string{"what is your problem", "what's your problem", "is there a problem", "which problem"}) {

		msg.Reply("http://media4.giphy.com/media/19hU0m3TJe6I/200w.gif")

	} else if msg.Contains("force push") {

		url := slick.RandomString("forcePush")
		msg.Reply(url)

	} else if msg.ContainsAny([]string{"there is a bug", "there's a bug"}) {

		msg.Reply("https://s3.amazonaws.com/pushbullet-uploads/ujy7DF0U8wm-9YYvLZkmSM8pMYcxCXXig8LjJORE9Xzt/The-life-of-a-coder.jpg")

	} else if msg.ContainsAny([]string{"oh yeah", "approved"}) {

		msg.Reply("https://i.chzbgr.com/maxW250/4496881920/h9C58F860.gif")

	} else if msg.Contains("ice cream") {

		msg.Reply("http://i.giphy.com/IGyLuFXIGSJj2.gif")
		msg.Reply("I love ice cream too")

	} else if msg.ContainsAny([]string{"lot of tension", "some tension", " tensed"}) {

		msg.Reply("http://thumbpress.com/wp-content/uploads/2014/01/funny-gif-meeting-strangers-girl-scared1.gif")
		msg.Reply("tensed, like that ?")

	} else if msg.Contains("quick fix") {

		msg.Reply("http://blog.pgi.com/wp-content/uploads/2013/02/jim-carey.gif")
		msg.Reply("make it real quick")

	} else if msg.ContainsAny([]string{"crack an egg", "crack something", "to crack"}) {

		msg.Reply("http://s3-ec.buzzfed.com/static/enhanced/webdr02/2012/11/8/18/anigif_enhanced-buzz-31656-1352415875-9.gif")
		msg.Reply("crack an egg, yeah")

	} else if msg.ContainsAny([]string{"i'm stuck", "I'm stuck", "we're stuck"}) {

		msg.Reply("http://media.giphy.com/media/RVlWx1msxnf7W/giphy.gif")
		msg.Reply("I'm stuck too!")

	} else if msg.ContainsAny([]string{"watching tv", "watch tv"}) {

		msg.Reply("http://i0.kym-cdn.com/photos/images/newsfeed/000/495/040/9ab.gif")
		msg.Reply("like that ?")

	} else if msg.ContainsAny([]string{"spider", "pee on", "inappropriate"}) {

		msg.Reply("https://i.chzbgr.com/maxW500/5626597120/hB2E11E61.gif")

	} else if msg.ContainsAny([]string{"a meeting", "an interview"}) {

		msg.Reply("like this one")
		msg.Reply("https://i.chzbgr.com/maxW500/6696664320/hFC69678C.gif")

	} else if msg.ContainsAny([]string{"it's odd", "it is odd", "that's odd", "that is odd", "it's awkward", "it is awkward", "that's awkward", "that is awkward"}) {

		term := "awkward"
		if msg.Contains("odd") {
			term = "odd"
		}
		msg.Reply(fmt.Sprintf("THAT's %s", term))
		msg.Reply("https://i.chzbgr.com/maxW500/8296294144/h7AC1001C.gif")

	} else if msg.Text == "ls" {

		msg.Reply("/code deploy/      Contributors-Guide/ image_server/     sheep_porn/     streambed/\nstreamhead/  README.md")

	} else if msg.ContainsAny([]string{"that's really cool", "that is really cool", "really happy"}) {

		msg.Reply("http://media.giphy.com/media/BlVnrxJgTGsUw/giphy.gif")

	} else if msg.ContainsAny([]string{"difficult problem", "hard problem"}) {

		msg.Reply("naming things, cache invalidation and off-by-1 errors are the two most difficult computer science problems")

	} else if msg.Contains("in theory") {

		msg.Reply("yeah, theory and practice perfectly match... in theory.")
	} else if msg.Contains("dishes") {

		msg.Reply(slick.RandomString("dishes"))

	} else if msg.Contains(" bean") {

		msg.Reply("http://media3.giphy.com/media/c35RMDO6luMaQ/500w.gif")

	} else if msg.Contains("steak") {

		msg.Reply("http://media.tumblr.com/tumblr_me6r52h1md1r6nno1.gif")

	} else if msg.ContainsAny([]string{"booze", "alcohol", "martini", " dog "}) {

		msg.Reply("http://media2.giphy.com/media/ZmJBjPdd44gXS/200w.gif")

	} else if msg.ContainsAny([]string{"internet", " tube "}) {

		msg.Reply("https://pbs.twimg.com/media/By0J3YHCcAA4UBo.jpg:large")

	}
}