Search in sources :

Example 1 with BotBehaviour

use of won.bot.framework.eventbot.behaviour.BotBehaviour 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)

Example 2 with BotBehaviour

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

the class DebugBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    String welcomeMessage = "Greetings! \nI am the DebugBot. I " + "can simulate multiple other users so you can test things. I understand a few commands. \nTo see which ones, " + "type 'usage'.";
    String welcomeHelpMessage = "When connecting with me, you can say 'ignore', or 'deny' to make me ignore or deny requests, and 'wait N' to make me wait N seconds (max 99) before reacting.";
    EventListenerContext ctx = getEventListenerContext();
    EventBus bus = getEventBus();
    // eagerly cache RDF data
    BotBehaviour eagerlyCacheBehaviour = new EagerlyPopulateCacheBehaviour(ctx);
    eagerlyCacheBehaviour.activate();
    // react to a bot command activating/deactivating eager caching
    bus.subscribe(SetCacheEagernessCommandEvent.class, new ActionOnEventListener(ctx, new BaseEventBotAction(ctx) {

        @Override
        protected void doRun(Event event, EventListener executingListener) throws Exception {
            if (event instanceof SetCacheEagernessCommandEvent) {
                if (((SetCacheEagernessCommandEvent) event).isEager()) {
                    eagerlyCacheBehaviour.activate();
                } else {
                    eagerlyCacheBehaviour.deactivate();
                }
            }
        }
    }));
    // react to a message that was not identified as a debug command
    BotBehaviour connectionMessageBehaviour = new ConnectionMessageBehaviour(ctx);
    connectionMessageBehaviour.activate();
    // react to the debug deactivate command (deactivate my need)
    BotBehaviour deactivateNeedBehaviour = new DeactivateNeedBehaviour(ctx);
    deactivateNeedBehaviour.activate();
    // react to the close behaviour
    BotBehaviour closeBehaviour = new CloseBevahiour(ctx);
    closeBehaviour.activate();
    // register with WoN nodes, be notified when new needs are created
    RegisterMatcherAction registerMatcherAction = new RegisterMatcherAction(ctx);
    this.matcherRegistrator = new ActionOnEventListener(ctx, registerMatcherAction, 1);
    bus.subscribe(ActEvent.class, this.matcherRegistrator);
    RandomDelayedAction delayedRegistration = new RandomDelayedAction(ctx, registrationMatcherRetryInterval, registrationMatcherRetryInterval, 0, registerMatcherAction);
    ActionOnEventListener matcherRetryRegistrator = new ActionOnEventListener(ctx, delayedRegistration);
    bus.subscribe(MatcherRegisterFailedEvent.class, matcherRetryRegistrator);
    // create the echo need for debug initial connect - if we're not reacting to the creation of our own echo need.
    CreateDebugNeedWithFacetsAction needForInitialConnectAction = new CreateDebugNeedWithFacetsAction(ctx, true, true);
    needForInitialConnectAction.setIsInitialForConnect(true);
    ActionOnEventListener initialConnector = new ActionOnEventListener(ctx, new NotFilter(new NeedUriInNamedListFilter(ctx, ctx.getBotContextWrapper().getNeedCreateListName())), needForInitialConnectAction);
    bus.subscribe(NeedCreatedEventForMatcher.class, initialConnector);
    // create the echo need for debug initial hint - if we're not reacting to the creation of our own echo need.
    CreateDebugNeedWithFacetsAction initialHinter = new CreateDebugNeedWithFacetsAction(ctx, true, true);
    initialHinter.setIsInitialForHint(true);
    ActionOnEventListener needForInitialHintListener = new ActionOnEventListener(ctx, new NotFilter(new NeedUriInNamedListFilter(ctx, ctx.getBotContextWrapper().getNeedCreateListName())), initialHinter);
    bus.subscribe(NeedCreatedEventForMatcher.class, needForInitialHintListener);
    // as soon as the echo need triggered by debug connect created, connect to original
    this.needConnector = new ActionOnEventListener(ctx, "needConnector", new RandomDelayedAction(ctx, CONNECT_DELAY_MILLIS, CONNECT_DELAY_MILLIS, 1, new ConnectWithAssociatedNeedAction(ctx, FacetType.OwnerFacet.getURI(), FacetType.OwnerFacet.getURI(), welcomeMessage + " " + welcomeHelpMessage)));
    bus.subscribe(NeedCreatedEventForDebugConnect.class, this.needConnector);
    // as soon as the echo need triggered by debug hint command created, hint to original
    this.needHinter = new ActionOnEventListener(ctx, "needHinter", new RandomDelayedAction(ctx, CONNECT_DELAY_MILLIS, CONNECT_DELAY_MILLIS, 1, new HintAssociatedNeedAction(ctx, FacetType.OwnerFacet.getURI(), FacetType.OwnerFacet.getURI(), matcherUri)));
    bus.subscribe(NeedCreatedEventForDebugHint.class, this.needHinter);
    // if the original need wants to connect - always open
    this.autoOpener = new ActionOnEventListener(ctx, new MultipleActions(ctx, new OpenConnectionDebugAction(ctx, welcomeMessage, welcomeHelpMessage), new PublishSetChattinessEventAction(ctx, true)));
    bus.subscribe(ConnectFromOtherNeedEvent.class, this.autoOpener);
    EventBotAction userCommandAction = new DebugBotIncomingMessageToEventMappingAction(ctx);
    // if the remote side opens, send a greeting and set to chatty.
    bus.subscribe(OpenFromOtherNeedEvent.class, new ActionOnEventListener(ctx, new MultipleActions(ctx, userCommandAction, new PublishSetChattinessEventAction(ctx, true))));
    // if the bot receives a text message - try to map the command of the text message to a DebugEvent
    messageFromOtherNeedListener = new ActionOnEventListener(ctx, userCommandAction);
    bus.subscribe(MessageFromOtherNeedEvent.class, messageFromOtherNeedListener);
    // react to usage command event
    this.usageMessageSender = new ActionOnEventListener(ctx, new SendMultipleMessagesAction(ctx, DebugBotIncomingMessageToEventMappingAction.USAGE_MESSAGES));
    bus.subscribe(UsageDebugCommandEvent.class, usageMessageSender);
    bus.subscribe(CloseCommandSuccessEvent.class, new ActionOnEventListener(ctx, "chattiness off", new PublishSetChattinessEventAction(ctx, false)));
    // react to close event: set connection to not chatty
    bus.subscribe(CloseFromOtherNeedEvent.class, new ActionOnEventListener(ctx, new PublishSetChattinessEventAction(ctx, false)));
    // react to the hint and connect commands by creating a need (it will fire correct need created for connect/hint
    // events)
    needCreator = new ActionOnEventListener(ctx, new CreateDebugNeedWithFacetsAction(ctx, true, true));
    bus.subscribe(HintDebugCommandEvent.class, needCreator);
    bus.subscribe(ConnectDebugCommandEvent.class, needCreator);
    bus.subscribe(SendNDebugCommandEvent.class, new ActionOnEventListener(ctx, new SendNDebugMessagesAction(ctx, DELAY_BETWEEN_N_MESSAGES, DebugBotIncomingMessageToEventMappingAction.N_MESSAGES)));
    MessageTimingManager timingManager = new MessageTimingManager(ctx, 20);
    // on every actEvent there is a chance we send a chatty message
    bus.subscribe(ActEvent.class, new ActionOnEventListener(ctx, new SendChattyMessageAction(ctx, CHATTY_MESSAGE_PROBABILITY, timingManager, DebugBotIncomingMessageToEventMappingAction.RANDOM_MESSAGES, DebugBotIncomingMessageToEventMappingAction.LAST_MESSAGES)));
    // set the chattiness of the connection
    bus.subscribe(SetChattinessDebugCommandEvent.class, new ActionOnEventListener(ctx, new SetChattinessAction(ctx)));
    // process eliza messages with eliza
    bus.subscribe(MessageToElizaEvent.class, new ActionOnEventListener(ctx, new AnswerWithElizaAction(ctx, 20)));
    // remember when we sent the last message
    bus.subscribe(WonMessageSentOnConnectionEvent.class, new ActionOnEventListener(ctx, new RecordMessageSentTimeAction(ctx, timingManager)));
    // remember when we got the last message
    bus.subscribe(WonMessageReceivedOnConnectionEvent.class, new ActionOnEventListener(ctx, new RecordMessageReceivedTimeAction(ctx, timingManager)));
    // initialize the sent timestamp when the open message is received
    bus.subscribe(OpenFromOtherNeedEvent.class, new ActionOnEventListener(ctx, new RecordMessageSentTimeAction(ctx, timingManager)));
    // initialize the sent timestamp when the connect message is received
    bus.subscribe(ConnectFromOtherNeedEvent.class, new ActionOnEventListener(ctx, new RecordMessageSentTimeAction(ctx, timingManager)));
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) CreateDebugNeedWithFacetsAction(won.bot.framework.eventbot.action.impl.debugbot.CreateDebugNeedWithFacetsAction) SendMultipleMessagesAction(won.bot.framework.eventbot.action.impl.wonmessage.SendMultipleMessagesAction) NeedUriInNamedListFilter(won.bot.framework.eventbot.filter.impl.NeedUriInNamedListFilter) SendNDebugMessagesAction(won.bot.framework.eventbot.action.impl.debugbot.SendNDebugMessagesAction) EventBus(won.bot.framework.eventbot.bus.EventBus) HintAssociatedNeedAction(won.bot.framework.eventbot.action.impl.wonmessage.HintAssociatedNeedAction) MultipleActions(won.bot.framework.eventbot.action.impl.MultipleActions) PublishSetChattinessEventAction(won.bot.framework.eventbot.action.impl.debugbot.PublishSetChattinessEventAction) DebugBotIncomingMessageToEventMappingAction(won.bot.framework.eventbot.action.impl.debugbot.DebugBotIncomingMessageToEventMappingAction) OpenConnectionDebugAction(won.bot.framework.eventbot.action.impl.debugbot.OpenConnectionDebugAction) BaseEventListener(won.bot.framework.eventbot.listener.BaseEventListener) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) EventListener(won.bot.framework.eventbot.listener.EventListener) RandomDelayedAction(won.bot.framework.eventbot.action.impl.RandomDelayedAction) CloseBevahiour(won.bot.framework.eventbot.behaviour.CloseBevahiour) ConnectWithAssociatedNeedAction(won.bot.framework.eventbot.action.impl.wonmessage.ConnectWithAssociatedNeedAction) BotBehaviour(won.bot.framework.eventbot.behaviour.BotBehaviour) RecordMessageSentTimeAction(won.bot.framework.eventbot.action.impl.debugbot.RecordMessageSentTimeAction) SetChattinessAction(won.bot.framework.eventbot.action.impl.debugbot.SetChattinessAction) AnswerWithElizaAction(won.bot.framework.eventbot.action.impl.debugbot.AnswerWithElizaAction) EagerlyPopulateCacheBehaviour(won.bot.framework.eventbot.behaviour.EagerlyPopulateCacheBehaviour) RecordMessageReceivedTimeAction(won.bot.framework.eventbot.action.impl.debugbot.RecordMessageReceivedTimeAction) SetCacheEagernessCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.SetCacheEagernessCommandEvent) RegisterMatcherAction(won.bot.framework.eventbot.action.impl.matcher.RegisterMatcherAction) ConnectionMessageBehaviour(won.bot.framework.eventbot.behaviour.ConnectionMessageBehaviour) NotFilter(won.bot.framework.eventbot.filter.impl.NotFilter) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) UsageDebugCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.UsageDebugCommandEvent) MatcherRegisterFailedEvent(won.bot.framework.eventbot.event.impl.matcher.MatcherRegisterFailedEvent) HintDebugCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.HintDebugCommandEvent) OpenFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.OpenFromOtherNeedEvent) Event(won.bot.framework.eventbot.event.Event) SendNDebugCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.SendNDebugCommandEvent) CloseFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.CloseFromOtherNeedEvent) MessageFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherNeedEvent) CloseCommandSuccessEvent(won.bot.framework.eventbot.event.impl.command.close.CloseCommandSuccessEvent) SetChattinessDebugCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.SetChattinessDebugCommandEvent) WonMessageReceivedOnConnectionEvent(won.bot.framework.eventbot.event.impl.wonmessage.WonMessageReceivedOnConnectionEvent) ConnectDebugCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.ConnectDebugCommandEvent) MessageToElizaEvent(won.bot.framework.eventbot.event.impl.debugbot.MessageToElizaEvent) ConnectFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.ConnectFromOtherNeedEvent) WonMessageSentOnConnectionEvent(won.bot.framework.eventbot.event.impl.wonmessage.WonMessageSentOnConnectionEvent) ActEvent(won.bot.framework.eventbot.event.impl.lifecycle.ActEvent) SetCacheEagernessCommandEvent(won.bot.framework.eventbot.event.impl.debugbot.SetCacheEagernessCommandEvent) DeactivateNeedBehaviour(won.bot.framework.eventbot.behaviour.DeactivateNeedBehaviour) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) MessageTimingManager(won.bot.framework.eventbot.action.impl.debugbot.MessageTimingManager) SendChattyMessageAction(won.bot.framework.eventbot.action.impl.debugbot.SendChattyMessageAction) EventBotAction(won.bot.framework.eventbot.action.EventBotAction) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction)

