Polyglot Wechaty
Wechaty Polyglot
Wechaty has the world's shortest lines code of chatbot in all programming languages!.This section gives an overview of implementing in different programming languages.Wechaty in all programming languages have the same API, as the TypeScript documented version.
If you are a total beginner to Wechaty, this project is the best starting point for you. You can run it on a Cloud IDE in a couple of steps or locally on your machine. Features of Wechaty Getting Started project
- It works in all operating systems like Linux, Mac or Windows.
- It Supports all puppets like Web, Pad, Windows, and Mac.
- It replies with a
dong
message whenever it receives ading
message.
Running Wechaty Getting Started Project on a cloud-based IDE
The fastest way to get started with Wechaty is to use a Cloud-based IDE for running the Wechaty Getting Started Project. You can either use Gitpod or Google Cloud Shell. If you are a total beginner, then we recommend Gitpod.
Getting Started Templates
- OpenAPI
- TypeScript
- JavaScript
- Python
- Go
- Java
- PHP
- Scala
- C#
- Rust
# git clone git@github.com:wechaty/openapi-wechaty-getting-started.git
# cd openapi-wechaty-getting-started
# To be added
GitHub: https://github.com/wechaty/openapi-wechaty-getting-started
git clone git@github.com:wechaty/wechaty-getting-started.git
cd wechaty-getting-started
git clone git@github.com:wechaty/wechaty-getting-started.git
cd wechaty-getting-started
git clone git@github.com:wechaty/python-wechaty-getting-started.git
cd python-wechaty-getting-started
GitHub: https://github.com/wechaty/python-wechaty-getting-started
git clone git@github.com:wechaty/go-wechaty-getting-started.git
cd go-wechaty-getting-started
GitHub: https://github.com/wechaty/go-wechaty-getting-started
git clone git@github.com:wechaty/java-wechaty-getting-started.git
cd java-wechaty-getting-started
GitHub: https://github.com/wechaty/java-wechaty-getting-started
git clone git@github.com:wechaty/php-wechaty-getting-started.git
cd php-wechaty-getting-started
GitHub: https://github.com/wechaty/php-wechaty-getting-started
git clone git@github.com:wechaty/scala-wechaty-getting-started.git
cd scala-wechaty-getting-started
GitHub: https://github.com/wechaty/scala-wechaty-getting-started
git clone git@github.com:wechaty/csharp-wechaty-getting-started.git
cd csharp-wechaty-getting-started
GitHub: https://github.com/wechaty/csharp-wechaty-getting-started
git clone git@github.com:wechaty/rust-wechaty-getting-started.git
cd rust-wechaty-getting-started
GitHub: https://github.com/wechaty/rust-wechaty-getting-started
Install & Start
make install
make bot
Implementation of Chatbots in different languages
Check the below implementation of Wechaty bot in different languages.
- TypeScript
- JavaScript
- Python
- Go
- Java
- PHP
- Scala
- C#
- Rust
- OpenAPI
import { Wechaty } from 'wechaty'
async function main () {
const bot = new Wechaty()
bot
.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
.on('login', user => console.log(`User ${user} logged in`))
.on('message', message => console.log(`Message: ${message}`))
await bot.start()
}
main()
.catch(console.error)
import { Wechaty } from 'wechaty'
async function main () {
const bot = new Wechaty()
bot
.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
.on('login', user => console.log(`User ${user} logged in`))
.on('message', message => console.log(`Message: ${message}`))
await bot.start()
}
main()
.catch(console.error)
from wechaty import Wechaty
import asyncio
async def main():
bot = Wechaty()
bot.on('scan', lambda status, qrcode, data: print('Scan QR Code to login: {}\nhttps://wechaty.js.org/qrcode/{}'.format(status, qrcode)))
bot.on('login', lambda user: print('User {} logged in'.format(user)))
bot.on('message', lambda message: print('Message: {}'.format(message)))
await bot.start()
asyncio.run(main())
package main
import (
"fmt"
"github.com/wechaty/go-wechaty/wechaty"
)
func main() {
_ = wechaty.NewWechaty().
OnScan(func(qrCode, status string) {
fmt.Printf("Scan QR Code to login: %s\nhttps://wechaty.js.org/qrcode/%s\n", status, qrCode)
}).
OnLogin(func(user string) { fmt.Printf("User %s logged in\n", user) }).
OnMessage(func(message string) { fmt.Printf("Message: %s\n", message) }).
Start()
}
package io.github.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 logged in :" + user))
.onMessage(message -> System.out.println("Message:" + message))
.start(true);
}
}
$wechaty = \IO\Github\Wechaty\Wechaty::getInstance($token, $endPoint);
$wechaty->onScan(function($qrcode, $status, $data) {
$qr = \IO\Github\Wechaty\Util\QrcodeUtils::getQr($qrcode);
echo "$qr\n\nOnline Image: https://wechaty.js.org/qrcode/$qrcode\n";
})->onLogin(function(\IO\Github\Wechaty\User\ContactSelf $user) {
})->onMessage(function(\IO\Github\Wechaty\User\Message $message) {
$message->say("hello from PHP7.4");
})->start();
package wechaty
object DingDongBot {
def main(args: Array[String]): Unit = {
Wechaty.instance()
.onScan(payload => { println("Scan QR Code to login: %s\nhttps://wechaty.js.org/qrcode/%s\n".format(payload.status, payload.qrcode)) })
.onLogin(payload => { println("User %s logged in\n".format(payload.id)) })
.onMessage(message => { println(message) })
.start()
Thread.currentThread().join()
}
}
var wechaty = new Wechaty(options, logger).onScan((qrcode, status) => {
Console.WriteLine($"Scan QR Code to login: {status} https://wechaty.js.org/qrcode/{(qrcode)}`");
}).OnLogin( user => {
Console.WriteLine("User {user} logined");
}).OnMessage( message => {
Console.WriteLine($"Message: {message}");
}).Start();
let bot = Wechaty::new(PuppetService::new(options).await.unwrap());
bot.on_scan(handle_scan)
.on_login(handle_login)
.on_logout(handle_logout)
.on_message(handle_message)
.start()
.await;
# To be add: curl ...
Blogs
Here are some of the blogs related to latest Wechaty Beta releases and also some other helpful links.
- Multi Language Wechaty Beta Release Announcement!
- Getting Started Without Leaving Your Browser: Wechaty Gitpod, @huan, Feb 06, 2021
- Wechaty is All You Need: Python, Go, and Java Translation Project wechaty/wechaty#1927
- Python the Wechaty Way wechaty/python-wechaty#13
- Go Wechaty project initialized! wechaty/go-wechaty#1
Support
Gitter Channel
You can join our Gitter network if you aren’t already a member.
WeChat Rooms
We have Polyglot Wechaty User Group on WeChat, and we are always looking for new members.
Scan the above QR Code to add Friday BOT to your WeChat:
Then, send it one of the following message to join a specific language group:
Secret Code | Language Group |
---|---|
openapi wechaty | OpenAPI(Swagger/gRPC) Wechaty User Group |
python wechaty | Python Wechaty User Group |
java wechaty | Java Wechaty User Group |
go wechaty | Go Wechaty User Group |
dotnet wechaty | dotNet(.NET) Wechaty User Group |
rust wechaty | Rust Wechaty User Group |
php wechaty | PHP Wechaty User Group |
scala wechaty | scala Wechaty User Group |
typescript wechaty | TypeScript Wechaty User Group |