當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。