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


Golang Bot.BotUserID方法代码示例

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


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

示例1: LeadHandler

func LeadHandler(ctx context.Context, bot *slackbot.Bot, sfo *services.SalesforceLead) {
	// log := logger.WithField("method", "LeadHandler")
	//
	// sf := salesforce.Salesforce{}
	// cfg := config.GetConfigFromContext(globalContext)
	// log.Infof("config %v", cfg)
	// oauth := salesforce.GetOauthFromContext(globalContext)
	// log.Infof("oauth %v", oauth)
	// leadResponse, err := sf.GetLead(globalContext, sfo.Id)
	// if err != nil {
	// 	logger.WithError(err).Error("Unable to get lead")
	// } else {
	// 	fmt.Printf("\n\nlead from SF:\n%#v\n", leadResponse)
	// }

	logger.Infof("LeadHandler for %s", sfo.Company)
	// channels, err := bot.Client.GetChannels(true)
	// if err != nil {
	// 	logger.Errorf("Couldn't get Channels from LeadHandler, err - %s", err)
	// 	return
	// }
	//
	// for _, channel := range channels {
	// 	if channel.IsMember {
	// 		evt := &slack.MessageEvent{}
	// 		evt.Channel = channel.ID
	// txt := fmt.Sprintf("Salesforce Opportunity just went into: %s", sfo.StageName)
	fields := []slack.AttachmentField{
		{Title: "Email", Value: sfo.Email, Short: true},
		{Title: "Phone", Value: sfo.Phone, Short: true},
	}

	ownedByTxt := ""
	if sfo.OwnerName != "" {
		ownedByTxt = fmt.Sprintf(", owned by: %s", sfo.OwnerName)
	}
	pretxt := fmt.Sprintf("Lead was %s%s", sfo.Op, ownedByTxt)
	if sfo.Op == "Created" {
		pretxt = ""
		channel_txt := "@channel Shotgun! :gun: A new lead is available!\nType \"<@" + bot.BotUserID() + "> mine\" to claim."
		bot.Reply(bot.Get(SalesKey), channel_txt, WithoutTyping)
		lastNewLead = sfo
	}
	attachment := slack.Attachment{
		Pretext:   pretxt,
		Title:     fmt.Sprintf("%s %s - %s", sfo.FirstName, sfo.LastName, sfo.Company),
		TitleLink: fmt.Sprintf("https://cs14.salesforce.com/%s", sfo.Id),
		// Text:      txt,
		// Fallback:  txt,
		Fields: fields,
		Color:  "#663399",
	}

	// supports multiple attachments
	attachments := []slack.Attachment{attachment}
	bot.ReplyWithAttachments(bot.Get(SalesKey), attachments, WithoutTyping)
	// 	}
	// }
}
开发者ID:RobotsAndPencils,项目名称:slack-salesforce-bot,代码行数:59,代码来源:main.go

示例2: ClaimHandler

func ClaimHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.MessageEvent) {
	if slackbot.IsMentioned(evt, bot.BotUserID()) {
		if strings.Contains(evt.Text, "mine") {
			if lastNewLead != nil {
				err := AssignNewLeadOwner(ctx, evt.User)
				if err != nil {
					bot.Reply(evt.Channel, err.Error(), WithoutTyping)
				} else {
					bot.Reply(evt.Channel, fmt.Sprintf("@%s staked their claim! :pick:", evt.User), WithoutTyping)
					bot.Reply(evt.Channel, fmt.Sprintf("*%s* is now in your hands, make the most it!\nRemember what our buddy Zig says:\n> _\"You were born to win, but to be a winner, you must plan to win, prepare to win, and expect to win.\"_", lastNewLead.FirstName), WithTyping)
				}
			} else {
				bot.Reply(evt.Channel, "I'm sorry, I don't know of any new leads you can claim. :disappointed:", WithTyping)
			}
		} else {
			bot.Reply(evt.Channel, "You really do care about me. :heart:", WithTyping)
		}
	}
}
开发者ID:RobotsAndPencils,项目名称:slack-salesforce-bot,代码行数:19,代码来源:main.go

示例3: JoinChannelHandler

func JoinChannelHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.RTMEvent) {
	joinedEvent := evt.Data.(*slack.ChannelJoinedEvent)
	log := logger.WithField("method", "JoinChannelHandler")
	log.Infof("Event: %#v", joinedEvent)
	sales := bot.Get(SalesKey)
	finance := bot.Get(FinanceKey)
	ops := bot.Get(OpsKey)
	bot.Reply(joinedEvent.Channel.ID, "Hello", WithTyping)
	bot.Reply(joinedEvent.Channel.ID, "I'm your friendly neighborhood Salesforce bot!", WithTyping)

	if sales == "" || finance == "" || ops == "" {

		bot.Reply(joinedEvent.Channel.ID, "Please take a moment and setup your notification channel preferences", WithTyping)
		if sales == "" {
			bot.Reply(joinedEvent.Channel.ID, "say \"<@"+bot.BotUserID()+"> set sales #channel\"", WithTyping)
		} else {
			bot.Reply(joinedEvent.Channel.ID, "sales team messages go to <#"+sales+">", WithTyping)
		}

		if finance == "" {
			bot.Reply(joinedEvent.Channel.ID, "say \"<@"+bot.BotUserID()+"> set finance #channel\"", WithTyping)
		} else {
			bot.Reply(joinedEvent.Channel.ID, "finance team messages go to <#"+finance+">", WithTyping)
		}

		if ops == "" {
			bot.Reply(joinedEvent.Channel.ID, "say \"<@"+bot.BotUserID()+"> set ops #channel\"", WithTyping)
		} else {
			bot.Reply(joinedEvent.Channel.ID, "ops team messages go to <#"+ops+">", WithTyping)
		}
	}
}
开发者ID:RobotsAndPencils,项目名称:slack-salesforce-bot,代码行数:32,代码来源:main.go

示例4: MentionHandler

func MentionHandler(ctx context.Context, bot *slackbot.Bot, evt *slack.MessageEvent) {
	if slackbot.IsMentioned(evt, bot.BotUserID()) {
		bot.Reply(evt, "You really do care about me. :heart:", WithTyping)
	}
}
开发者ID:chris-skud,项目名称:starter-go-bot,代码行数:5,代码来源:main.go


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