Skip to content

Commit

Permalink
2018-02-26 Mojo::Weixin v1.3.9 发布
Browse files Browse the repository at this point in the history
  • Loading branch information
hexsum committed Feb 26, 2018
1 parent 452dffc commit 55a73ee
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
17 changes: 17 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2017-02-26 Mojo::Weixin v1.3.9
1)开放HTTP的Agent自定义属性
2)修复重复发消息的BUG,每个消息对象增加一个uid属性,作为消息唯一标识,再多次失败尝试过程中,服务端对相同uid不会重复
3)修复MsgType为51时的bug 感谢 @cntlis
4)修复账号主域名非wx.qq.com时无法正确识别的bug
5)无法初始化好友和群信息时,直接返回空数据,避免程序退出
6)新增转账消息支持
7)默认日志打印到STDERR
8)win系统默认禁用终端颜色显示
9)增加公告系统
10)Openwx插件一系列改进:
增加 /openwx/get_group_basic_info 接口 参考issue: https://github.com/sjdy521/Mojo-Weixin/issues/123
新增post_stdout参数,上报数据是否打印到stdout,适合管道交互信息方式,默认0
插件端口监听失败会终止程序运行,添加监听端口日志,方便定位问题
事件上报添加登录失败事件
修复上报接口直接回复消息时,返回json格式中文包含\uxxxx转义形式时会报错的问题

2017-11-08 Mojo::Weixin v1.3.8
1)新增主动撤回消息功能 感谢 @呸,管杀不管埋
2)文档错误纠正 感谢 @新杰
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Mojo-Weixin v1.3.8 [![Build Status](https://travis-ci.org/sjdy521/Mojo-Weixin.svg?branch=master)](https://travis-ci.org/sjdy521/Mojo-Weixin) [![Join the chat at https://gitter.im/sjdy521/Mojo-Weixin](https://badges.gitter.im/sjdy521/Mojo-Weixin.svg)](https://gitter.im/sjdy521/Mojo-Weixin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![API列表](https://img.shields.io/badge/doc-API%E5%88%97%E8%A1%A8-brightgreen.svg)](API.md) [![QQ群-498880156](https://img.shields.io/badge/QQ%E7%BE%A4-498880156-blue.svg)](http://jq.qq.com/?_wv=1027&k=kjVJzo) [![IRC](https://img.shields.io/badge/IRC-%E5%AE%98%E6%96%B9%E9%A2%91%E9%81%93-yellow.svg)](http://irc.perfi.wang/?channel=#Mojo-Webqq)
Mojo-Weixin v1.3.9 [![Build Status](https://travis-ci.org/sjdy521/Mojo-Weixin.svg?branch=master)](https://travis-ci.org/sjdy521/Mojo-Weixin) [![Join the chat at https://gitter.im/sjdy521/Mojo-Weixin](https://badges.gitter.im/sjdy521/Mojo-Weixin.svg)](https://gitter.im/sjdy521/Mojo-Weixin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![API列表](https://img.shields.io/badge/doc-API%E5%88%97%E8%A1%A8-brightgreen.svg)](API.md) [![QQ群-498880156](https://img.shields.io/badge/QQ%E7%BE%A4-498880156-blue.svg)](http://jq.qq.com/?_wv=1027&k=kjVJzo) [![IRC](https://img.shields.io/badge/IRC-%E5%AE%98%E6%96%B9%E9%A2%91%E9%81%93-yellow.svg)](http://irc.perfi.wang/?channel=#Mojo-Webqq)
========================

使用Perl语言编写的微信客户端框架,基于Mojolicious,要求Perl版本5.10+,可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Weixin.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Mojo::Weixin;
our $VERSION = '1.3.8';
our $VERSION = '1.3.9';
use Mojo::Weixin::Base 'Mojo::EventEmitter';
use Mojo::IOLoop;
use Mojo::Weixin::Log;
Expand All @@ -21,6 +21,7 @@ has log_unicode => 0;
has download_media => 1;
has disable_color => ($^O eq 'MSWin32' ? 1 : 0); #是否禁用终端打印颜色
has send_interval => 3; #全局发送消息间隔
has json_codec_mode => 0; #0表示使用from_json/to_json 1表示使用decode_json/encode_json

has notice_api => 'https://raw.githubusercontent.com/sjdy521/Mojo-Weixin/master/NOTICE';
has is_fetch_notice => 1; #是否启动时获取公告
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojo/Weixin/Plugin/Openwx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,18 @@ sub call{
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->success){
$client->debug("插件[".__PACKAGE__ ."]接收消息[".$msg->id."]上报成功");
$client->debug( $tx->res->body );
if($tx->res->headers->content_type =~m#text/json|application/json#){
#文本类的返回结果必须是json字符串
my $json;
eval{$json = $client->from_json($tx->res->body)};
eval{$json = $client->decode_json($tx->res->body);$client->reform($json)};
if($@){$client->warn($@);return}
if(defined $json){
#暂时先不启用format的属性
#{code=>0,reply=>"回复的消息",format=>"text"}
#if((!defined $json->{format}) or (defined $json->{format} and $json->{format} eq "text")){
# $msg->reply(Encode::encode("utf8",$json->{reply})) if defined $json->{reply};
#}

$msg->reply($json->{reply}) if defined $json->{reply};
$msg->reply_media($json->{media}) if defined $json->{media} and $json->{media} =~ /^https?:\/\//;
}
Expand Down Expand Up @@ -202,7 +201,7 @@ sub call{
if($tx->res->headers->content_type =~m#text/json|application/json#){
#文本类的返回结果必须是json字符串
my $json;
eval{$json = $client->from_json($tx->res->body)};
eval{$json = $client->decode_json($tx->res->body);$client->reform($json)};
if($@){$client->warn($@);return}
if(defined $json){
#{code=>0,reply=>"回复的消息",format=>"text"}
Expand Down
16 changes: 13 additions & 3 deletions lib/Mojo/Weixin/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ sub spurt {
sub from_json{
my $self = shift;
my $r = eval{
my $json = Mojo::JSON::decode_json(@_);
$self->reform($json);
$json;
if($self->json_codec_mode == 0){
my $json = Mojo::JSON::from_json(@_);
$json;
}
elsif($self->json_codec_mode == 1){
my $json = Mojo::JSON::decode_json(@_);
$self->reform($json);
$json;
}
else{
my $json = Mojo::JSON::from_json(@_);
$json;
}
};
if($@){
$self->warn($@);
Expand Down

0 comments on commit 55a73ee

Please sign in to comment.