Skip to content

Commit 77b886e

Browse files
committed
init doc files
1 parent 0c17a9a commit 77b886e

File tree

8 files changed

+350
-4
lines changed

8 files changed

+350
-4
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = 0
14+
indent_style = space
15+
trim_trailing_whitespace = false
16+
17+
# 4 tab indentation
18+
[Makefile]
19+
indent_style = tab
20+
indent_size = 4
21+
22+
[*.py]
23+
indent_size = 4

.vscode/settings.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"alignment": {
3+
"operatorPadding": "right",
4+
"indentBase": "firstline",
5+
"surroundSpace": {
6+
"colon": [1, 1], // The first number specify how much space to add to the left, can be negative. The second number is how much space to the right, can be negative.
7+
"assignment": [1, 1], // The same as above.
8+
"arrow": [1, 1], // The same as above.
9+
"comment": 2, // Special how much space to add between the trailing comment and the code.
10+
// If this value is negative, it means don't align the trailing comment.
11+
},
12+
},
13+
14+
"files.exclude": {
15+
"build/": true,
16+
"dist/": true,
17+
},
18+
19+
}

Makefile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Makefile for Scala Wechaty
2+
#
3+
# GitHb: https://github.com/wechaty/scala-wechaty
4+
# Author: Huan LI <[email protected]> https://github.com/huan
5+
#
6+
7+
.PHONY: all
8+
all : clean lint
9+
10+
.PHONY: clean
11+
clean:
12+
echo clean
13+
14+
.PHONY: lint
15+
lint:
16+
echo lint
17+
18+
.PHONY: install
19+
install:
20+
echo install
21+
22+
.PHONY: test
23+
test:
24+
echo test
25+
26+
.PHONY: bot
27+
bot:
28+
mvn \
29+
-DWECHATY_PUPPET_HOSTIE_TOKEN=$$WECHATY_PUPPET_HOSTIE_TOKEN \
30+
-Dexec.mainClass=wechaty.DingDongBot verify
31+
32+
.PHONY: version
33+
version:
34+
@newVersion=$$(awk -F. '{print $$1"."$$2"."$$3+1}' < VERSION) \
35+
&& echo $${newVersion} > VERSION \
36+
&& git add VERSION \
37+
&& git commit -m "$${newVersion}" > /dev/null \
38+
&& git tag "v$${newVersion}" \
39+
&& echo "Bumped version to $${newVersion}"

NOTICE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Scala Wechaty Chatbot SDK
2+
Copyright 2020 Wechaty Contributors.
3+
4+
This product includes software developed at
5+
The Wechaty Organization (https://github.com/wechaty).
6+
7+
This software contains code derived from the Stackoverflow,
8+
including various modifications by GitHub.

README.md

+260
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
# scala-wechaty
2+
3+
![Scala Wechaty](https://wechaty.github.io/scala-wechaty/images/scala-wechaty.png)
4+
5+
[![Scala Wechaty Getting Started](https://img.shields.io/badge/Scala%20Wechaty-Getting%20Started-red)](https://github.com/wechaty/scala-wechaty-getting-started)
6+
[![Scala 2.13](https://img.shields.io/badge/scala-2.13+-red.svg)](https://www.scala-lang.org/)
7+
8+
## Connecting Chatbots
9+
10+
[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://github.com/Wechaty/wechaty)
11+
12+
Wechaty is a Conversatioanl AI RPA SDK for Wechat **Individual** Accounts that help you create a chatbot in 6 lines of Python.
13+
14+
## Voice of the Developers
15+
16+
> "Wechaty is a great solution, I believe there would be much more users recognize it." [link](https://github.com/Wechaty/wechaty/pull/310#issuecomment-285574472)
17+
> &mdash; <cite>@Gcaufy, Tencent Engineer, Author of [WePY](https://github.com/Tencent/wepy)</cite>
18+
>
19+
> "太好用,好用的想哭"
20+
> &mdash; <cite>@xinbenlv, Google Engineer, Founder of HaoShiYou.org</cite>
21+
>
22+
> "最好的微信开发库" [link](http://weibo.com/3296245513/Ec4iNp9Ld?type=comment)
23+
> &mdash; <cite>@Jarvis, Baidu Engineer</cite>
24+
>
25+
> "Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" [link](http://mp.weixin.qq.com/s/dWHAj8XtiKG-1fIS5Og79g)
26+
> &mdash; <cite>@lijiarui, Founder & CEO of Juzi.BOT.</cite>
27+
>
28+
> "If you know js ... try Wechaty, it's easy to use."
29+
> &mdash; <cite>@Urinx Uri Lee, Author of [WeixinBot(Python)](https://github.com/Urinx/WeixinBot)</cite>
30+
31+
See more at [Wiki:Voice Of Developer](https://github.com/Wechaty/wechaty/wiki/Voice%20Of%20Developer)
32+
33+
## Join Us
34+
35+
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 _scala wechaty_, join our **Wechaty Python Developers' Home**.
36+
37+
![Wechaty Scala Developers' Home](https://wechaty.github.io/wechaty/images/bot-qr-code.png)
38+
39+
Scan now, because other Wechaty Python developers want to talk with you too! (secret code: _scala wechaty_)
40+
41+
## The World's Shortest Scala ChatBot: 9 lines of Code
42+
43+
```scala
44+
package wechaty
45+
46+
object DingDongBot {
47+
def main(args: Array[String]): Unit = {
48+
Wechaty.instance()
49+
.onScan(payload => { println("Scan QR Code to login: %s\nhttps://api.qrserver.com/v1/create-qr-code/?data=%s\n".format(payload.status, payload.qrcode)) })
50+
.onLogin(payload => { println("User %s logined\n".format(payload.id)) })
51+
.onMessage(message => { println(message) })
52+
.start()
53+
Thread.currentThread().join()
54+
}
55+
}
56+
```
57+
58+
## Scala Wechaty Developing Plan
59+
60+
We already have Wechaty in TypeScript, It will be not too hard to translate the TypeScript(TS) to Python(PY) because [wechaty](https://github.com/wechaty/wechaty) has only 3,000 lines of the TS code, they are well designed and de-coupled by the [wechaty-puppet](https://github.com/wechaty/wechaty-puppet/) abstraction. So after we have translated those 3,000 lines of TypeScript code, we will almost be done.
61+
62+
As we have already a ecosystem of Wechaty in TypeScript, so we will not have to implement everything in Python, especially, in the Feb 2020, we have finished the [@chatie/grpc](https://github.com/chatie/grpc) service abstracting module with the [wechaty-puppet-hostie](https://github.com/wechaty/wechaty-puppet-hostie) implmentation.
63+
64+
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 (Scala)`.
65+
66+
```ascii
67+
+--------------------------+ +--------------------------+
68+
| | | |
69+
| Wechaty (TypeScript) | | Wechaty (Scala) |
70+
| | | |
71+
+--------------------------+ +--------------------------+
72+
73+
+-------------------------------------------------------+
74+
| Wechaty Puppet Hostie |
75+
| |
76+
| (wechaty-puppet-hostie) |
77+
+-------------------------------------------------------+
78+
79+
+--------------------- @chatie/grpc ----------------------+
80+
81+
+-------------------------------------------------------+
82+
| Wechaty Puppet Abstract |
83+
| |
84+
| (wechaty-puppet) |
85+
+-------------------------------------------------------+
86+
87+
+--------------------------+ +--------------------------+
88+
| Pad Protocol | | Web Protocol |
89+
| | | |
90+
| wechaty-puppet-padplus | |(wechaty-puppet-puppeteer)|
91+
+--------------------------+ +--------------------------+
92+
+--------------------------+ +--------------------------+
93+
| Windows Protocol | | Mac Protocol |
94+
| | | |
95+
| (wechaty-puppet-windows) | | (wechaty-puppet-macpro) |
96+
+--------------------------+ +--------------------------+
97+
```
98+
99+
## Example: How to Translate TypeScript to Scala
100+
101+
There's a 100 lines class named `Image` in charge of downloading the WeChat image to different sizes.
102+
103+
It is a great example for demonstrating how do we translate the TypeScript to Scala in Wechaty Way:
104+
105+
### Image Class Source Code
106+
107+
- TypeScript: <https://github.com/wechaty/wechaty/blob/master/src/user/image.ts>
108+
- Scala: <https://github.com/wechaty/scala-wechaty/blob/master/wechaty/src/main/scala/wechaty/user/Image.scala>
109+
110+
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 Scala at the same time.
111+
112+
## To-do List
113+
114+
- TS: TypeScript
115+
- SLOC: Source Lines Of Code
116+
117+
### Wechaty Internal Modules
118+
119+
1. [ ] Class Wechaty @wj-mCat
120+
- TS SLOC(1160): <https://github.com/wechaty/wechaty/blob/master/src/wechaty.ts>
121+
- [ ] Code
122+
- [ ] Unit Tests
123+
- [ ] Documentation
124+
1. [ ] Class Contact
125+
- TS SLOC(804): <https://github.com/wechaty/wechaty/blob/master/src/user/contact.ts>
126+
- [ ] Code
127+
- [ ] Unit Tests
128+
- [ ] Documentation
129+
1. [ ] Class ContactSelf
130+
- TS SLOC(199): <https://github.com/wechaty/wechaty/blob/master/src/user/contact-self.ts>
131+
- [ ] Code
132+
- [ ] Unit Tests
133+
- [ ] Documentation
134+
1. [ ] Class Message
135+
- TS SLOC(1054): <https://github.com/wechaty/wechaty/blob/master/src/user/message.ts>
136+
- [ ] Code
137+
- [ ] Unit Tests
138+
- [ ] Documentation
139+
1. [ ] Class Room
140+
- TS SLOC(1194): <https://github.com/wechaty/wechaty/blob/master/src/user/room.ts>
141+
- [ ] Code
142+
- [ ] Unit Tests
143+
- [ ] Documentation
144+
1. [ ] Class Image @wj-mCat
145+
- TS SLOC(60): <https://github.com/wechaty/wechaty/blob/master/src/user/image.ts>
146+
- [ ] Code
147+
- [ ] Unit Tests
148+
- [ ] Documentation
149+
1. [x] Class Accessory @huan
150+
- TS SLOC(179): <https://github.com/wechaty/wechaty/blob/master/src/accessory.ts>
151+
- [x] Code
152+
- [x] Unit Tests
153+
- [ ] Documentation
154+
1. [ ] Class Config @wj-mCat
155+
- TS SLOC(187): <https://github.com/wechaty/wechaty/blob/master/src/config.ts>
156+
- [ ] Code
157+
- [ ] Unit Tests
158+
- [ ] Documentation
159+
1. [ ] Class Favorite
160+
- TS SLOC(52): <https://github.com/wechaty/wechaty/blob/master/src/user/favorite.ts>
161+
- [ ] Code
162+
- [ ] Unit Tests
163+
- [ ] Documentation
164+
1. [ ] Class Friendship
165+
- TS SLOC(417): <https://github.com/wechaty/wechaty/blob/master/src/user/friendship.ts>
166+
- [ ] Code
167+
- [ ] Unit Tests
168+
- [ ] Documentation
169+
1. [ ] Class MiniProgram
170+
- TS SLOC(70): <https://github.com/wechaty/wechaty/blob/master/src/user/mini-program.ts>
171+
- [ ] Code
172+
- [ ] Unit Tests
173+
- [ ] Documentation
174+
1. [ ] Class RoomInvitation
175+
- TS SLOC(317): <https://github.com/wechaty/wechaty/blob/master/src/user/room-invitation.ts>
176+
- [ ] Code
177+
- [ ] Unit Tests
178+
- [ ] Documentation
179+
1. [ ] Class Tag
180+
- TS SLOC(190): <https://github.com/wechaty/wechaty/blob/master/src/user/tag.ts>
181+
- [ ] Code
182+
- [ ] Unit Tests
183+
- [ ] Documentation
184+
1. [ ] Class UrlLink
185+
- TS SLOC(107): <https://github.com/wechaty/wechaty/blob/master/src/user/url-link.ts>
186+
- [ ] Code
187+
- [ ] Unit Tests
188+
- [ ] Documentation
189+
190+
### Wechaty External Modules
191+
192+
1. [ ] Class FileBox
193+
- TS SLOC(638): <https://github.com/huan/file-box/blob/master/src/file-box.ts>
194+
- [ ] Code
195+
- [ ] Unit Tests
196+
- [ ] Documentation
197+
1. [ ] Class MemoryCard
198+
- TS SLOC(376): <https://github.com/huan/memory-card/blob/master/src/memory-card.ts>
199+
- [ ] Code
200+
- [ ] Unit Tests
201+
- [ ] Documentation
202+
1. [ ] Class WechatyPuppet
203+
- TS SLOC(1115): <https://github.com/wechaty/wechaty-puppet/blob/master/src/puppet.ts>
204+
- [ ] Code
205+
- [ ] Unit Tests
206+
- [ ] Documentation
207+
1. [ ] Class WechatyPuppetHostie
208+
- TS SLOC(909): <https://github.com/wechaty/wechaty-puppet-hostie/blob/master/src/grpc/puppet-client.ts>
209+
- [ ] Code
210+
- [ ] Unit Tests
211+
- [ ] Documentation
212+
213+
## Usage
214+
215+
[![Scala Wechaty Getting Started](https://img.shields.io/badge/Scala%20Wechaty-Getting%20Started-red)](https://github.com/wechaty/scala-wechaty-getting-started)
216+
217+
Scala Wechaty is very easy to use!
218+
219+
## Requirements
220+
221+
1. Scala 2.13+
222+
223+
## Development
224+
225+
```shell
226+
git clone [email protected]:wechaty/scala-wechaty.git
227+
228+
export WECHATY_PUPPET_HOSTIE_TOKEN=your_token_here
229+
make bot
230+
```
231+
232+
## History
233+
234+
### master
235+
236+
### v0.0.1 (Jun 3, 2020)
237+
238+
Thanks for our community contributor [@jcai](https://github.com/jcai/) Jun Tsai, who is a very experienced Scala developer, start from scratch three days ago (Jun 1) and finished the first version for ding-dong-bot.scala on two days ago, which only last 1 days for all the translation tasks!
239+
240+
#### One day
241+
242+
Only one day! This is the fastest record in the world for translating the TypeScript Wechaty to Multi-language Wechaty, Scala in this case. Cheers!
243+
244+
## Related Projects
245+
246+
- [Wechaty](https://github.com/wechaty/wechaty) - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript)
247+
- [Python Wechaty](https://github.com/wechaty/python-wechaty) - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python)
248+
- [Go Wechaty](https://github.com/wechaty/go-wechaty) - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go)
249+
- [Java Wechaty](https://github.com/wechaty/java-wechaty) - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java)
250+
- [Scala Wechaty](https://github.com/wechaty/scala-wechaty) - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala)
251+
252+
## Author
253+
254+
[@jcai](https://github.com/jcai/) Jun Tsai <[email protected]>
255+
256+
## Copyright & License
257+
258+
- Code & Docs © 2020 Wechaty Contributors <https://github.com/wechaty>
259+
- Code released under the Apache-2.0 License
260+
- Docs released under Creative Commons

README.txt

-4
This file was deleted.

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.2

docs/images/scala-wechaty.png

82.9 KB
Loading

0 commit comments

Comments
 (0)