本文整理汇总了Golang中github.com/kyokomi/slackbot/plugins.BotEvent类的典型用法代码示例。如果您正苦于以下问题:Golang BotEvent类的具体用法?Golang BotEvent怎么用?Golang BotEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BotEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CheckMessage
func (r plugin) CheckMessage(event plugins.BotEvent, message string) (bool, string) {
cmdArgs, ok := event.BotCmdArgs(message)
if !ok {
return false, message
}
return true, strings.Join(cmdArgs, " ")
}
开发者ID:135yshr,项目名称:slackbot,代码行数:7,代码来源:docomo.go
示例2: DoAction
func (r plugin) DoAction(event plugins.BotEvent, message string) bool {
// Contextを取得
redisKey := buildRoomContextKey(event.Channel())
dialogueCtx, _ := r.repository.Load(redisKey)
// 雑談API叩く
name := event.SenderName()
req := docomo.DialogueRequest{
Utt: &message,
Context: &dialogueCtx,
Nickname: &name,
}
res, err := r.client.Dialogue.Get(req, false)
if err != nil {
event.Reply("はて?")
return true
} else if res.RequestError.PolicyException.MessageID != "" {
event.Reply(fmt.Sprintf("%s: %s",
res.RequestError.PolicyException.MessageID,
res.RequestError.PolicyException.Text),
)
return true
}
// 結果を返す
event.Reply(res.Utt)
// Contextを保存
if dialogueCtx == "" {
r.repository.Save(redisKey, res.Context)
}
return false // next ok
}
开发者ID:135yshr,项目名称:slackbot,代码行数:34,代码来源:docomo.go
示例3: CheckMessage
func (p *plugin) CheckMessage(event plugins.BotEvent, message string) (bool, string) {
if p.debug {
log.Printf("message [%s]\n", message)
log.Printf("botLinkID [%s]\n", event.BotLinkID())
log.Printf("botLinkIDForClient [%s]\n", event.BotLinkIDForClient())
log.Printf("botName [%s]\n", event.BotName())
log.Printf("botID [%s]\n", event.BotID())
}
cmdArgs, ok := event.BotCmdArgs(message)
if !ok {
return false, message
}
if len(cmdArgs) < 1 {
return false, message
}
if p.debug {
log.Println(cmdArgs)
}
for cmdKey, cmds := range p.commandMap {
if cmds.Contains(cmdArgs[0]) {
cmdArgs[0] = cmdKey
return true, strings.Join(cmdArgs, " ")
}
}
return false, message
}
开发者ID:135yshr,项目名称:slackbot,代码行数:31,代码来源:sysstd.go
示例4: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
sendMessage, isNext := GetLGTMImageURL(p.buildRandomURL(message))
event.Reply(sendMessage)
return isNext // next stop
}
开发者ID:135yshr,项目名称:slackbot,代码行数:7,代码来源:lgtm.go
示例5: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
cmdArgs := strings.Fields(message)
if _, ok := p.commandMap[cmdArgs[0]]; !ok {
return true
}
event.Reply(p.executeCommand(cmdArgs...))
return false // next ok
}
开发者ID:135yshr,项目名称:slackbot,代码行数:8,代码来源:sysstd.go
示例6: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
query := strings.Replace(strings.TrimLeft(message, "image me"), "image me", "", 1)
links, err := p.client.GetImageLinks(query)
if err != nil {
log.Println(err)
return false
}
idx := int(p.rd.Int() % len(links))
event.Reply(links[idx])
return false // next ng
}
开发者ID:135yshr,项目名称:slackbot,代码行数:14,代码来源:googleimage.go
示例7: DoAction
func (r *plugin) DoAction(event plugins.BotEvent, message string) bool {
size := utf8.RuneCountInString(message)
header := ""
for i := 0; i < size+2; i++ {
header += "人"
}
fotter := ""
for i := 0; i < size; i++ {
fotter += "^Y"
}
reMessage := "_" + header + "_"
reMessage += "\n"
reMessage += "> " + message + " <"
reMessage += "\n"
reMessage += " ̄Y" + fotter + " ̄"
event.Reply(reMessage)
return false // next ok
}
开发者ID:135yshr,项目名称:slackbot,代码行数:22,代码来源:suddendeath.go
示例8: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
event.Reply(message)
return true // next ok
}
开发者ID:135yshr,项目名称:slackbot,代码行数:4,代码来源:echo.go
示例9: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
c := CronCommand{}
if err := c.Scan(message); err != nil {
log.Printf("error %s", err)
return false
}
switch c.Action {
case AddAction, RandomAddAction:
message := p.cron.AddCronCommand(event.Channel(), c)
p.cron.RefreshCron(&event, event.Channel())
event.Reply(message)
case DelAction, DeleteAction, StopAction:
message := p.cron.DelCronCommand(event.Channel(), c)
p.cron.RefreshCron(&event, event.Channel())
event.Reply(message)
case ListAction:
message := p.cron.ListCronCommand(event.Channel(), c)
event.Reply(message)
case RefreshAction:
p.cron.RefreshCron(&event, event.Channel())
event.Reply("```\nrefresh ok\n```")
case HelpAction:
message := p.cron.HelpCronCommand(event.Channel(), c)
event.Reply(message)
}
return false
}
开发者ID:135yshr,项目名称:slackbot,代码行数:28,代码来源:cron.go
示例10: DoAction
func (r plugin) DoAction(event plugins.BotEvent, message string) bool {
event.Reply(r.kohaAPI.GetImageURL())
return false // next ng
}
开发者ID:135yshr,项目名称:slackbot,代码行数:4,代码来源:kohaimage.go
示例11: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
event.Reply(p.getRandomNaruhodo())
return false // next ng
}
开发者ID:135yshr,项目名称:slackbot,代码行数:4,代码来源:naruhodo.go
示例12: DoAction
func (p *plugin) DoAction(event plugins.BotEvent, message string) bool {
daisuki := strings.Replace(strings.TrimLeft(message, keyword), keyword, "", 1)
event.Reply(fmt.Sprintf("わぁい%s あかり%s大好き", daisuki, daisuki))
return false // next ok
}
开发者ID:135yshr,项目名称:slackbot,代码行数:5,代码来源:akari.go
注:本文中的github.com/kyokomi/slackbot/plugins.BotEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论