本文整理汇总了Golang中github.com/plotly/plotbot.Message类的典型用法代码示例。如果您正苦于以下问题:Golang Message类的具体用法?Golang Message怎么用?Golang Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ChatHandler
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()+"```")
}
}
}
}
开发者ID:pkdevboxy,项目名称:plotbot,代码行数:26,代码来源:standup.go
示例2: aggregateBugReporter
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()
})
}
开发者ID:pkdevboxy,项目名称:plotbot,代码行数:34,代码来源:bugger.go
示例3: ChatHandler
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
}
开发者ID:cemoulto,项目名称:plotbot,代码行数:46,代码来源:bugger.go
示例4: ChatHandler
func (dep *Deployer) ChatHandler(conv *plotbot.Conversation, msg *plotbot.Message) {
bot := conv.Bot
if match := deployFormat.FindStringSubmatch(msg.Text); match != nil {
if dep.lockedBy != "" {
conv.Reply(msg, fmt.Sprintf("Deployment was locked by %s. Unlock with '%s, unlock deployment' if they're OK with it.", dep.lockedBy, dep.bot.Config.Nickname))
return
}
if dep.runningJob != nil {
params := dep.runningJob.params
conv.Reply(msg, fmt.Sprintf("@%s Deploy currently running: %s", msg.FromUser.Name, params))
return
} else {
params := &DeployParams{
Environment: match[3],
Branch: match[2],
Tags: match[8],
DeploymentBranch: match[5],
InitiatedBy: msg.FromUser.RealName,
From: "chat",
initiatedByChat: msg,
}
go dep.handleDeploy(params)
}
return
} else if msg.Contains("cancel deploy") {
if dep.runningJob == nil {
conv.Reply(msg, "No deploy running, sorry friend..")
} else {
if dep.runningJob.killing == true {
conv.Reply(msg, "deploy: Interrupt signal already sent, waiting to die")
return
} else {
conv.Reply(msg, "deploy: Sending Interrupt signal...")
dep.runningJob.killing = true
dep.runningJob.kill <- true
}
}
return
} else if msg.Contains("in the pipe") {
url := dep.getCompareUrl("prod", dep.config.DefaultStreambedBranch)
mention := msg.FromUser.Name
if url != "" {
conv.Reply(msg, fmt.Sprintf("@%s in %s branch, waiting to reach prod: %s", mention, dep.config.DefaultStreambedBranch, url))
} else {
conv.Reply(msg, fmt.Sprintf("@%s couldn't get current revision on prod", mention))
}
} else if msg.Contains("unlock deploy") {
dep.lockedBy = ""
conv.Reply(msg, fmt.Sprintf("Deployment is now unlocked."))
bot.Notify(dep.config.AnnounceRoom, "#00ff00", fmt.Sprintf("%s has unlocked deployment", msg.FromUser.Name))
} else if msg.Contains("lock deploy") {
dep.lockedBy = msg.FromUser.Name
conv.Reply(msg, fmt.Sprintf("Deployment is now locked. Unlock with '%s, unlock deployment' ASAP!", dep.bot.Config.Nickname))
bot.Notify(dep.config.AnnounceRoom, "#ff0000", fmt.Sprintf("%s has locked deployment", dep.lockedBy))
} else if msg.Contains("deploy") || msg.Contains("push to") {
mention := dep.bot.MentionPrefix
conv.Reply(msg, fmt.Sprintf(`*Usage:* %s, [please|insert reverence] deploy [<branch-name>] to <environment> [using <deployment-branch>][, tags: <ansible-playbook tags>, ..., ...]
*Examples:*
• %s please deploy to prod
• %s deploy thing-to-test to stage
• %s deploy complicated-thing to stage, tags: updt_streambed, blow_up_the_sun
*Other commands:*
• %s, what's in the pipe? - show what's waiting to be deployed to prod
• %s lock deployment - prevent deployment until it's unlocked
• %s cancel deploy - cancel the currently running deployment`, mention, mention, mention, mention, mention, mention, mention))
}
}
开发者ID:cemoulto,项目名称:plotbot,代码行数:70,代码来源:deployer.go
示例5: voteHandler
func (v *Vote) voteHandler(conv *plotbot.Conversation, msg *plotbot.Message) {
v.mutex.Lock()
defer v.mutex.Unlock()
bot := v.bot
// TODO: ok, @kat wants to survey what's for lunch, use "!vote The Food Place http://food-place.url" .. you can vote for the same place with a substring: "!vote food place"
// TODO: match "!vote Mucha Dogs http://bigdogs.com"
// TODO: match "!vote mucha dogs"
// TODO: match "!vote Other place
if msg.Text == "!what-for-lunch" || msg.Text == "!vote-for-lunch" {
bot.ReplyMention(msg, "you can say `!what-for-lunch 5m` to get a vote that will last 5 minutes. `!vote-for-lunch` is an alias")
return
}
if msg.HasPrefix("!what-for-lunch ") || msg.HasPrefix("!vote-for-lunch ") {
if v.runningVotes[msg.FromChannel.Id] != nil {
bot.ReplyMention(msg, "vote is already running!")
return
}
timing := strings.TrimSpace(strings.SplitN(msg.Text, " ", 2)[1])
dur, err := time.ParseDuration(timing)
if err != nil {
bot.ReplyMention(msg, fmt.Sprintf("couldn't parse duration: %s", err))
return
}
v.runningVotes[msg.FromChannel.Id] = make([]vote, 0)
go func() {
time.Sleep(dur)
v.mutex.Lock()
defer v.mutex.Unlock()
res := make(map[string]int)
for _, oneVote := range v.runningVotes[msg.FromChannel.Id] {
res[oneVote.vote] = res[oneVote.vote] + 1
}
// TODO: print report, clear up
if len(res) == 0 {
bot.ReplyMention(msg, "polls closed, but no one voted")
} else {
out := []string{"polls closed, here are the results:"}
for theVote, count := range res {
plural := ""
if count > 1 {
plural = "s"
}
out = append(out, fmt.Sprintf("* %s: %d vote%s", theVote, count, plural))
}
bot.ReplyMention(msg, strings.Join(out, "\n"))
}
delete(v.runningVotes, msg.FromChannel.Id)
}()
bot.Reply(msg, "<!channel> okay, what do we eat ? Votes are open. Use `!vote The Food Place http://food-place.url` .. you can vote for the same place with a substring, ex: `!vote food place`")
}
if msg.HasPrefix("!vote ") {
running := v.runningVotes[msg.FromChannel.Id]
if running == nil {
bot.Reply(msg, bot.WithMood("what vote ?!", "oh you're so cute! voting while there's no vote going on !"))
return
}
voteCast := strings.TrimSpace(strings.SplitN(msg.Text, " ", 2)[1])
if len(voteCast) == 0 {
return
}
// TODO: check for dupe
for _, prevVote := range running {
if msg.FromUser.Id == prevVote.user {
// buzz off if you voted already
bot.ReplyMention(msg, bot.WithMood("you voted already", "trying to double vote ! how charming :)"))
return
}
}
for _, prevVote := range running {
if strings.Contains(strings.ToLower(prevVote.vote), strings.ToLower(voteCast)) {
running = append(running, vote{msg.FromUser.Id, prevVote.vote})
v.runningVotes[msg.FromChannel.Id] = running
bot.ReplyMention(msg, bot.WithMood("okay", "hmmm kaay"))
return
}
}
running = append(running, vote{msg.FromUser.Id, voteCast})
v.runningVotes[msg.FromChannel.Id] = running
bot.ReplyMention(msg, bot.WithMood("taking note", "taking note! what a creative mind..."))
// TODO: match "!what-for-lunch 1h|5m|50s"
}
}
开发者ID:pkdevboxy,项目名称:plotbot,代码行数:100,代码来源:vote.go
示例6: ChatHandler
func (plotberry *PlotBerry) ChatHandler(conv *plotbot.Conversation, msg *plotbot.Message) {
if msg.MentionsMe && msg.Contains("how many user") {
conv.Reply(msg, fmt.Sprintf("We got %d users!", plotberry.totalUsers))
}
return
}
开发者ID:pkdevboxy,项目名称:plotbot,代码行数:6,代码来源:plotberry.go
示例7: ChatHandler
func (funny *Funny) ChatHandler(conv *plotbot.Conversation, msg *plotbot.Message) {
bot := conv.Bot
if msg.MentionsMe {
if msg.Contains("you're funny") {
if bot.Mood == plotbot.Happy {
conv.Reply(msg, "_blush_")
} else {
conv.Reply(msg, "here's another one")
conv.Reply(msg, plotbot.RandomString("robot jokes"))
}
} else if msg.ContainsAny([]string{"dumb ass", "dumbass"}) {
conv.Reply(msg, "don't say such things")
} else if msg.ContainsAny([]string{"thanks", "thank you", "thx", "thnks"}) {
conv.Reply(msg, 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 {
conv.ReplyMention(msg, bot.WithMood("good, and you ?", "I'm wild today!! wadabout you ?"))
bot.ListenFor(&plotbot.Conversation{
ListenDuration: 60 * time.Second,
WithUser: msg.FromUser,
InChannel: msg.FromChannel,
MentionsMeOnly: true,
HandlerFunc: func(conv *plotbot.Conversation, msg *plotbot.Message) {
conv.ReplyMention(msg, bot.WithMood("glad to hear it!", "zwweeeeeeeeet !"))
conv.Close()
},
TimeoutFunc: func(conv *plotbot.Conversation) {
conv.ReplyMention(msg, "well, we can catch up later")
},
})
}
}
if msg.ContainsAny([]string{"lot of excitement", "that's exciting", "how exciting", "much excitement"}) {
conv.Reply(msg, "http://static.fjcdn.com/gifs/Japanese+kids+spongebob+toys_0ad21b_3186721.gif")
return
} else if msg.ContainsAny([]string{"what is your problem", "what's your problem", "is there a problem", "which problem"}) {
conv.Reply(msg, "http://media4.giphy.com/media/19hU0m3TJe6I/200w.gif")
return
} else if msg.Contains("force push") {
url := plotbot.RandomString("forcePush")
conv.Reply(msg, url)
return
} else if msg.ContainsAny([]string{"there is a bug", "there's a bug"}) {
conv.Reply(msg, "https://s3.amazonaws.com/pushbullet-uploads/ujy7DF0U8wm-9YYvLZkmSM8pMYcxCXXig8LjJORE9Xzt/The-life-of-a-coder.jpg")
return
} else if msg.ContainsAny([]string{"oh yeah", "approved"}) {
conv.Reply(msg, "https://i.chzbgr.com/maxW250/4496881920/h9C58F860.gif")
return
} else if msg.Contains("ice cream") {
conv.Reply(msg, "http://i.giphy.com/IGyLuFXIGSJj2.gif")
conv.Reply(msg, "I love ice cream too")
return
} else if msg.ContainsAny([]string{"lot of tension", "some tension", " tensed"}) {
conv.Reply(msg, "http://thumbpress.com/wp-content/uploads/2014/01/funny-gif-meeting-strangers-girl-scared1.gif")
conv.Reply(msg, "tensed, like that ?")
return
} else if msg.Contains("quick fix") {
conv.Reply(msg, "http://blog.pgi.com/wp-content/uploads/2013/02/jim-carey.gif")
conv.Reply(msg, "make it real quick")
return
} else if msg.ContainsAny([]string{"crack an egg", "crack something", "to crack"}) {
conv.Reply(msg, "http://s3-ec.buzzfed.com/static/enhanced/webdr02/2012/11/8/18/anigif_enhanced-buzz-31656-1352415875-9.gif")
conv.Reply(msg, "crack an egg, yeah")
return
} else if msg.ContainsAny([]string{"i'm stuck", "I'm stuck", "we're stuck"}) {
conv.Reply(msg, "http://media.giphy.com/media/RVlWx1msxnf7W/giphy.gif")
conv.Reply(msg, "I'm stuck too!")
return
} else if msg.ContainsAny([]string{"watching tv", "watch tv"}) {
conv.Reply(msg, "http://i0.kym-cdn.com/photos/images/newsfeed/000/495/040/9ab.gif")
conv.Reply(msg, "like that ?")
return
} else if msg.ContainsAny([]string{"spider", "pee on", "inappropriate"}) {
//.........这里部分代码省略.........
开发者ID:cemoulto,项目名称:plotbot,代码行数:101,代码来源:funny.go
注:本文中的github.com/plotly/plotbot.Message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论