Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望能合并 #28

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.iml

/bin/
QR.jpg
Binary file added JavaToolKit-1.0-SNAPSHOT.jar
Binary file not shown.
14 changes: 14 additions & 0 deletions Kuangcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 个人修改
> [原项目说明](https://github.com/Kuangcp/itchat4j/blob/master/yaphone.md)
### 修改运行方式 2017-06-06 12:27:47
- 运行 mvn package 命令 进行打包
- 指定使用图灵机器人的类来运行
- `java -cp jar包 TulingRobot 目录`

- 可能遇到的bug:
- Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/java/jdk1.8.0_102/jre/lib/amd64/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
- [FixPage](http://ju.outofmemory.cn/entry/296572)
- linux下:
- `./run.sh` 生成图片之后直接扫描图片或者如下:
- `./read.sh` 终端中输出二维码扫描,登录即可
- `注意`:前提是安装了python和 [qrcode-terminal](https://github.com/alishtory/qrcode-terminal)
45 changes: 27 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand All @@ -122,25 +122,34 @@
</execution>
</executions>
</plugin>

<plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
<descriptorRef>src</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.kuangcp.test.TulingRobot</mainClass>
<mainClass>com.kuangcp.test.MyTest</mainClass>
<mainClass>com.test.ReadProperties</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions read.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
basepath=$(cd `dirname $0`; pwd)
rm temp
touch temp
java -cp JavaToolKit-1.0-SNAPSHOT.jar com.myth.qrcode.ReadQRCode $basepath/QR.jpg>>temp

infile=temp
while read xcoord; do
qrcode-terminal-py -d $xcoord
done < $infile
rm temp
5 changes: 5 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rm QR.jpg
basepath=$(cd `dirname $0`; pwd)
cd $basepath/target
java -cp itchat4j-1.1.0.jar TulingRobot $basepath

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.zhouyafeng.itchat4j.demo.demo1;
package com.kuangcp.test;

import cn.zhouyafeng.itchat4j.Wechat;
import cn.zhouyafeng.itchat4j.face.IMsgHandlerFace;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package cn.zhouyafeng.itchat4j.demo.demo1;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONObject;
package com.kuangcp.test;

import cn.zhouyafeng.itchat4j.api.WechatTools;
import cn.zhouyafeng.itchat4j.face.IMsgHandlerFace;
import cn.zhouyafeng.itchat4j.utils.enums.MsgTypeEnum;
import cn.zhouyafeng.itchat4j.utils.tools.DownloadTools;
import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* 简单示例程序,收到文本信息自动回复原信息,收到图片、语音、小视频后根据路径自动保存
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package cn.zhouyafeng.itchat4j.demo.demo2;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
package com.kuangcp.test;

import cn.zhouyafeng.itchat4j.Wechat;
import cn.zhouyafeng.itchat4j.core.Core;
import cn.zhouyafeng.itchat4j.face.IMsgHandlerFace;
import cn.zhouyafeng.itchat4j.utils.MyHttpClient;
import cn.zhouyafeng.itchat4j.utils.enums.MsgTypeEnum;
import cn.zhouyafeng.itchat4j.utils.tools.DownloadTools;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

/**
* 图灵机器人示例
Expand All @@ -29,8 +27,17 @@
*/
public class TulingRobot implements IMsgHandlerFace {
MyHttpClient myHttpClient = Core.getInstance().getMyHttpClient();
String apiKey = "597b34bea4ec4c85a775c469c84b6817"; // 这里是我申请的图灵机器人API接口,每天只能5000次调用,建议自己去申请一个,免费的:)
String apiKey = "e4f65340d723498fa577f78a247653de"; // 这里是我申请的图灵机器人API接口,每天只能5000次调用,建议自己去申请一个,免费的:)
Logger logger = Logger.getLogger("TulingRobot");
private static String path;

public static void main(String[] args) {
IMsgHandlerFace msgHandler = new TulingRobot();
// "/home/kcp/Code/wechat"
path = args[0];
Wechat wechat = new Wechat(msgHandler, args[0]);
wechat.start();
}

@Override
public String textMsgHandle(JSONObject msg) {
Expand Down Expand Up @@ -65,24 +72,20 @@ public String picMsgHandle(JSONObject msg) {
@Override
public String voiceMsgHandle(JSONObject msg) {
String fileName = String.valueOf(new Date().getTime());
String voicePath = "D://itchat4j/voice" + File.separator + fileName + ".mp3";
String voicePath = path + File.separator + fileName + ".mp3";
DownloadTools.getDownloadFn(msg, MsgTypeEnum.VOICE.getType(), voicePath);
return "收到语音";
}

@Override
public String viedoMsgHandle(JSONObject msg) {
String fileName = String.valueOf(new Date().getTime());
String viedoPath = "D://itchat4j/viedo" + File.separator + fileName + ".mp4";
String viedoPath = path + File.separator + fileName + ".mp4";
DownloadTools.getDownloadFn(msg, MsgTypeEnum.VIEDO.getType(), viedoPath);
return "收到视频";
}

public static void main(String[] args) {
IMsgHandlerFace msgHandler = new TulingRobot();
Wechat wechat = new Wechat(msgHandler, "D://itchat4j/login");
wechat.start();
}


@Override
public String nameCardMsgHandle(JSONObject msg) {
Expand Down
71 changes: 0 additions & 71 deletions src/test/java/cn/zhouyafeng/itchat4j/demo/demo3/UnusefulDemo.java

This file was deleted.

22 changes: 22 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rm QR.jpg
basepath=$(cd `dirname $0`; pwd)
cd $basepath/target
java -cp itchat4j-1.1.0.jar TulingRobot $basepath
cd ..
for ((i=0;i<3;i++));do
{
sleep 45;
java -cp JavaToolKit-1.0-SNAPSHOT.jar com.myth.qrcode.ReadQRCode $basepath/QR.jpg
}&
done
wait

#infile=temp
#while read xcoord
#do
# echo $xcoord
# qrcode-terminal-py -d $xcoord
#done < $infile
#rm temp