me.chanjar.weixin.mp.api.WxMpMessageRouter Java Examples
The following examples show how to use
me.chanjar.weixin.mp.api.WxMpMessageRouter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxMpUtil.java From mywx with Apache License 2.0 | 6 votes |
/** * @param wxMpMessageRouter 微信路由 * @param async * @param ask * @param answer */ public static void text( WxMpMessageRouter wxMpMessageRouter, boolean async, String ask, String answer ) { WxMpMessageHandler handler = (wxMessage, context, wxMpService, sessionManager) -> { WxMpXmlOutTextMessage m = WxMpXmlOutMessage .TEXT() .content(answer) .fromUser(wxMessage.getToUserName()) .toUser(wxMessage.getFromUserName()) .build(); return m; }; wxMpMessageRouter .rule() .async(async) .content(ask) .handler(handler) .end(); }
Example #2
Source File: WxMpConfiguration.java From mall4j with GNU Affero General Public License v3.0 | 5 votes |
@Bean public WxMpMessageRouter messageRouter() { final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService()); // 自定义菜单事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT) .event(MenuButtonType.CLICK).handler(this.menuHandler).end(); return newRouter; }
Example #3
Source File: WxMpDemoServer.java From weixin-java-tools with Apache License 2.0 | 5 votes |
private static void initWeixin() { try (InputStream is1 = ClassLoader .getSystemResourceAsStream("test-config.xml")) { WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage .fromXml(is1); wxMpConfigStorage = config; wxMpService = new WxMpServiceHttpClientImpl(); wxMpService.setWxMpConfigStorage(config); WxMpMessageHandler logHandler = new DemoLogHandler(); WxMpMessageHandler textHandler = new DemoTextHandler(); WxMpMessageHandler imageHandler = new DemoImageHandler(); WxMpMessageHandler oauth2handler = new DemoOAuth2Handler(); DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler(); wxMpMessageRouter = new WxMpMessageRouter(wxMpService); wxMpMessageRouter.rule().handler(logHandler).next().rule() .msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler) .handler(guessNumberHandler).end().rule().async(false).content("哈哈") .handler(textHandler).end().rule().async(false).content("图片") .handler(imageHandler).end().rule().async(false).content("oauth") .handler(oauth2handler).end(); } catch (IOException e) { e.printStackTrace(); } }
Example #4
Source File: WxMpConfiguration.java From yshopmall with Apache License 2.0 | 4 votes |
/** * 获取WxMpMessageRouter */ public static WxMpMessageRouter getWxMpMessageRouter() { WxMpMessageRouter wxMpMessageRouter = routers.get(ShopKeyUtils.getYshopWeiXinMpSevice()); return wxMpMessageRouter; }
Example #5
Source File: WxMpEndpointServlet.java From weixin-java-tools with Apache License 2.0 | 4 votes |
public WxMpEndpointServlet(WxMpConfigStorage wxMpConfigStorage, WxMpService wxMpService, WxMpMessageRouter wxMpMessageRouter) { this.wxMpConfigStorage = wxMpConfigStorage; this.wxMpService = wxMpService; this.wxMpMessageRouter = wxMpMessageRouter; }
Example #6
Source File: WxMpConfiguration.java From black-shop with Apache License 2.0 | 4 votes |
public static Map<String, WxMpMessageRouter> getRouters() { return routers; }
Example #7
Source File: WechatMpConfiguration.java From fw-cloud-framework with MIT License | 4 votes |
@Bean public WxMpMessageRouter router(WxMpService wxMpService) { final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService); // 记录所有事件的日志 (异步执行) newRouter.rule().handler(this.logHandler).next(); // 接收客服会话管理事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event( WxMpEventConstants.CustomerService.KF_CREATE_SESSION) .handler(this.kfSessionHandler).end(); newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event( WxMpEventConstants.CustomerService.KF_CLOSE_SESSION).handler(this.kfSessionHandler) .end(); newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event( WxMpEventConstants.CustomerService.KF_SWITCH_SESSION) .handler(this.kfSessionHandler).end(); // 门店审核事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event( WxMpEventConstants.POI_CHECK_NOTIFY).handler(this.storeCheckNotifyHandler).end(); // 自定义菜单事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.CLICK) .handler(this.getMenuHandler()).end(); // 点击菜单连接事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(MenuButtonType.VIEW).handler( this.nullHandler).end(); // 关注事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.SUBSCRIBE).handler( this.getSubscribeHandler()).end(); // 取消关注事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.UNSUBSCRIBE) .handler(this.getUnsubscribeHandler()).end(); // 上报地理位置事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.LOCATION).handler( this.getLocationHandler()).end(); // 接收地理位置消息 newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler( this.getLocationHandler()).end(); // 扫码事件 newRouter.rule().async(false).msgType(XmlMsgType.EVENT).event(EventType.SCAN).handler( this.getScanHandler()).end(); // 默认 newRouter.rule().async(false).handler(this.getMsgHandler()).end(); return newRouter; }
Example #8
Source File: WxMpConfiguration.java From sdb-mall with Apache License 2.0 | 4 votes |
public static Map<String, WxMpMessageRouter> getRouters() { return routers; }
Example #9
Source File: WxMpEndpointServlet.java From weixin-java-tools with Apache License 2.0 | 4 votes |
public WxMpEndpointServlet(WxMpConfigStorage wxMpConfigStorage, WxMpService wxMpService, WxMpMessageRouter wxMpMessageRouter) { this.wxMpConfigStorage = wxMpConfigStorage; this.wxMpService = wxMpService; this.wxMpMessageRouter = wxMpMessageRouter; }