예제 #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
}