Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ class Bot{
}
```

if use plugins
```java
class Bot{
public static void main(String args[]){
Wechaty bot = Wechaty.instance()
.use(
WechatyPlugins.ScanPlugin(),
WechatyPlugins.DingDongPlugin(null))
.start(true);
}
}
```

## Development

To be writen:
Expand Down Expand Up @@ -265,6 +278,9 @@ mvn install wechaty

### master

### v0.1.3 (June 6 2020)
1. support plugins!

### v0.1.2 (June 6 2020)
1. change method `on(Event:String,Listener:listener)` to `onEvent(Listener:listener)`. See examples
2. update version to 0.1.2
Expand Down
43 changes: 42 additions & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>io.github.wechaty</groupId>
<artifactId>wechaty</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -55,9 +55,50 @@
<version>1.7.30</version>
</dependency>

<dependency>
<groupId>io.github.wechaty</groupId>
<artifactId>java-wechaty-plugin-contrib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>


</dependencies>

<repositories>
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.wechaty.example;

import io.github.wechaty.Wechaty;
import io.github.wechaty.plugins.WechatyPlugins;

public class MainWithPlugin {

public static void main(String[] args) {

Wechaty bot = Wechaty.instance("your_token")
.use(WechatyPlugins.ScanPlugin(), WechatyPlugins.DingDongPlugin(null))
.start(true);

}

}
66 changes: 21 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>io.github.wechaty</groupId>
<artifactId>wechaty-parent</artifactId>
<packaging>pom</packaging>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
<name>kotlin-wechaty</name>

<description>
Expand Down Expand Up @@ -71,30 +71,6 @@
<version>2.8.1</version>
</dependency>


<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.1</version>
</dependency>
<dependency> <!-- 桥接:告诉Slf4j使用Log4j2 -->
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -180,26 +156,26 @@

<build>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.6</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>sign-artifacts</id>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <gpgArguments>-->
<!-- <arg>&#45;&#45;pinentry-mode</arg>-->
<!-- <arg>loopback</arg>-->
<!-- </gpgArguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
2 changes: 1 addition & 1 deletion wechaty-puppet-hostie/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.github.wechaty</groupId>
<artifactId>wechaty-parent</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wechaty-puppet-hostie</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions wechaty-puppet-mock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wechaty-parent</artifactId>
<groupId>io.github.wechaty</groupId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,7 +24,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
2 changes: 1 addition & 1 deletion wechaty-puppet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.github.wechaty</groupId>
<artifactId>wechaty-parent</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wechaty-puppet</artifactId>
Expand Down
34 changes: 17 additions & 17 deletions wechaty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.github.wechaty</groupId>
<artifactId>wechaty-parent</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wechaty</artifactId>
Expand Down Expand Up @@ -59,24 +59,24 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-api</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-core</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
<!-- </dependency>-->

<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.lmax</groupId>-->
<!-- <artifactId>disruptor</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
20 changes: 17 additions & 3 deletions wechaty/src/main/kotlin/io/github/wechaty/Wechaty.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.wechaty;

//import io.github.io.github.user.Room

import io.github.wechaty.eventEmitter.Event
import io.github.wechaty.eventEmitter.EventEmitter
Expand All @@ -25,6 +24,7 @@ class Wechaty private constructor(private var wechatyOptions: WechatyOptions) :

private lateinit var puppet: Puppet
private val puppetOptions: PuppetOptions = wechatyOptions.puppetOptions!!
private val globalPluginList: MutableList<WechatyPlugin> = mutableListOf()

@Volatile
private var readyState = StateEnum.OFF
Expand All @@ -40,9 +40,10 @@ class Wechaty private constructor(private var wechatyOptions: WechatyOptions) :
val roomManager = RoomManager(this)
val roomInvitationMessage = RoomInvitationManager(this)

// init {
init {
// this.memory = wechatyOptions.memory
// }
installGlobalPlugin()
}


fun start(await: Boolean = false):Wechaty {
Expand Down Expand Up @@ -99,6 +100,19 @@ class Wechaty private constructor(private var wechatyOptions: WechatyOptions) :
return on(EventEnum.MESSAGE,listener)
}

fun use(vararg plugins: WechatyPlugin):Wechaty{
plugins.forEach {
it(this)
}
return this
}

private fun installGlobalPlugin(){
for (item in globalPluginList) {
item(this)
}
}

private fun on(event: Event,listener:LoginListener):Wechaty{
super.on(event, object : Listener {
override fun handler(vararg any: Any) {
Expand Down
2 changes: 2 additions & 0 deletions wechaty/src/main/kotlin/io/github/wechaty/WechatyOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ class WechatyOptions {
var ioToken:String? = null

}
typealias WechatyPlugin = (Wechaty) -> Unit

13 changes: 0 additions & 13 deletions wechaty/src/main/kotlin/io/github/wechaty/utils/LogUtils.kt

This file was deleted.