本文整理汇总了Golang中github.com/iopred/bruxism.Message.Message方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Message方法的具体用法?Golang Message.Message怎么用?Golang Message.Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/iopred/bruxism.Message
的用法示例。
在下文中一共展示了Message.Message方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: makeScriptFromMessages
func makeScriptFromMessages(service bruxism.Service, message bruxism.Message, messages []bruxism.Message) *comicgen.Script {
speakers := make(map[string]int)
avatars := make(map[int]string)
script := []*comicgen.Message{}
for _, message := range messages {
speaker, ok := speakers[message.UserName()]
if !ok {
speaker = len(speakers)
speakers[message.UserName()] = speaker
avatars[speaker] = message.UserAvatar()
}
script = append(script, &comicgen.Message{
Speaker: speaker,
Text: message.Message(),
Author: message.UserName(),
})
}
return &comicgen.Script{
Messages: script,
Author: fmt.Sprintf(service.UserName()),
Avatars: avatars,
Type: comicgen.ComicTypeChat,
}
}
示例2: Message
func (t *triviaChannel) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
if strings.ToLower(message.Message()) == t.Answer {
t.Lock()
defer t.Unlock()
if !t.Active {
return
}
ts := t.Scores[message.UserID()]
if ts == nil {
ts = &triviaScore{}
t.Scores[message.UserID()] = ts
}
ts.Name = message.UserName()
ts.Score++
service.SendMessage(message.Channel(), fmt.Sprintf("%s got it! The answer was %s.", message.UserName(), t.Answer))
service.SendMessage(message.Channel(), fmt.Sprintf("%s answered in %d seconds and their score is now %d.", message.UserName(), int(time.Now().Sub(t.Asked).Seconds()), ts.Score))
t.Unanswered = 0
if t.hintChan != nil {
close(t.hintChan)
t.hintChan = nil
}
}
}