com.jfinal.weixin.sdk.msg.out.OutTextMsg Java Examples

The following examples show how to use com.jfinal.weixin.sdk.msg.out.OutTextMsg. 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: WechatMsgNotifyController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderOptionValue(String optionKey, String defaultText) {
    String text = optionService.findByKey(optionKey);
    if (StrUtil.isBlank(text)) {
        renderText(defaultText);
        return;
    }

    if (text.startsWith("key:") && text.length() > 4) {
        String key = text.substring(4);
        WechatReply wechatReply = wechatReplyService.findByKey(key);
        if (wechatReply != null && StrUtil.isNotBlank(wechatReply.getContent())) {
            renderWechatReply(getInMsg(), wechatReply);
        }
    }

    //以上内容没有进行渲染
    if (getRender() == null) {
        InMsg msg = getInMsg();
        OutTextMsg outMsg = new OutTextMsg(msg);
        outMsg.setContent(text);
        render(outMsg);
    }

}
 
Example #2
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 实现父类抽方法,处理关注/取消关注消息
 */
protected void processInFollowEvent(InFollowEvent inFollowEvent)
{
	if (InFollowEvent.EVENT_INFOLLOW_SUBSCRIBE.equals(inFollowEvent.getEvent()))
	{
		logger.debug("关注:" + inFollowEvent.getFromUserName());
		OutTextMsg outMsg = new OutTextMsg(inFollowEvent);
		outMsg.setContent("这是Jfinal-weixin测试服务</br>\r\n感谢您的关注");
		render(outMsg);
	}
	// 如果为取消关注事件,将无法接收到传回的信息
	if (InFollowEvent.EVENT_INFOLLOW_UNSUBSCRIBE.equals(inFollowEvent.getEvent()))
	{
		logger.debug("取消关注:" + inFollowEvent.getFromUserName());
	}
}
 
Example #3
Source File: WeixinMsgController.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
/**
 * 处理接收到的关注/取消关注事件
 */
@Override
protected void processInFollowEvent(InFollowEvent inFollowEvent) {
    OutTextMsg outMsg = new OutTextMsg(inFollowEvent);
    outMsg.setContent("欢迎关注!");
    render(outMsg);
}
 
Example #4
Source File: GetOpenIdAddon.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onRenderMessage(InMsg inMsg, MsgController msgController) {
    OutTextMsg outTextMsg = new OutTextMsg(inMsg);
    outTextMsg.setContent("您的微信 OpenId 是 : " + inMsg.getFromUserName());
    msgController.render(outTextMsg);
    return true;
}
 
Example #5
Source File: HelloWechatAddon.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onRenderMessage(InMsg inMsg, MsgController msgController) {
    OutTextMsg outTextMsg = new OutTextMsg(inMsg);
    outTextMsg.setContent("world");
    msgController.render(outTextMsg);
    return true;
}
 
Example #6
Source File: ArticleDetailWechatAddon.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onRenderMessage(InMsg inMsg, MsgController msgController) {
    InTextMsg inTextMsg = (InTextMsg) inMsg;

    String content = inTextMsg.getContent();
    String slug = content.substring(8); // 8 =  "article:".length();

    Article article = articleService.findFirstBySlug(slug);
    if (article == null) {
        return false;
    }

    String webDomain = optionService.findByKey(JPressConsts.OPTION_WEB_DOMAIN);
    if (StrUtil.isBlank(webDomain)) {
        OutTextMsg outTextMsg = new OutTextMsg(inMsg);
        outTextMsg.setContent("服务器配置错误:网站域名配置为空,请先到 后台->系统->常规 配置网站域名");
        msgController.render(outTextMsg);
        return true;
    }

    News news = new News();
    news.setDescription(CommonsUtils.maxLength(article.getText(), 100));
    news.setTitle(article.getTitle());
    news.setUrl(webDomain + article.getUrl());
    news.setPicUrl(webDomain + article.getThumbnail());

    OutNewsMsg outNewsMsg = new OutNewsMsg(inMsg);
    outNewsMsg.addNews(news);
    msgController.render(outNewsMsg);

    return true;
}
 
