Skip to content

Commit 9d6b684

Browse files
authored
Merge pull request #28 from diaozxin007/master
1. update wechaty grpc to 0.16.1 2
2 parents 0018167 + facc316 commit 9d6b684

File tree

14 files changed

+403
-102
lines changed

14 files changed

+403
-102
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,20 @@ If you are interested in the translation and want to look at how it works, it wi
227227

228228
## Usage
229229

230-
1. Add a token to class `io.github.wechaty.examples.Main` in folder `wechaty/src/main/java`
230+
1. Add a token to class `io.github.wechaty.example.Main` in folder `examples/src/main/java`
231231
2. Build:
232232

233233
```shell
234+
cd examples/
234235
mvn install
235236
```
236237

237238
3. Run
238239

239240
```shell
240-
java -jar wechaty/target/wechaty-1.0.0-SNAPSOHOT-jar-with-dependencies.jar
241+
java -jar target/examples-0.1.1-SNAPSHOT-jar-with-dependencies.jar
241242
# or run in background
242-
nohup java -jar wechaty/target/wechaty-1.0.0-SNAPSOHOT-jar-with-dependencies.jar &>> nohup.out & tailf nohup.out
243+
nohup java -jar target/examples-0.1.1-SNAPSHOT-jar-with-dependencies.jar &>> nohup.out & tailf nohup.out
243244
```
244245

245246
4. enjoy
@@ -263,6 +264,10 @@ mvn install wechaty
263264

264265
### master
265266

267+
### v0.1.1 (June 6 2020)
268+
1. update wechaty grpc to 0.16.1
269+
2. move examples from wechaty to independent module. Make example easy to use.
270+
266271
### v0.1.1 (May 31 2020)
267272

268273
1. update version to 0.1.1-SNAPSHOT

examples/pom.xml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
4+
<parent>
5+
<groupId>io.github.wechaty</groupId>
6+
<artifactId>wechaty-parent</artifactId>
7+
<version>0.1.1-SNAPSHOT</version>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
<artifactId>wechaty-example</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<properties>
14+
<kotlin.version>1.3.72</kotlin.version>
15+
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18+
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
19+
<dokka.version>0.10.1</dokka.version>
20+
</properties>
21+
22+
<dependencies>
23+
24+
<dependency>
25+
<groupId>io.github.wechaty</groupId>
26+
<artifactId>wechaty</artifactId>
27+
<version>0.1.1-SNAPSHOT</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.apache.logging.log4j</groupId>
31+
<artifactId>log4j-api</artifactId>
32+
<version>2.13.1</version>
33+
</dependency>
34+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
35+
<dependency>
36+
<groupId>org.apache.logging.log4j</groupId>
37+
<artifactId>log4j-core</artifactId>
38+
<version>2.13.1</version>
39+
</dependency>
40+
<dependency> <!-- 桥接:告诉Slf4j使用Log4j2 -->
41+
<groupId>org.apache.logging.log4j</groupId>
42+
<artifactId>log4j-slf4j-impl</artifactId>
43+
<version>2.13.1</version>
44+
</dependency>
45+
<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
46+
<dependency>
47+
<groupId>com.lmax</groupId>
48+
<artifactId>disruptor</artifactId>
49+
<version>3.4.2</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>org.slf4j</groupId>
54+
<artifactId>slf4j-api</artifactId>
55+
<version>1.7.30</version>
56+
</dependency>
57+
58+
59+
</dependencies>
60+
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-compiler-plugin</artifactId>
66+
<version>3.6.1</version>
67+
<configuration>
68+
<source>1.8</source>
69+
<target>1.8</target>
70+
</configuration>
71+
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-assembly-plugin</artifactId>
75+
<version>3.3.0</version>
76+
<executions>
77+
<execution>
78+
<id>make-assembly</id>
79+
<phase>package</phase>
80+
<goals>
81+
<goal>single</goal>
82+
</goals>
83+
<configuration>
84+
<archive>
85+
<manifest>
86+
<mainClass>io.github.wechaty.examples.Main</mainClass>
87+
</manifest>
88+
</archive>
89+
<descriptorRefs>
90+
<descriptorRef>jar-with-dependencies</descriptorRef>
91+
</descriptorRefs>
92+
</configuration>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
</plugins>
97+
</build>
98+
99+
100+
</project>

wechaty/src/main/java/io/github/wechaty/examples/Main.java renamed to examples/src/main/java/io/github/wechaty/example/Main.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.wechaty.examples;
1+
package io.github.wechaty.example;
22

33

44
import io.github.wechaty.MessageListener;
@@ -16,12 +16,8 @@
1616

