本文整理汇总了Golang中github.com/iopred/bruxism.Service.IsPrivate方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.IsPrivate方法的具体用法?Golang Service.IsPrivate怎么用?Golang Service.IsPrivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/iopred/bruxism.Service
的用法示例。
在下文中一共展示了Service.IsPrivate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Help
// Help returns a list of help strings that are printed when the user requests them.
func (p *triviaPlugin) Help(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message, detailed bool) []string {
if service.IsPrivate(message) || !(service.IsModerator(message) || service.IsBotOwner(message)) {
return nil
}
return []string{
bruxism.CommandHelp(service, "trivia", "<start|stop> [theme]", "Starts or stops trivia with an optional theme.")[0],
bruxism.CommandHelp(service, "trivia", "<score>", "Returns your current trivia score.")[0],
}
}
示例2: Message
func (p *ReminderPlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
if !service.IsMe(message) {
if bruxism.MatchesCommand(service, "remind", message) || bruxism.MatchesCommand(service, "reminder", message) {
_, parts := bruxism.ParseCommand(service, message)
if len(parts) < 2 {
service.SendMessage(message.Channel(), fmt.Sprintf("Invalid reminder, no time or message. eg: %s", p.randomReminder(service)))
return
}
t, r, err := p.parseReminder(parts)
now := time.Now()
if err != nil || t.Before(now) || t.After(now.Add(time.Hour*24*365+time.Hour)) {
service.SendMessage(message.Channel(), fmt.Sprintf("Invalid time. eg: %s", strings.Join(randomTimes, ", ")))
return
}
if r == "" {
service.SendMessage(message.Channel(), fmt.Sprintf("Invalid reminder, no message. eg: %s", p.randomReminder(service)))
return
}
requester := message.UserName()
if service.Name() == bruxism.DiscordServiceName {
requester = fmt.Sprintf("<@%s>", message.UserID())
}
err = p.AddReminder(&Reminder{
StartTime: now,
Time: t,
Requester: requester,
Target: message.Channel(),
Message: r,
IsPrivate: service.IsPrivate(message),
})
if err != nil {
service.SendMessage(message.Channel(), err.Error())
return
}
service.SendMessage(message.Channel(), fmt.Sprintf("Reminder set for %s.", humanize.Time(t)))
}
}
}
示例3: Message
// Message handler.
func (p *triviaPlugin) Message(bot *bruxism.Bot, service bruxism.Service, message bruxism.Message) {
defer bruxism.MessageRecover()
if !service.IsMe(message) && !service.IsPrivate(message) {
messageChannel := message.Channel()
isCommand := bruxism.MatchesCommand(service, "trivia", message)
if isCommand && (service.IsModerator(message) || service.IsBotOwner(message)) {
p.Lock()
tc := p.Channels[messageChannel]
if tc == nil {
tc = &triviaChannel{
Channel: messageChannel,
Scores: map[string]*triviaScore{},
}
p.Channels[messageChannel] = tc
}
p.Unlock()
_, parts := bruxism.ParseCommand(service, message)
if len(parts) == 0 {
return
}
switch parts[0] {
case "start":
theme := ""
if len(parts) >= 2 {
theme = parts[1]
}
tc.Start(bot, service, theme)
case "stop":
tc.Stop(bot, service)
}
} else {
if isCommand {
_, parts := bruxism.ParseCommand(service, message)
if len(parts) == 0 {
return
}
if parts[0] == "score" {
p.RLock()
tc := p.Channels[messageChannel]
if tc != nil {
ts := tc.Scores[message.UserID()]
if ts != nil {
service.SendMessage(message.Channel(), fmt.Sprintf("%s's score is %d.", message.UserName(), ts.Score))
} else {
service.SendMessage(message.Channel(), fmt.Sprintf("%s's score is 0.", message.UserName()))
}
}
p.RUnlock()
}
return
}
p.RLock()
tc := p.Channels[messageChannel]
p.RUnlock()
if tc != nil {
tc.Message(bot, service, message)
}
}
}
}