當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plugins.BotEvent類代碼示例

本文整理匯總了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;未經允許,請勿轉載。