Skip to content

Commit 0018167

Browse files
committed
Merge branch 'master' of github.com:wechaty/java-wechaty
2 parents 38d415e + 648ffc9 commit 0018167

File tree

28 files changed

+1106
-216
lines changed

28 files changed

+1106
-216
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ mvn install wechaty
263263

264264
### master
265265

266+
### v0.1.1 (May 31 2020)
267+
268+
1. update version to 0.1.1-SNAPSHOT
269+
1. finish all function of room
270+
1. remove log4j2 package from wechaty
271+
1. change all log level to debug
272+
1. remove log4j2.xml from wechaty
273+
266274
### v0.1 (May 18 2020)
267275

268276
We decided to use Kotlin to develop the Java Wechaty!

pom.xml

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>io.github.wechaty</groupId>
66
<artifactId>wechaty-parent</artifactId>
77
<packaging>pom</packaging>
8-
<version>0.1.0-SNAPSHOT</version>
8+
<version>0.1.1-SNAPSHOT</version>
99
<name>kotlin-wechaty</name>
1010

1111
<description>
@@ -26,12 +26,11 @@
2626
<dokka.version>0.10.1</dokka.version>
2727
</properties>
2828

29-
30-
3129
<modules>
3230
<module>wechaty</module>
3331
<module>wechaty-puppet</module>
3432
<module>wechaty-puppet-hostie</module>
33+
<module>wechaty-puppet-mock</module>
3534
</modules>
3635

3736
<dependencyManagement>
@@ -73,22 +72,28 @@
7372
</dependency>
7473

7574

76-
<dependency>
77-
<groupId>org.apache.logging.log4j</groupId>
78-
<artifactId>log4j-api</artifactId>
79-
<version>2.13.1</version>
80-
</dependency>
81-
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
82-
<dependency>
83-
<groupId>org.apache.logging.log4j</groupId>
84-
<artifactId>log4j-core</artifactId>
85-
<version>2.13.1</version>
86-
</dependency>
87-
<dependency> <!-- 桥接:告诉Slf4j使用Log4j2 -->
88-
<groupId>org.apache.logging.log4j</groupId>
89-
<artifactId>log4j-slf4j-impl</artifactId>
90-
<version>2.13.1</version>
91-
</dependency>
75+
<!-- <dependency>-->
76+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
77+
<!-- <artifactId>log4j-api</artifactId>-->
78+
<!-- <version>2.13.1</version>-->
79+
<!-- </dependency>-->
80+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core &ndash;&gt;-->
81+
<!-- <dependency>-->
82+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
83+
<!-- <artifactId>log4j-core</artifactId>-->
84+
<!-- <version>2.13.1</version>-->
85+
<!-- </dependency>-->
86+
<!-- <dependency> &lt;!&ndash; 桥接:告诉Slf4j使用Log4j2 &ndash;&gt;-->
87+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
88+
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
89+
<!-- <version>2.13.1</version>-->
90+
<!-- </dependency>-->
91+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/com.lmax/disruptor &ndash;&gt;-->
92+
<!-- <dependency>-->
93+
<!-- <groupId>com.lmax</groupId>-->
94+
<!-- <artifactId>disruptor</artifactId>-->
95+
<!-- <version>3.4.2</version>-->
96+
<!-- </dependency>-->
9297

9398
<dependency>
9499
<groupId>org.slf4j</groupId>
@@ -108,13 +113,6 @@
108113
<version>2.11.0</version>
109114
</dependency>
110115

111-
<!-- https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static -->
112-
<dependency>
113-
<groupId>io.netty</groupId>
114-
<artifactId>netty-tcnative-boringssl-static</artifactId>
115-
<version>2.0.30.Final</version>
116-
</dependency>
117-
118116
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
119117
<dependency>
120118
<groupId>com.fasterxml.jackson.core</groupId>
@@ -144,11 +142,11 @@
144142
</dependency>
145143

146144

147-
<dependency>
148-
<groupId>com.tinder.statemachine</groupId>
149-
<artifactId>statemachine</artifactId>
150-
<version>0.2.0</version>
151-
</dependency>
145+
<!-- <dependency>-->
146+
<!-- <groupId>com.tinder.statemachine</groupId>-->
147+
<!-- <artifactId>statemachine</artifactId>-->
148+
<!-- <version>0.2.0</version>-->
149+
<!-- </dependency>-->
152150

153151
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
154152
<dependency>
@@ -158,19 +156,19 @@
158156
</dependency>
159157

160158