Example 3 with BotBehaviour

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

the class GroupCycleBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    EventListenerContext ctx = getEventListenerContext();
    // start with a friendly message
    ctx.getEventBus().subscribe(InitializeEvent.class, new ActionOnFirstEventListener(ctx, new BaseEventBotAction(ctx) {

        @Override
        protected void doRun(Event event, EventListener executingListener) throws Exception {
            logger.info("");
            logger.info("We will create {} groups with {} members each.", NUMBER_OF_GROUPS, NUMBER_OF_GROUPMEMBERS);
            logger.info("The groups all be connected to each other, resulting in {} group-group connections", NUMBER_OF_GROUPS * (NUMBER_OF_GROUPS - 1) / 2);
            logger.info("Then, one group member will send a message to its group, which should reach all other group members exactly once");
            logger.info("This will result in {} messages being received.", NUMBER_OF_GROUPS * NUMBER_OF_GROUPMEMBERS - 1);
            logger.info("The groups will forward {} messages and suppress {} duplicates", NUMBER_OF_GROUPS * (NUMBER_OF_GROUPS + NUMBER_OF_GROUPMEMBERS - 2), (int) Math.pow(NUMBER_OF_GROUPS, 2) - 3 * NUMBER_OF_GROUPS + 2);
            logger.info("");
        }
    }));
    // understand message commands
    BotBehaviour messageCommandBehaviour = new ExecuteWonMessageCommandBehaviour(ctx);
    messageCommandBehaviour.activate();
    // if we receive a connection message, log it
    BotBehaviour logConnectionMessageBehaviour = new LogConnectionMessageBehaviour(ctx);
    logConnectionMessageBehaviour.activate();
    // log other important events (group/member creation and conneciton)
    BotBehaviour infoBehaviour = new OutputInfoMessagesBehaviour(ctx);
    infoBehaviour.activate();
    // wait for both groups to finish being set up, then connect the groups
    BehaviourBarrier barrier = new BehaviourBarrier(ctx);
    for (int i = 0; i < NUMBER_OF_GROUPS; i++) {
        // create group 1, its members, and connect them
        CreateGroupBehaviour groupCreate = new CreateGroupBehaviour(ctx);
        OpenOnConnectBehaviour groupOpenOnConnect = new OpenOnConnectBehaviour(ctx);
        CreateGroupMembersBehaviour groupMembers = new CreateGroupMembersBehaviour(ctx);
        groupCreate.onDeactivateActivate(groupOpenOnConnect, groupMembers);
        barrier.waitFor(groupMembers);
        // wait for the initialize event and trigger group creation
        ctx.getEventBus().subscribe(InitializeEvent.class, new ActionOnFirstEventListener(ctx, new BaseEventBotAction(ctx) {

            @Override
            protected void doRun(Event event, EventListener executingListener) throws Exception {
                groupCreate.activate();
            }
        }));
    }
    BotBehaviour connectGroupsBehaviour = new ConnectGroupsBehaviour(ctx);
    barrier.thenStart(connectGroupsBehaviour);
    barrier.activate();
    // after connecting the groups, send one message on behalf of one of the group members
    // and count the messages that group members receive
    // when all groups are connected, start the count behaviour
    CountReceivedMessagesBehaviour countReceivedMessagesBehaviour = new CountReceivedMessagesBehaviour(ctx);
    connectGroupsBehaviour.onDeactivateActivate(countReceivedMessagesBehaviour);
    // wait for the count behaviour to have started, then send the group message
    BotBehaviour sendInitialMessageBehaviour = new SendOneMessageBehaviour(ctx);
    countReceivedMessagesBehaviour.onActivateActivate(sendInitialMessageBehaviour);
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) BotBehaviour(won.bot.framework.eventbot.behaviour.BotBehaviour) BehaviourBarrier(won.bot.framework.eventbot.behaviour.BehaviourBarrier) ExecuteWonMessageCommandBehaviour(won.bot.framework.eventbot.behaviour.ExecuteWonMessageCommandBehaviour) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) MessageFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherNeedEvent) CreateNeedCommandResultEvent(won.bot.framework.eventbot.event.impl.command.create.CreateNeedCommandResultEvent) InitializeEvent(won.bot.framework.eventbot.event.impl.lifecycle.InitializeEvent) BaseEvent(won.bot.framework.eventbot.event.BaseEvent) BaseNeedSpecificEvent(won.bot.framework.eventbot.event.BaseNeedSpecificEvent) OpenCommandEvent(won.bot.framework.eventbot.event.impl.command.open.OpenCommandEvent) ConnectFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.ConnectFromOtherNeedEvent) OpenFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.OpenFromOtherNeedEvent) Event(won.bot.framework.eventbot.event.Event) ConnectionMessageCommandEvent(won.bot.framework.eventbot.event.impl.command.connectionmessage.ConnectionMessageCommandEvent) CommandEvent(won.bot.framework.eventbot.event.impl.cmd.CommandEvent) CreateNeedCommandEvent(won.bot.framework.eventbot.event.impl.command.create.CreateNeedCommandEvent) ConnectCommandResultEvent(won.bot.framework.eventbot.event.impl.command.connect.ConnectCommandResultEvent) ConnectCommandEvent(won.bot.framework.eventbot.event.impl.command.connect.ConnectCommandEvent) ActionOnFirstEventListener(won.bot.framework.eventbot.listener.impl.ActionOnFirstEventListener) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) EventListener(won.bot.framework.eventbot.listener.EventListener) ActionOnFirstEventListener(won.bot.framework.eventbot.listener.impl.ActionOnFirstEventListener)

Example 4 with BotBehaviour

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

the class Telegram2WonBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    EventListenerContext ctx = getEventListenerContext();
    telegramMessageGenerator.setEventListenerContext(ctx);
    bus = getEventBus();
    // Initiate Telegram Bot Handler
    ApiContextInitializer.init();
    TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
    try {
        wonTelegramBotHandler = new WonTelegramBotHandler(bus, telegramMessageGenerator, botName, token);
        logger.debug("botName: " + wonTelegramBotHandler.getBotUsername());
        logger.debug("botTokn: " + wonTelegramBotHandler.getBotToken());
        telegramBotsApi.registerBot(wonTelegramBotHandler);
        BotBehaviour connectBehaviour = new ConnectBehaviour(ctx);
        connectBehaviour.activate();
        BotBehaviour closeBehaviour = new CloseBevahiour(ctx);
        closeBehaviour.activate();
        BotBehaviour connectionMessageBehaviour = new ConnectionMessageBehaviour(ctx);
        connectionMessageBehaviour.activate();
        // Telegram initiated Events
        bus.subscribe(TelegramMessageReceivedEvent.class, new ActionOnEventListener(ctx, "TelegramMessageReceived", new TelegramMessageReceivedAction(ctx, wonTelegramBotHandler, telegramContentExtractor)));
        bus.subscribe(SendHelpEvent.class, new ActionOnEventListener(ctx, "TelegramHelpAction", new TelegramHelpAction(ctx, wonTelegramBotHandler)));
        bus.subscribe(TelegramCreateNeedEvent.class, new ActionOnEventListener(ctx, "TelegramCreateAction", new TelegramCreateAction(ctx, wonTelegramBotHandler, telegramContentExtractor)));
        // WON initiated Events
        bus.subscribe(HintFromMatcherEvent.class, new ActionOnEventListener(ctx, "HintReceived", new Hint2TelegramAction(ctx, wonTelegramBotHandler)));
        bus.subscribe(ConnectFromOtherNeedEvent.class, new ActionOnEventListener(ctx, "ConnectReceived", new Connect2TelegramAction(ctx, wonTelegramBotHandler)));
        bus.subscribe(MessageFromOtherNeedEvent.class, new ActionOnEventListener(ctx, "ReceivedTextMessage", new Message2TelegramAction(ctx, wonTelegramBotHandler)));
    } catch (TelegramApiRequestException e) {
        logger.error(e.getMessage());
    }
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) BotBehaviour(won.bot.framework.eventbot.behaviour.BotBehaviour) ConnectBehaviour(won.bot.framework.eventbot.behaviour.ConnectBehaviour) TelegramMessageReceivedAction(won.bot.framework.eventbot.action.impl.telegram.receive.TelegramMessageReceivedAction) TelegramBotsApi(org.telegram.telegrambots.TelegramBotsApi) ConnectionMessageBehaviour(won.bot.framework.eventbot.behaviour.ConnectionMessageBehaviour) TelegramApiRequestException(org.telegram.telegrambots.exceptions.TelegramApiRequestException) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) WonTelegramBotHandler(won.bot.framework.eventbot.action.impl.telegram.WonTelegramBotHandler) CloseBevahiour(won.bot.framework.eventbot.behaviour.CloseBevahiour)

