当前位置: 首页>>代码示例>>Golang>>正文


Golang Bot.FindUser方法代码示例

本文整理汇总了Golang中github.com/wcharczuk/jarvis/jarvis/core.Bot.FindUser方法的典型用法代码示例。如果您正苦于以下问题:Golang Bot.FindUser方法的具体用法?Golang Bot.FindUser怎么用?Golang Bot.FindUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/wcharczuk/jarvis/jarvis/core.Bot的用法示例。


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

示例1: handlePassiveCatchAll

func (c *Core) handlePassiveCatchAll(b core.Bot, m *slack.Message) error {
	message := util.TrimWhitespace(core.LessMentions(m.Text))
	if optionValue, hasOption := b.Configuration()[ConfigOptionPassiveCatchAll]; hasOption && optionValue == "true" {
		if core.IsAngry(message) {
			user := b.FindUser(m.User)
			response := []string{"slow down %s", "maybe calm down %s", "%s you should really relax", "chill %s", "it's ok %s, let it out"}
			return b.Sayf(m.Channel, core.Random(response), strings.ToLower(user.Profile.FirstName))
		}
	}

	return nil
}
开发者ID:wcharczuk,项目名称:jarvis,代码行数:12,代码来源:core.go

示例2: handleUserID

func (u Util) handleUserID(b core.Bot, m *slack.Message) error {
	messageText := core.LessSpecificMention(m.Text, b.ID())
	mentionedUserIDs := core.Mentions(messageText)

	outputText := "I looked up the following users:\n"
	for _, userID := range mentionedUserIDs {
		user := b.FindUser(userID)
		outputText = outputText + fmt.Sprintf("> %s : %s %s", userID, user.Profile.FirstName, user.Profile.LastName)
	}

	return b.Say(m.Channel, outputText)
}
开发者ID:wcharczuk,项目名称:jarvis,代码行数:12,代码来源:util.go

示例3: handleJira

func (j *Jira) handleJira(b core.Bot, m *slack.Message) error {
	text := core.LessMentions(m.Text)

	issueIds := j.extractJiraIssues(text)
	if len(issueIds) == 0 {
		return nil
	}

	issues, err := j.fetchJiraIssues(b, issueIds)
	if err != nil {
		return err
	}
	if len(issues) == 0 {
		return nil
	}

	user := b.FindUser(m.User)

	leadText := fmt.Sprintf("*%s* has mentioned the following jira issues (%d): ", user.Profile.FirstName, len(issues))
	message := slack.NewChatMessage(m.Channel, leadText)
	message.AsUser = slack.OptionalBool(true)
	message.UnfurlLinks = slack.OptionalBool(false)
	for _, issue := range issues {
		if !util.IsEmpty(issue.Key) {
			var itemText string
			if issue.Fields != nil {
				assignee := "Unassigned"
				if issue.Fields.Assignee != nil {
					assignee = issue.Fields.Assignee.DisplayName
				}
				itemText = fmt.Sprintf("%s %s\nAssigned To: %s",
					fmt.Sprintf("https://%s/browse/%s", b.Configuration()[ConfigJiraHost], issue.Key),
					issue.Fields.Summary,
					assignee,
				)
			} else {
				itemText = fmt.Sprintf("%s\n%s", issue.Key, fmt.Sprintf("https://%s/browse/%s", b.Configuration()[ConfigJiraHost], issue.Key))
			}

			item := slack.ChatMessageAttachment{
				Color: slack.OptionalString("#3572b0"),
				Text:  slack.OptionalString(itemText),
			}
			message.Attachments = append(message.Attachments, item)
		}
	}

	_, err = b.Client().ChatPostMessage(message)
	if err != nil {
		fmt.Printf("issue posting message: %v\n", err)
	}
	return err
}
开发者ID:wcharczuk,项目名称:jarvis,代码行数:53,代码来源:jira.go

示例4: handleSalutation

func (c *Core) handleSalutation(b core.Bot, m *slack.Message) error {
	user := b.FindUser(m.User)
	salutation := []string{"hey %s", "hi %s", "hello %s", "ohayo gozaimasu %s", "salut %s", "bonjour %s", "yo %s", "sup %s"}
	return b.Sayf(m.Channel, core.Random(salutation), strings.ToLower(user.Profile.FirstName))
}
开发者ID:wcharczuk,项目名称:jarvis,代码行数:5,代码来源:core.go


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