161-
<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
162-
<dependency>
163-
<groupId>com.lmax</groupId>
164-
<artifactId>disruptor</artifactId>
165-
<version>3.4.2</version>
166-
</dependency>
159+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/com.lmax/disruptor &ndash;&gt;-->
160+
<!-- <dependency>-->
161+
<!-- <groupId>com.lmax</groupId>-->
162+
<!-- <artifactId>disruptor</artifactId>-->
163+
<!-- <version>3.4.2</version>-->
164+
<!-- </dependency>-->
167165

168-
<!-- https://mvnrepository.com/artifact/io.grpc/grpc-kotlin-stub -->
169-
<dependency>
170-
<groupId>io.grpc</groupId>
171-
<artifactId>grpc-kotlin-stub</artifactId>
172-
<version>0.1.1</version>
173-
</dependency>
166+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/io.grpc/grpc-kotlin-stub &ndash;&gt;-->
167+
<!-- <dependency>-->
168+
<!-- <groupId>io.grpc</groupId>-->
169+
<!-- <artifactId>grpc-kotlin-stub</artifactId>-->
170+
<!-- <version>0.1.1</version>-->
171+
<!-- </dependency>-->
174172

175173
<dependency>
176174
<groupId>org.hamcrest</groupId>
@@ -183,11 +181,27 @@
183181
<version>2.16</version>
184182
</dependency>
185183

184+
<dependency>
185+
<groupId>org.mockito</groupId>
186+
<artifactId>mockito-core</artifactId>
187+
<version>3.3.3</version>
188+
</dependency>
189+
<dependency>
190+
<groupId>junit</groupId>
191+
<artifactId>junit</artifactId>
192+
<version>4.12</version>
193+
</dependency>
194+
<dependency>
195+
<groupId>com.github.javafaker</groupId>
196+
<artifactId>javafaker</artifactId>
197+
<version>1.0.2</version>
198+
</dependency>
199+
186200
</dependencies>
187201
</dependencyManagement>
188202

189-
<!-- <build>-->
190-
<!-- <plugins>-->
203+
<build>
204+
<plugins>
191205
<!-- <plugin>-->
192206
<!-- <groupId>org.apache.maven.plugins</groupId>-->
193207
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
@@ -208,8 +222,8 @@
208222
<!-- </execution>-->
209223
<!-- </executions>-->
210224
<!-- </plugin>-->
211-
<!-- </plugins>-->
212-
<!-- </build>-->
225+
</plugins>
226+
</build>
213227

214228

215229
<contributors>

wechaty-puppet-hostie/pom.xml

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
<parent>
55
<groupId>io.github.wechaty</groupId>
66
<artifactId>wechaty-parent</artifactId>
7-
<version>0.1.0-SNAPSHOT</version>
7+
<version>0.1.1-SNAPSHOT</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010
<artifactId>wechaty-puppet-hostie</artifactId>
1111
<packaging>jar</packaging>
1212

13-
<properties>
14-
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
15-
<dokka.version>0.10.1</dokka.version>
16-
</properties>
17-
1813
<dependencies>
1914

2015
<dependency>
@@ -30,18 +25,6 @@
3025
<groupId>io.github.wechaty</groupId>
3126
<artifactId>grpc</artifactId>
3227
</dependency>
33-
<!-- <dependency>-->
34-
<!-- <groupId>io.netty</groupId>-->
35-
<!-- <artifactId>netty-transport-native-kqueue</artifactId>-->
36-
<!-- <classifier>osx-x86_64</classifier>-->
37-
<!-- </dependency>-->
38-
39-
<!-- <dependency>-->
40-
<!-- <groupId>io.netty</groupId>-->
41-
<!-- <artifactId>netty-transport-native-epoll</artifactId>-->
42-
<!-- <classifier>linux-x86_64</classifier>-->
43-
<!-- </dependency>-->
44-
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
4528
<dependency>
4629
<groupId>com.squareup.okhttp3</groupId>
4730
<artifactId>okhttp</artifactId>
@@ -53,34 +36,33 @@
5336
<artifactId>guava</artifactId>
5437
</dependency>
5538

56-
<dependency>
57-
<groupId>org.apache.logging.log4j</groupId>
58-
<artifactId>log4j-api</artifactId>
59-
</dependency>
60-
<dependency>
61-
<groupId>org.apache.logging.log4j</groupId>
62-
<artifactId>log4j-core</artifactId>
63-
</dependency>
64-
<dependency>
65-
<groupId>org.apache.logging.log4j</groupId>
66-
<artifactId>log4j-slf4j-impl</artifactId>
67-
</dependency>
39+
<!-- <dependency>-->
40+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
41+
<!-- <artifactId>log4j-api</artifactId>-->
42+
<!-- </dependency>-->
43+
<!-- <dependency>-->
44+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
45+
<!-- <artifactId>log4j-core</artifactId>-->
46+
<!-- </dependency>-->
47+
<!-- <dependency>-->
48+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
49+
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
50+
<!-- </dependency>-->
6851
<dependency>
6952
<groupId>org.slf4j</groupId>
7053
<artifactId>slf4j-api</artifactId>
7154
</dependency>
7255

73-
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static &ndash;&gt;-->
74-
<!-- <dependency>-->
75-
<!-- <groupId>io.netty</groupId>-->
76-
<!-- <artifactId>netty-tcnative-boringssl-static</artifactId>-->
77-
<!-- </dependency>-->
78-
7956
<dependency>
8057
<groupId>com.fasterxml.jackson.module</groupId>
8158
<artifactId>jackson-module-kotlin</artifactId>
8259
</dependency>
8360

61+
<dependency>
62+
<groupId>org.apache.commons</groupId>
63+
<artifactId>commons-lang3</artifactId>
64+
</dependency>
65+
8466
</dependencies>
8567

8668
<build>

wechaty-puppet-hostie/src/main/kotlin/io/github/wechaty/grpc/GrpcPuppet.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import org.apache.commons.lang3.StringUtils
1616
import org.apache.commons.lang3.math.NumberUtils
1717
import org.slf4j.LoggerFactory
1818
import java.util.concurrent.CompletableFuture
19-
import java.util.concurrent.CountDownLatch
2019
import java.util.concurrent.Executors.newFixedThreadPool
2120
import java.util.concurrent.Future
2221
import java.util.concurrent.TimeUnit
@@ -29,8 +28,6 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
2928

3029
private var channel: ManagedChannel? = null
3130

32-
private val GRPC_PROT = 8788
33-
3431
private val CHATIE_ENDPOINT = "https://api.chatie.io/v0/hosties/"
3532

3633
private val client: OkHttpClient = OkHttpClient()
@@ -75,7 +72,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
7572
state = try {
7673
startGrpcClient().get()
7774
val state = channel!!.getState(true)
78-
log.info(state.name)
75+
log.debug(state.name)
7976
val startRequest = Base.StartRequest.newBuilder().build()
8077
val start = grpcClient!!.start(startRequest)
8178
startGrpcStream()
@@ -92,7 +89,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
9289

9390
override fun stop(): Future<Void> {
9491

95-
log.info("stop()")
92+
log.debug("stop()")
9693
if (state == StateEnum.OFF) {
9794
log.warn("stop() is called on a OFF puppet. await ready(off) and return.")
9895
return CompletableFuture.completedFuture(null)
@@ -129,7 +126,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
129126

130127
override fun unref() {
131128

132-
log.info("unref")
129+
log.debug("unref")
133130
super.unref()
134131

135132
}
@@ -187,7 +184,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
187184
fun stopGrpcClient(): Future<Void> {
188185

189186
channel!!.shutdown().awaitTermination(5, TimeUnit.SECONDS)
190-
log.info("grpc is shutdown")
187+
log.debug("grpc is shutdown")
191188
return CompletableFuture.completedFuture(null)
192189
}
193190

@@ -406,7 +403,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
406403
payload.province = response.province
407404
payload.signature = response.signature
408405
payload.star = response.star
409-
payload.type = ContractType.getByCode(response.type.number)
406+
payload.type = ContactType.getByCode(response.type.number)
410407
payload.weixin = response.weixin
411408
payload
412409
}
@@ -580,8 +577,8 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
580577

581578
val fileJson = file.toJsonString()
582579

583-
log.info("json is {}", fileJson)
584-
log.info("json size is {}", fileJson.length)
580+
log.debug("json is {}", fileJson)
581+
log.debug("json size is {}", fileJson.length)
585582

586583
val request = Message.MessageSendFileRequest.newBuilder()
587584
.setConversationId(conversationId)
@@ -942,7 +939,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
942939
val type = event.type
943940
val payload = event.payload
944941

945-
log.info("PuppetHostie $type payload $payload")
942+
log.debug("PuppetHostie $type payload $payload")
946943

947944
if (type != Event.EventType.EVENT_TYPE_HEARTBEAT) {
948945
emit("heartbeat", EventHeartbeatPayload("heartbeat"))
@@ -1004,7 +1001,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
10041001

10051002
Event.EventType.EVENT_TYPE_SCAN -> {
10061003
val eventScanPayload = JsonUtils.readValue<EventScanPayload>(payload)
1007-
log.info("scan pay load is {}", eventScanPayload)
1004+
log.debug("scan pay load is {}", eventScanPayload)
10081005
emit("scan", eventScanPayload)
10091006
}
10101007

@@ -1018,7 +1015,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
10181015

10191016

10201017
else -> {
1021-
log.info("PuppetHostie $type payload $payload")
1018+
log.debug("PuppetHostie $type payload $payload")
10221019
}
10231020

10241021

0 commit comments

Comments
 (0)