• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TextMessageEventHandler类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.github.messenger4j.receive.handlers.TextMessageEventHandler的典型用法代码示例。如果您正苦于以下问题:Java TextMessageEventHandler类的具体用法?Java TextMessageEventHandler怎么用?Java TextMessageEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TextMessageEventHandler类属于com.github.messenger4j.receive.handlers包,在下文中一共展示了TextMessageEventHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: newTextMessageEventHandler

点赞 3

import com.github.messenger4j.receive.handlers.TextMessageEventHandler; //导入依赖的package包/类
private TextMessageEventHandler newTextMessageEventHandler() {
  return event -> {
    LOGGER.info("Received TextMessage with text '{}'.", event.getText());
    String senderId = event.getSender().getId();
    Intent intent = IntentAnalyzer.analyzeIntent(event.getText());
    try {
      if (intent instanceof TextReplyIntent) {
        sendTextReply(senderId, ((TextReplyIntent) intent));
      } else if (intent instanceof WatchWebsite) {
        WatchWebsite watchWebsite = (WatchWebsite) intent;
        Website website = new Website(watchWebsite.url(), new UserId(senderId));
        websiteRepository.persist(website);
        sendTextMessage(senderId, "OK, wird gemacht");
      }
    } catch (MessengerApiException | MessengerIOException e) {
      handleSendException(e);
    }
  };
}
 

开发者ID:chatbot-workshop,
项目名称:java-messenger-watchdog,
代码行数:20,
代码来源:CallbackHandler.java

示例2: newTextMessageEventHandler

点赞 3

import com.github.messenger4j.receive.handlers.TextMessageEventHandler; //导入依赖的package包/类
private TextMessageEventHandler newTextMessageEventHandler() {
    return (TextMessageEvent event) -> {
        logger.debug("Received TextMessageEvent: {}", event);

        final String messageId = event.getMid();
        final String messageText = event.getText();
        final String senderId = event.getSender().getId();
        final Date timestamp = event.getTimestamp();

        logger.info("Received message '{}' with text '{}' from user '{}' at '{}'",
                messageId, messageText, senderId, timestamp);

        try {

            sendTranslationOrSpellChecked(senderId, messageText);

        } catch (UnsupportedEncodingException e) {
            handleSendException(e);
        }
    };
}
 

开发者ID:ikhamlic,
项目名称:esct-messenger-bot,
代码行数:22,
代码来源:MessengerPlatformCallbackHandler.java

示例3: getTextMessageEventHandler

点赞 2

import com.github.messenger4j.receive.handlers.TextMessageEventHandler; //导入依赖的package包/类
private TextMessageEventHandler getTextMessageEventHandler(String botId, Deployment.Environment environment) {
    return event -> {
        try {
            String message = event.getText();
            String senderId = event.getSender().getId();
            final String conversationId = getConversationId(environment, botId, senderId);
            say(environment, botId, conversationId, senderId, message);

        } catch (RestInterfaceFactoryException | IRequest.HttpRequestException e) {
            log.error(e.getLocalizedMessage(), e);
        }
    };
}
 

开发者ID:labsai,
项目名称:EDDI,
代码行数:14,
代码来源:FacebookEndpoint.java

示例4: newTextMessageEventHandler

点赞 2

import com.github.messenger4j.receive.handlers.TextMessageEventHandler; //导入依赖的package包/类
private TextMessageEventHandler newTextMessageEventHandler() {
    return event -> {
        logger.debug("Received TextMessageEvent: {}", event);

        final String messageId = event.getMid();
        final String messageText = event.getText();
        final String senderId = event.getSender().getId();
        final Date timestamp = event.getTimestamp();

        logger.info("Received message '{}' with text '{}' from user '{}' at '{}'",
                messageId, messageText, senderId, timestamp);

        try {
            switch (messageText.toLowerCase()) {
                case "image":
                    sendImageMessage(senderId);
                    break;

                case "gif":
                    sendGifMessage(senderId);
                    break;

                case "audio":
                    sendAudioMessage(senderId);
                    break;

                case "video":
                    sendVideoMessage(senderId);
                    break;

                case "file":
                    sendFileMessage(senderId);
                    break;

                case "button":
                    sendButtonMessage(senderId);
                    break;

                case "generic":
                    sendGenericMessage(senderId);
                    break;

                case "receipt":
                    sendReceiptMessage(senderId);
                    break;

                case "quick reply":
                    sendQuickReply(senderId);
                    break;

                case "read receipt":
                    sendReadReceipt(senderId);
                    break;

                case "typing on":
                    sendTypingOn(senderId);
                    break;

                case "typing off":
                    sendTypingOff(senderId);
                    break;

                /*
                case "account linking":
                    sendAccountLinking(senderId);
                    break;
                */

                default:
                    sendTextMessage(senderId, messageText);
            }
        } catch (MessengerApiException | MessengerIOException e) {
            handleSendException(e);
        }
    };
}
 

开发者ID:messenger4j,
项目名称:messenger4j-spring-boot-quickstart-template,
代码行数:77,
代码来源:MessengerPlatformCallbackHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)