Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 6 lines of Java.
"Wechaty is a great solution, I believe there would be much more users recognize it." link
— @Gcaufy, Tencent Engineer, Author of WePY"太好用,好用的想哭"
— @xinbenlv, Google Engineer, Founder of HaoShiYou.org"最好的微信开发库" link
— @Jarvis, Baidu Engineer"Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" link
— @lijiarui, Founder & CEO of Juzi.BOT."If you know js ... try Wechaty, it's easy to use."
— @Urinx Uri Lee, Author of WeixinBot(Python)
See more at Wiki:Voice Of Developer
Wechaty is used in many ChatBot projects by thousands of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code java wechaty, join our Wechaty Java Developers' Home.
Scan now, because other Wechaty Java developers want to talk with you too! (secret code: java wechaty)
class Bot{
public static void main(String args[]){
Wechaty bot = Wechaty.instance()
.onScan((qrcode, statusScanStatus, data) -> System.out.println(QrcodeUtils.getQr(qrcode)))
.onLogin(user -> System.out.println("User logined :" + user))
.onMessage(message -> System.out.println("Message:" + message))
.start(true);
}
}
if use plugins
class Bot{
public static void main(String args[]){
Wechaty bot = Wechaty.instance()
.use(
WechatyPlugins.ScanPlugin(),
WechatyPlugins.DingDongPlugin(null))
.start(true);
}
}
To be writen:
make install
make bot
We already have Wechaty in TypeScript, It will be not too hard to translate the TypeScript(TS) to Java because wechaty has only 3,000 lines of the TS code, they are well designed and de-coupled by the wechaty-puppet abstraction. So after we have translated those 3,000 lines of TypeScript code, we will almost be done.
As we have already a ecosystem of Wechaty in TypeScript, so we will not have to implement everything in Java, especially, in the Feb 2020, we have finished the @chatie/grpc service abstracting module with the wechaty-puppet-hostie implmentation.
The following diagram shows out that we can reuse almost everything in TypeScript, and what we need to do is only the block located at the top right of the diagram: Wechaty (Java)
.
+--------------------------+ +--------------------------+
| | | |
| Wechaty (TypeScript) | | Wechaty (Java) |
| | | |
+--------------------------+ +--------------------------+
+-------------------------------------------------------+
| Wechaty Puppet Hostie |
| |
| (wechaty-puppet-hostie) |
+-------------------------------------------------------+
+--------------------- @chatie/grpc ----------------------+
+-------------------------------------------------------+
| Wechaty Puppet Abstract |
| |
| (wechaty-puppet) |
+-------------------------------------------------------+
+--------------------------+ +--------------------------+
| Pad Protocol | | Web Protocol |
| | | |
| wechaty-puppet-padplus | |(wechaty-puppet-puppeteer)|
+--------------------------+ +--------------------------+
+--------------------------+ +--------------------------+
| Windows Protocol | | Mac Protocol |
| | | |
| (wechaty-puppet-windows) | | (wechaty-puppet-macpro) |
+--------------------------+ +--------------------------+
There's a 100 lines class named Image
in charge of downloading the WeChat image to different sizes.
It is a great example for demonstrating how do we translate the TypeScript to Java in Wechaty Way:
- TypeScript: https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- Java: https://github.com/wechaty/java-wechaty/blob/master/src/wechaty/user/image.py
If you are interested in the translation and want to look at how it works, it will be a good start from reading and comparing those two Image
class files in TypeScript and Java at the same time.
- TS: TypeScript
- SLOC: Source Lines Of Code
- Class Wechaty
- TS SLOC(1160): https://github.com/wechaty/wechaty/blob/master/src/wechaty.ts
- Code
- Unit Tests
- Documentation
- Class Contact
- TS SLOC(804): https://github.com/wechaty/wechaty/blob/master/src/user/contact.ts
- Code
- Unit Tests
- Documentation
- Class ContactSelf
- TS SLOC(199): https://github.com/wechaty/wechaty/blob/master/src/user/contact-self.ts
- Code
- Unit Tests
- Documentation
- Class Message
- TS SLOC(1054): https://github.com/wechaty/wechaty/blob/master/src/user/message.ts
- Code
- Unit Tests
- Documentation
- Class Room
- TS SLOC(1194): https://github.com/wechaty/wechaty/blob/master/src/user/room.ts
- Code
- Unit Tests
- Documentation
- Class Image
- TS SLOC(60): https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- Code
- Unit Tests
- Documentation
- Class Accessory
- TS SLOC(179): https://github.com/wechaty/wechaty/blob/master/src/accessory.ts
- Code
- Unit Tests
- Documentation
- Class Config
- TS SLOC(187): https://github.com/wechaty/wechaty/blob/master/src/config.ts
- Code
- Unit Tests
- Documentation
- Class Favorite
- TS SLOC(52): https://github.com/wechaty/wechaty/blob/master/src/user/favorite.ts
- Code
- Unit Tests
- Documentation
- Class Friendship
- TS SLOC(417): https://github.com/wechaty/wechaty/blob/master/src/user/friendship.ts
- Code
- Unit Tests
- Documentation
- Class MiniProgram
- TS SLOC(70): https://github.com/wechaty/wechaty/blob/master/src/user/mini-program.ts
- Code
- Unit Tests
- Documentation
- Class RoomInvitation
- TS SLOC(317): https://github.com/wechaty/wechaty/blob/master/src/user/room-invitation.ts
- Code
- Unit Tests
- Documentation
- Class Tag
- TS SLOC(190): https://github.com/wechaty/wechaty/blob/master/src/user/tag.ts
- Code
- Unit Tests
- Documentation
- Class UrlLink
- TS SLOC(107): https://github.com/wechaty/wechaty/blob/master/src/user/url-link.ts
- Code
- Unit Tests
- Documentation
- Class FileBox
- TS SLOC(638): https://github.com/huan/file-box/blob/master/src/file-box.ts
- Code
- Unit Tests
- Documentation
- Class MemoryCard
- TS SLOC(376): https://github.com/huan/memory-card/blob/master/src/memory-card.ts
- Code
- Unit Tests
- Documentation
- Class WechatyPuppet
- TS SLOC(1115): https://github.com/wechaty/wechaty-puppet/blob/master/src/puppet.ts
- Code
- Unit Tests
- Documentation
- Class WechatyPuppetHostie
- TS SLOC(909): https://github.com/wechaty/wechaty-puppet-hostie/blob/master/src/client/puppet-hostie.ts
- Code
- Unit Tests
- Documentation
-
Add a token to class
io.github.wechaty.example.Main
in folderexamples/src/main/java
-
Build:
cd examples/ mvn install
-
Run
java -jar target/wechaty-example-1.0.0-SNAPSHOT-jar-with-dependencies.jar # or run in background nohup java -jar target/wechaty-example-1.0.0-SNAPSHOT-jar-with-dependencies.jar &>> nohup.out & tailf nohup.out
-
enjoy
- JDK/JRE
mvn install wechaty
- Publish Java Module to Maven Central Repo - OSSRH Guide
- Kotlin vs Java: Most Important Differences That You Must Know
Java(Kotlin) Wechaty BETA Released!
Read more from our Multi-language Wechaty Beta Release event from our blog:
- use
PuppetManager
to manage multi puppet implementations. - add mock puppet.
- remove puppet implementations from wechaty pom. Which implementation to use depends on which implementation jar in your pom.
- fix some bugs.
- support plugins!
- change method
on(Event:String,Listener:listener)
toonEvent(Listener:listener)
. See examples - update version to 0.1.2
- update wechaty grpc to 0.16.1
- move examples from wechaty to independent module. Make example easy to use.
- update version to 0.1.1-SNAPSHOT
- finish all function of room
- remove log4j2 package from wechaty
- change all log level to debug
- remove log4j2.xml from wechaty
We decided to use Kotlin to develop the Java Wechaty!
- Project re-inited by overwriting
wechaty/java-wechaty
bydiaozxin/kotlin-wechaty
. - Second contributor joined: @redmaple1 Xiaoya Ren
- Project created.
- First contributor joined: @diaozxin007 Zhengxin DIAO (刁政欣)
- Wechaty - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript)
- Python Wechaty - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python)
- Go Wechaty - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go)
- Java Wechaty - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java)
- Scala Wechaty - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala)
[![Wechaty in Kotlin](https://img.shields.io/badge/Wechaty-Kotlin-orange)](https://github.com/wechaty/java-wechaty)
- @redmaple1 Xiaoya Ren
- @huan - Huan LI (李卓桓)
- @diaozxin007 [email protected]
- Website: 犀利豆的博客
- Code & Docs © 2020 Wechaty Contributors https://github.com/wechaty
- Code released under the Apache-2.0 License
- Docs released under Creative Commons