1717
public class Main {
1818

19-
private static OkHttpClient client = new OkHttpClient();
20-
2119
public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
2220

23-
FileBox fileBox = FileBox.fromUrl("https://img.xilidou.com/img/dong.jpg", null, null);
24-
2521
Wechaty bot = Wechaty.instance("your_token");
2622

2723
bot.on("scan", (qrcode, statusScanStatus, data) -> {

pom.xml

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<dependency>
4040
<groupId>io.github.wechaty</groupId>
41-
<version>0.11.25</version>
41+
<version>0.16.1</version>
4242
<artifactId>grpc</artifactId>
4343
</dependency>
4444

@@ -72,28 +72,28 @@
7272
</dependency>
7373

7474

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

9898
<dependency>
9999
<groupId>org.slf4j</groupId>
@@ -141,28 +141,12 @@
141141
<version>2.6</version>
142142
</dependency>
143143

144-
145-
<!-- <dependency>-->
146-
<!-- <groupId>com.tinder.statemachine</groupId>-->
147-
<!-- <artifactId>statemachine</artifactId>-->
148-
<!-- <version>0.2.0</version>-->
149-
<!-- </dependency>-->
150-
151144
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
152145
<dependency>
153146
<groupId>com.squareup.okhttp3</groupId>
154147
<artifactId>okhttp</artifactId>
155148
<version>4.6.0</version>
156149
</dependency>
157-
158-
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>-->
165-
166150
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/io.grpc/grpc-kotlin-stub &ndash;&gt;-->
167151
<!-- <dependency>-->
168152
<!-- <groupId>io.grpc</groupId>-->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
421421
.build()
422422

423423
return CompletableFuture.supplyAsync {
424-
grpcClient!!.frendshipAccept(request)
424+
grpcClient!!.friendshipAccept(request)
425425
return@supplyAsync null
426426
}
427427
}

wechaty-puppet/src/main/kotlin/Puppet.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ abstract class Puppet : EventEmitter {
4141
private val HEARTBEAT_COUNTER = AtomicLong()
4242
private val HOSTIE_KEEPALIVE_TIMEOUT = 15 * 1000L
4343
private val DEFAULT_WATCHDOG_TIMEOUT = 60L
44+
// private var memory: MemoryCard
4445

4546
private val executorService = Executors.newSingleThreadScheduledExecutor()
4647

@@ -65,6 +66,10 @@ abstract class Puppet : EventEmitter {
6566
count.addAndGet(1)
6667
this.puppetOptions = puppetOptions
6768

69+
// this.memory = MemoryCard()
70+
// this.memory.load()
71+
72+
6873
val timeOut = puppetOptions.timeout ?: DEFAULT_WATCHDOG_TIMEOUT
6974
watchDog = WatchDog(1000 * timeOut, "puppet")
7075

@@ -900,6 +905,10 @@ abstract class Puppet : EventEmitter {
900905
}
901906
}
902907

908+
// fun setMemory(memoryCard: MemoryCard){
909+
// this.memory = memoryCard
910+
// }
911+
903912
// fun getEventBus(): EventBus {
904913
// return eb
905914
// }
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//package io.github.wechaty.memorycard
2+
//
3+
//import org.slf4j.LoggerFactory
4+
//import java.util.concurrent.Future
5+
//
6+
//class MemoryCard{
7+
//
8+
// private var name:String? = null
9+
// protected var parent:MemoryCard? = null
10+
// protected var payload:MemoryCardPayload ? = null
11+
// protected var storage:StorageBackend? = null
12+
// protected val multiplexNameList = mutableListOf<String>()
13+
//
14+
// private var options:MemoryCardOptions
15+
//
16+
// constructor(name: String?=null,options:MemoryCardOptions? = null){
17+
//
18+
// val _optiones:MemoryCardOptions = options ?: MemoryCardOptions()
19+
//
20+
// if(name != null){
21+
// if(options != null) {
22+
// _optiones.name = name
23+
// }
24+
// }
25+
// this.options = _optiones
26+
// this.name = _optiones.name
27+
//
28+
// (_optiones.multiplex != null).let {
29+
// this.parent = _optiones.multiplex!!.parent
30+
// this.payload = this.parent!!.payload
31+
// this.multiplexNameList.addAll(parent!!.multiplexNameList)
32+
// this.multiplexNameList.add(_optiones.multiplex!!.name)
33+
// this.storage = null
34+
// }
35+
//
36+
// (_optiones.multiplex == null).let {
37+
// this.payload = null
38+
// this.multiplexNameList.clear()
39+
// }
40+
// }
41+
//
42+
// private fun getStore():StorageBackend?{
43+
// log.debug("getStorage() for storage type: %s'",this.options)
44+
//
45+
// return StorageBackend.getStorage(
46+
// this.options.name!!,
47+
// this.options.storageOptions
48+
// )
49+
// }
50+
//
51+
// fun load(){
52+
// this.payload = this.storage!!.load()
53+
// }
54+
//
55+
// fun save(){
56+
// this.storage!!.save(this.payload!!)
57+
// }
58+
//
59+
// companion object{
60+
// private val log = LoggerFactory.getLogger(MemoryCard::class.java)
61+
//
62+
// fun multiplex(memory:MemoryCard,name:String):MemoryCard{
63+
// return MemoryCard()
64+
// }
65+
// }
66+
//
67+
//
68+
//}
69+
//
70+
//class MemoryCardPayload{
71+
// val map:Map<String,Any> = HashMap()
72+
//}
73+
//
74+
//data class Multiplex(
75+
// val parent:MemoryCard,
76+
// val name:String
77+
//)
78+
//
79+
//class MemoryCardOptions{
80+
//
81+
// var name:String? = null
82+
// var storageOptions:StorageBackendOptions? = null
83+
// var multiplex:Multiplex? = null
84+
//
85+
//}
86+
//
87+
//
88+
//
89+
//

0 commit comments

Comments
 (0)