本文整理汇总了Golang中github.com/abourget/slick.Conversation.ReplyMention方法的典型用法代码示例。如果您正苦于以下问题:Golang Conversation.ReplyMention方法的具体用法?Golang Conversation.ReplyMention怎么用?Golang Conversation.ReplyMention使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/abourget/slick.Conversation
的用法示例。
在下文中一共展示了Conversation.ReplyMention方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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,
//.........这里部分代码省略.........
示例2: 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"))
}
}