本文整理汇总了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)
// }
// }
}
示例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)
}
}
}
示例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)
}
}
}
示例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)
}
}