Search in sources :

Example 1 with FactoryBotInitBehaviour

use of won.bot.framework.eventbot.behaviour.FactoryBotInitBehaviour in project webofneeds by researchstudio-sat.

the class FactoryBot method initializeEventListeners.

@Override
protected final void initializeEventListeners() {
    if (!(super.getBotContextWrapper() instanceof FactoryBotContextWrapper)) {
        logger.error("FactoryBot does not work without a FactoryBotContextWrapper");
        throw new IllegalStateException("FactoryBot does not work without a FactoryBotContextWrapper");
    }
    if (getNeedProducer() == null) {
        logger.error("FactoryBots do not work without a set needProducer");
        throw new IllegalStateException("FactoryBots do not work without a set needProducer");
    }
    EventListenerContext ctx = getEventListenerContext();
    BotBehaviour factoryBotInitBehaviour = new FactoryBotInitBehaviour(ctx);
    BotBehaviour factoryBotHintBehaviour = new FactoryBotHintBehaviour(ctx);
    BotBehaviour messageCommandBehaviour = new ExecuteWonMessageCommandBehaviour(ctx);
    BotBehaviour runningBehaviour = new BotBehaviour(ctx) {

        @Override
        protected void onActivate(Optional<Object> message) {
            initializeFactoryEventListeners();
        }
    };
    factoryBotInitBehaviour.onDeactivateActivate(runningBehaviour, factoryBotHintBehaviour, messageCommandBehaviour);
    factoryBotInitBehaviour.activate();
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) BotBehaviour(won.bot.framework.eventbot.behaviour.BotBehaviour) Optional(java.util.Optional) FactoryBotInitBehaviour(won.bot.framework.eventbot.behaviour.FactoryBotInitBehaviour) FactoryBotHintBehaviour(won.bot.framework.eventbot.behaviour.FactoryBotHintBehaviour) ExecuteWonMessageCommandBehaviour(won.bot.framework.eventbot.behaviour.ExecuteWonMessageCommandBehaviour) FactoryBotContextWrapper(won.bot.framework.bot.context.FactoryBotContextWrapper)

Aggregations

Optional (java.util.Optional)1 FactoryBotContextWrapper (won.bot.framework.bot.context.FactoryBotContextWrapper)1 EventListenerContext (won.bot.framework.eventbot.EventListenerContext)1 BotBehaviour (won.bot.framework.eventbot.behaviour.BotBehaviour)1 ExecuteWonMessageCommandBehaviour (won.bot.framework.eventbot.behaviour.ExecuteWonMessageCommandBehaviour)1 FactoryBotHintBehaviour (won.bot.framework.eventbot.behaviour.FactoryBotHintBehaviour)1 FactoryBotInitBehaviour (won.bot.framework.eventbot.behaviour.FactoryBotInitBehaviour)1