Aggregations

EventListenerContext (won.bot.framework.eventbot.EventListenerContext)4 BotBehaviour (won.bot.framework.eventbot.behaviour.BotBehaviour)4 ActionOnEventListener (won.bot.framework.eventbot.listener.impl.ActionOnEventListener)3 BaseEventBotAction (won.bot.framework.eventbot.action.BaseEventBotAction)2 CloseBevahiour (won.bot.framework.eventbot.behaviour.CloseBevahiour)2 ConnectionMessageBehaviour (won.bot.framework.eventbot.behaviour.ConnectionMessageBehaviour)2 ExecuteWonMessageCommandBehaviour (won.bot.framework.eventbot.behaviour.ExecuteWonMessageCommandBehaviour)2 Event (won.bot.framework.eventbot.event.Event)2 ConnectFromOtherNeedEvent (won.bot.framework.eventbot.event.impl.wonmessage.ConnectFromOtherNeedEvent)2 MessageFromOtherNeedEvent (won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherNeedEvent)2 OpenFromOtherNeedEvent (won.bot.framework.eventbot.event.impl.wonmessage.OpenFromOtherNeedEvent)2 EventListener (won.bot.framework.eventbot.listener.EventListener)2 Optional (java.util.Optional)1 TelegramBotsApi (org.telegram.telegrambots.TelegramBotsApi)1 TelegramApiRequestException (org.telegram.telegrambots.exceptions.TelegramApiRequestException)1 FactoryBotContextWrapper (won.bot.framework.bot.context.FactoryBotContextWrapper)1 EventBotAction (won.bot.framework.eventbot.action.EventBotAction)1 MultipleActions (won.bot.framework.eventbot.action.impl.MultipleActions)1 RandomDelayedAction (won.bot.framework.eventbot.action.impl.RandomDelayedAction)1 AnswerWithElizaAction (won.bot.framework.eventbot.action.impl.debugbot.AnswerWithElizaAction)1