• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang slick.Conversation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/abourget/slick.Conversation的典型用法代码示例。如果您正苦于以下问题:Golang Conversation类的具体用法?Golang Conversation怎么用?Golang Conversation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Conversation类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ChatHandler

func (bugger *Bugger) ChatHandler(conv *slick.Conversation, 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

		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:plotly,项目名称:slick,代码行数:45,代码来源:bugger.go


示例2: ChatHandler

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())
			}
		}
	}
}
开发者ID:plotly,项目名称:slick,代码行数:26,代码来源:standup.go


示例3: messageReport

func (bugger *Bugger) messageReport(days int, msg *slick.Message, conv *slick.Conversation, genReport func() string) {

	if days > 31 {
		conv.Reply(msg, fmt.Sprintf("Whaoz, %d is too much data to compile - well maybe not, I am just scared", days))
		return
	}

	conv.Reply(msg, bugger.bot.WithMood("Building report - one moment please",
		"Whaooo! Pinging those githubbers - Let's do this!"))

	conv.Reply(msg, genReport())

}
开发者ID:plotly,项目名称:slick,代码行数:13,代码来源:bugger.go


示例4: ChatHandler

func (wicked *Wicked) ChatHandler(conv *slick.Conversation, msg *slick.Message) {
	bot := conv.Bot
	uuidNow := time.Now()

	if strings.HasPrefix(msg.Text, "!wicked ") {
		fromRoom := ""
		if msg.FromChannel != nil {
			fromRoom = msg.FromChannel.Id
		}

		availableRoom := wicked.FindAvailableRoom(fromRoom)

		if availableRoom == nil {
			conv.Reply(msg, "No available Wicked Confroom for a meeting! Seems you'll need to create new Wicked Confrooms !")
			goto continueLogging
		}

		id := wicked.NextMeetingID()
		meeting := NewMeeting(id, msg.FromUser, msg.Text[7:], bot, availableRoom, uuidNow)

		wicked.pastMeetings = append(wicked.pastMeetings, meeting)
		wicked.meetings[availableRoom.Id] = meeting

		if availableRoom.Id == fromRoom {
			meeting.sendToRoom(fmt.Sprintf(`*** Starting wicked meeting W%s in here.`, meeting.ID))
		} else {
			conv.Reply(msg, fmt.Sprintf(`*** Starting wicked meeting W%s in room "%s". Join with !join W%s`, meeting.ID, availableRoom.Name, meeting.ID))
			initiatedFrom := ""
			if fromRoom != "" {
				initiatedFrom = fmt.Sprintf(` in "%s"`, msg.FromChannel.Name)
			}
			meeting.sendToRoom(fmt.Sprintf(`*** Wicked meeting initiated by @%s%s. Goal: %s`, msg.FromUser.Name, initiatedFrom, meeting.Goal))
		}

		meeting.sendToRoom(fmt.Sprintf(`*** Access report at %s/wicked/%s.html`, wicked.bot.Config.WebBaseURL, meeting.ID))
		meeting.setTopic(fmt.Sprintf(`[Running] W%s goal: %s`, meeting.ID, meeting.Goal))
	} else if strings.HasPrefix(msg.Text, "!join") {
		match := joinMatcher.FindStringSubmatch(msg.Text)
		if match == nil {
			conv.ReplyMention(msg, `invalid !join syntax. Use something like "!join W123"`)
		} else {
			for _, meeting := range wicked.meetings {
				if match[1] == meeting.ID {
					meeting.sendToRoom(fmt.Sprintf(`*** @%s asked to join`, msg.FromUser.Name))
				}
			}
		}
	}

continueLogging:

	//
	// Public commands and messages
	//
	if msg.FromChannel == nil {
		return
	}
	room := msg.FromChannel.Id
	meeting, meetingExists := wicked.meetings[room]
	if !meetingExists {
		return
	}

	user := meeting.ImportUser(msg.FromUser)

	if strings.HasPrefix(msg.Text, "!proposition ") {
		decision := meeting.AddDecision(user, msg.Text[12:], uuidNow)
		if decision == nil {
			conv.Reply(msg, "Whoops, wrong syntax for !proposition")
		} else {
			conv.Reply(msg, fmt.Sprintf("Proposition added, ref: D%s", decision.ID))
		}

	} else if strings.HasPrefix(msg.Text, "!ref ") {

		meeting.AddReference(user, msg.Text[4:], uuidNow)
		conv.Reply(msg, "Ref. added")

	} else if strings.HasPrefix(msg.Text, "!conclude") {
		meeting.Conclude()
		// TODO: kill all waiting goroutines dealing with messaging
		delete(wicked.meetings, room)
		meeting.sendToRoom("Concluding Wicked meeting, that's all folks!")
		meeting.setTopic(fmt.Sprintf(`[Concluded] W%s goal: %s`, meeting.ID, meeting.Goal))

	} else if match := decisionMatcher.FindStringSubmatch(msg.Text); match != nil {

		decision := meeting.GetDecisionByID(match[1])
		if decision != nil {
			decision.RecordPlusplus(user)
			conv.ReplyMention(msg, "noted")
		}

	}

	// Log message
	newMessage := &Message{
		From:      user,
		Timestamp: uuidNow,
		Text:      msg.Text,
//.........这里部分代码省略.........
开发者ID:plotly,项目名称:slick,代码行数:101,代码来源:wicked.go


示例5: ChatHandler

// Handler
func (healthy *Healthy) ChatHandler(conv *slick.Conversation, msg *slick.Message) {
	log.Println("Health check. Requested by", msg.FromUser.Name)
	conv.Reply(msg, healthy.CheckAll())
}
开发者ID:plotly,项目名称:slick,代码行数:5,代码来源:healthy.go


示例6: ChatHandler

func (dep *Deployer) ChatHandler(conv *slick.Conversation, msg *slick.Message) {
	bot := conv.Bot

	// Discard non "mention_name, " prefixed messages
	if !strings.HasPrefix(msg.Text, fmt.Sprintf("%s, ", bot.Config.Nickname)) {
		return
	}

	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 man..")
		} 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, "purple", "text", fmt.Sprintf("%s has unlocked deployment", msg.FromUser.Name), true)
	} 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, "purple", "text", fmt.Sprintf("%s has locked deployment", dep.lockedBy), true)
	} else if msg.Contains("deploy") || msg.Contains("push to") {
		mention := dep.bot.Config.Nickname
		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`, mention, mention, mention, mention, mention, mention))
	}
}
开发者ID:plotly,项目名称:slick,代码行数:72,代码来源:deployer.go


示例7: ChatHandler

func (plotberry *PlotBerry) ChatHandler(conv *slick.Conversation, msg *slick.Message) {
	if msg.MentionsMe && msg.Contains("how many user") {
		conv.Reply(msg, fmt.Sprintf("We got %d users!", plotberry.totalUsers))
	}
	return
}
开发者ID:plotly,项目名称:slick,代码行数:6,代码来源:plotberry.go


示例8: ChatHandler

func (totw *Totw) ChatHandler(conv *slick.Conversation, msg *slick.Message) {
	if strings.HasPrefix(msg.Text, "!totw") || strings.HasPrefix(msg.Text, "!techoftheweek") {
		conv.ReplyMention(msg, slick.RandomString("tech adept"))
	}
}
开发者ID:plotly,项目名称:slick,代码行数:5,代码来源:totw.go



注:本文中的github.com/abourget/slick.Conversation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang slick.Message类代码示例发布时间:2022-05-24
下一篇:
Golang slick.Bot类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap