コード例 #1
0
ファイル: bot.go プロジェクト: wcharczuk/jarvis
// Actions returns the actions loaded for a bot
func (b *Bot) Actions() []core.Action {
	allActions := []core.Action{}
	allActions = append(allActions, b.mentionActions...)
	allActions = append(allActions, b.passiveActions...)
	sort.Sort(core.ActionsByPriority(allActions))
	return allActions
}
コード例 #2
0
ファイル: bot.go プロジェクト: wcharczuk/jarvis
// AddAction adds an action for the bot.
func (b *Bot) AddAction(action core.Action) {
	if action.Priority == 0 {
		action.Priority = core.PriorityNormal
	}
	if action.Passive {
		b.passiveActions = append(b.passiveActions, action)

		sortable := core.ActionsByPriority(b.passiveActions)
		sort.Sort(sortable)
		b.passiveActions = sortable
	} else {
		b.mentionActions = append(b.mentionActions, action)

		sortable := core.ActionsByPriority(b.mentionActions)
		sort.Sort(sortable)
		b.mentionActions = sortable
	}
	b.actionLookup[action.ID] = action
}