Example #7
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInQrCodeEvent(InQrCodeEvent inQrCodeEvent)
{
	if (InQrCodeEvent.EVENT_INQRCODE_SUBSCRIBE.equals(inQrCodeEvent.getEvent()))
	{
		logger.debug("扫码未关注:" + inQrCodeEvent.getFromUserName());
		OutTextMsg outMsg = new OutTextMsg(inQrCodeEvent);
		outMsg.setContent("感谢您的关注,二维码内容:" + inQrCodeEvent.getEventKey());
		render(outMsg);
	}
	if (InQrCodeEvent.EVENT_INQRCODE_SCAN.equals(inQrCodeEvent.getEvent()))
	{
		logger.debug("扫码已关注:" + inQrCodeEvent.getFromUserName());
	}
}
 
Example #8
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInLocationEvent(InLocationEvent inLocationEvent)
{
	logger.debug("发送地理位置事件:" + inLocationEvent.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inLocationEvent);
	outMsg.setContent("地理位置是:" + inLocationEvent.getLatitude());
	render(outMsg);
}
 
Example #9
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 实现父类抽方法,处理自定义菜单事件
 */
protected void processInMenuEvent(InMenuEvent inMenuEvent)
{
	logger.debug("菜单事件:" + inMenuEvent.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inMenuEvent);
	outMsg.setContent("菜单事件内容是:" + inMenuEvent.getEventKey());
	render(outMsg);
}
 
Example #10
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInSpeechRecognitionResults(InSpeechRecognitionResults inSpeechRecognitionResults)
{
	logger.debug("语音识别事件:" + inSpeechRecognitionResults.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inSpeechRecognitionResults);
	outMsg.setContent("语音识别内容是:" + inSpeechRecognitionResults.getRecognition());
	render(outMsg);
}
 
Example #11
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInShakearoundUserShakeEvent(InShakearoundUserShakeEvent inShakearoundUserShakeEvent) {
	logger.debug("摇一摇周边设备信息通知事件:" + inShakearoundUserShakeEvent.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inShakearoundUserShakeEvent);
	outMsg.setContent("摇一摇周边设备信息通知事件UUID:" + inShakearoundUserShakeEvent.getUuid());
	render(outMsg);
}
 
Example #12
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInVerifySuccessEvent(InVerifySuccessEvent inVerifySuccessEvent) {
	logger.debug("资质认证成功通知事件:" + inVerifySuccessEvent.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inVerifySuccessEvent);
	outMsg.setContent("资质认证成功通知事件:" + inVerifySuccessEvent.getExpiredTime());
	render(outMsg);
}
 
Example #13
Source File: WeixinMsgController.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void processInVerifyFailEvent(InVerifyFailEvent inVerifyFailEvent){
	logger.debug("资质认证失败通知事件:" + inVerifyFailEvent.getFromUserName());
	OutTextMsg outMsg = new OutTextMsg(inVerifyFailEvent);
	outMsg.setContent("资质认证失败通知事件:" + inVerifyFailEvent.getFailReason());
	render(outMsg);
}
 
Example #14
Source File: OutMsgXmlBuilderTest.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	OutTextMsg msg = new OutTextMsg();
	msg.setToUserName("to james");
	msg.setFromUserName("from james");
	msg.setCreateTime(msg.now());
	msg.setContent("jfinal weixin 极速开发平台碉堡了");
	String xml = OutMsgXmlBuilder.build(msg);
	System.out.println(xml);
}
 
Example #15
Source File: MsgController.java    From jfinal-weixin with Apache License 2.0 4 votes vote down vote up
public void renderOutTextMsg(String content) {
    OutTextMsg outMsg = new OutTextMsg(getInMsg());
    outMsg.setContent(content);
    render(outMsg);
}