Home
Softono
w

wechaty

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
4

Software by wechaty

wechaty
Open Source

wechaty

# Wechaty [![Join Wechaty Discord Developer Community](https://img.shields.io/discord/916984413944967180?logo=discord&style=flat)](https://discord.gg/7q8NBZbQzt) [![NPM Version](https://img.shields.io/npm/v/wechaty?color=brightgreen)](https://www.npmjs.com/package/wechaty) [![NPM](https://github.com/wechaty/wechaty/workflows/NPM/badge.svg)](https://github.com/wechaty/wechaty/actions?query=workflow%3ANPM) [![Docker](https://github.com/wechaty/wechaty/workflows/Docker/badge.svg)](https://github.com/wechaty/wechaty/actions?query=workflow%3ADocker) [![Wechaty](https://wechaty.js.org/img/wechaty-logo.svg)](https://wechaty.js.org) [Ship.Fail](https://ship.fail) [PreAngel](https://PreAngel.AI) [![Downloads](https://img.shields.io/npm/dm/wechaty.svg?style=flat-square)](https://www.npmjs.com/package/wechaty) [![GitHub stars](https://img.shields.io/github/stars/wechaty/wechaty.svg?label=github%20stars)](https://github.com/wechaty/wechaty) [![Docker Pulls](https://img.shields.io/docker/pulls/wechaty/wechaty.svg?maxAge=2592000)](https://hub.docker.com/r/wechaty/wechaty/) [![ES Modules](https://img.shields.io/badge/ES-Modules-orange)](https://github.com/Chatie/tsconfig/issues/16) [![TypeScript](https://img.shields.io/badge/--3178C6?logo=typescript&logoColor=ffffff)](https://wechaty.js.org/docs/polyglot/typescript/) [![JavaScript](https://img.shields.io/badge/--F7DF1E?logo=javascript&logoColor=000)](https://wechaty.js.org/docs/polyglot/typescript/) [![Python](https://img.shields.io/badge/--3670A0?logo=python&logoColor=ffdd54)](https://wechaty.js.org/docs/polyglot/python/) [![Go](https://img.shields.io/badge/--00ADD8?logo=go&logoColor=white)](https://wechaty.js.org/docs/polyglot/go/) [![Java](https://img.shields.io/badge/--red?logo=java&logoColor=white)](https://wechaty.js.org/docs/polyglot/java/) [![.NET](https://img.shields.io/badge/--5C2D91?logo=dotnet&logoColor=white)](https://wechaty.js.org/docs/polyglot/dotnet/) [![PHP](https://img.shields.io/badge/--777BB4?logo=php&logoColor=white)](https://wechaty.js.org/docs/polyglot/php/) [![Rust](https://img.shields.io/badge/--000000?logo=rust&logoColor=white)](https://wechaty.js.org/docs/polyglot/rust/) [![Scala](https://img.shields.io/badge/--DC322F?logo=scala&logoColor=white)](https://wechaty.js.org/docs/polyglot/scala/) [![WeChat](https://img.shields.io/badge/--07C160?logo=wechat&logoColor=white)](https://wechaty.js.org/docs/puppet-providers/wechat) [![Whatsapp](https://img.shields.io/badge/--25D366?logo=whatsapp&logoColor=white)](https://wechaty.js.org/docs/puppet-providers/whatsapp) <!-- [![TikTok](https://img.shields.io/badge/--000000?logo=tiktok&logoColor=white)](https://wechaty.js.org/docs/puppet-providers/tiktok) [![Line](https://img.shields.io/badge/--00C300?logo=line&logoColor=white)](https://wechaty.js.org/docs/puppet-providers/line) [![Telegram](https://img.shields.io/badge/--2CA5E0?logo=telegram&logoColor=white)](https://wechaty.js.org/docs/puppet-providers/telegram) [![Gitter](https://badges.gitter.im/wechaty/wechaty.svg)](https://gitter.im/wechaty/wechaty?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter room](https://badgen.net/gitter/members/wechaty/wechaty)](https://gitter.im/wechaty/wechaty?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Telegram Wechaty Channel](https://img.shields.io/badge/chat-on%20telegram-blue)](https://t.me/wechaty) --> ## Elevator Pitch Wechaty is a conversational RPA SDK that simplifies the process of building chatbots. It's like a Swiss Army knife for chatbot development, providing a universal interface to various messaging platforms such as WhatsApp, WeChat, and more. With Wechaty, you write your bot code once, and it runs on any of the supported platforms. This means you can focus on creating engaging conversational experiences without worrying about the underlying complexities of each platform's API. It's open-source, easy to use, and backed by a vibrant community that's ready to help you bring your chatbot ideas to life. ## Connecting Chatbots Wechaty is an RPA (Robotic Process Automation) SDK for Chatbot Makers which can help you create a bot in 6 lines of [JavaScript](https://GitHub.com/Wechaty/wechaty), [Python](https://GitHub.com/Wechaty/python-wechaty/), [Go](https://GitHub.com/Wechaty/go-wechaty/), and [Java](https://GitHub.com/Wechaty/java-wechaty/), with cross-platform support including [Linux, Windows, MacOS](https://github.com/wechaty/wechaty/actions?query=workflow%3ANPM), and [Docker](https://github.com/wechaty/wechaty/actions?query=workflow%3ADocker). :spider_web: <https://wechaty.js.org> :octocat: <https://github.com/Wechaty/wechaty> :beetle: <https://github.com/Wechaty/wechaty/issues> :book: <https://github.com/Wechaty/wechaty-getting-started> :whale: <https://hub.docker.com/r/wechaty/wechaty> ## Breaking News - [重磅:绕过登录限制,wechaty免费版web协议重放荣光, @gengchen528, Apr 13, 2021](https://wechaty.js.org/2021/04/13/wechaty-uos-web/) ## Voice of Developers > "Wechaty is a great solution; I believe there would be much more users who recognize it." [link](https://github.com/Wechaty/wechaty/pull/310#issuecomment-285574472) > &mdash; <cite>@Gcaufy, Tencent Engineer, Author of [WePY](https://github.com/Tencent/wepy)</cite> > > "太好用,好用的想哭" > &mdash; <cite>@xinbenlv, Google Engineer, Founder of HaoShiYou.org</cite> > > ”好用到哭“——你们对得起这个评价! [link](https://github.com/bigbrother666sh/shezhangbujianle#%E8%87%B4%E6%95%AC) > &mdash; <cite>[@bigbrother666sh](https://github.com/bigbrother666sh), creator of《社长不见了》剧本杀 NPC DM</cite> > > "最好的微信开发库" [link](http://weibo.com/3296245513/Ec4iNp9Ld?type=comment) > &mdash; <cite>@Jarvis, Baidu Engineer</cite> > > "Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" [link](http://mp.weixin.qq.com/s/dWHAj8XtiKG-1fIS5Og79g) > &mdash; <cite>@lijiarui, Founder & CEO of Juzi.BOT.</cite> > > "If you know js ... try Wechaty. It's easy to use." > &mdash; <cite>@Urinx Uri Lee, Author of [WeixinBot(Python)](https://github.com/Urinx/WeixinBot)</cite> > > "Wechaty is a good project; I hope it can continue! Therefore, I became a contributor in open collective." > &mdash; <cite>[@Simple](https://github.com/mrwhh)</cite> See more at [Wiki:Voice Of Developer](https://github.com/Wechaty/wechaty/wiki/Voice%20Of%20Developer) ### Join Us on Discord [![Join Wechaty Discord Developer Community](https://img.shields.io/discord/916984413944967180?logo=discord&style=flat)](https://discord.gg/7q8NBZbQzt) [![Wechaty Discord](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdiscord.com%2Fapi%2Finvites%2F7q8NBZbQzt%3Fwith_counts%3Dtrue&query=%24.approximate_member_count&logo=discord&logoColor=white&label=Users%20Total&color=green&style=flat)](https://discord.gg/7q8NBZbQzt) Wechaty is used in many ChatBot projects by thousands of developers. To talk with other developers, scan the QR Code below and join our **Wechaty Developer Community**. ![Wechaty Discord Community QR Code](https://wechaty.js.org/img/discord-qrcode.svg) Scan now because other Wechaty developers want to talk with you, too! ### Resource Wechaty has already held lots of talks and got a lot of blogs in the past years; here are all of the wechaty resources: - :video_camera: [Youtube Playlist: Watch all of the talk videos related with Wechaty](https://www.youtube.com/playlist?list=PL8hd9KDTdarDXf_Rxtr8meKhxtgcXMInh) - :page_with_curl: [Full Docs](https://wechaty.js.org/) - :bulb: [Blog: See how developers use wechaty to build fantastic projects!](https://wechaty.github.io/) - :beginner: [Wechaty-Getting-Started:Wechaty Starter Project Template that Works Out-of-the-Box](https://github.com/wechaty/wechaty-getting-started) - :tada: [Wechaty Contributor List: Thanks for their contribution!](https://github.com/wechaty/wechaty/wiki/Contributors) - :gift: [Juzibot Support Wechaty: Know everything about Wechaty](https://github.com/juzibot/Welcome/wiki/Everything-about-Wechaty) ## :rocket: The World's Shortest ChatBot Code: 6 lines of JavaScript ```javascript import { WechatyBuilder } from 'wechaty' const wechaty = WechatyBuilder.build() // get a Wechaty instance wechaty .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}`)) wechaty.start() ``` > **Notice: Wechaty requires Node.js version >= 16** This bot can log all messages to the console after login by the scan. You can find Wechaty's Official Examples at [examples/ding-dong-bot.ts](examples/ding-dong-bot.ts) and more from our [Example Directory](https://github.com/Wechaty/wechaty-getting-started/blob/main/examples/). ## :checkered_flag: Requirements 1. Node.js version 16+ 1. NPM version 7+ 1. TypeScript version 4.4+ ## Getting Started [![node](https://img.shields.io/node/v/wechaty.svg?maxAge=604800)](https://nodejs.org/) - Wechaty Starter Repository - <https://github.com/wechaty/wechaty-getting-started> We have a Wechaty starter repository for beginners with the simplest setting. It will be **work** out-of-the-box after you `clone` & `npm install` & `npm start`. If you are new to Wechaty and want to try it the first time, we'd like to strong recommend you starting from this repository, and using it as your starter template for your project. Otherwise, please saved the above _The World's Shortest ChatBot Code: 6 lines of JavaScript_ example to a file named `bot.js` before you can use either NPM or Docker to run it. ### 1. Npm [![NPM Version](https://img.shields.io/npm/v/wechaty?color=brightgreen&label=wechaty%40latest)](https://www.npmjs.com/package/wechaty) [![npm (tag)](https://img.shields.io/npm/v/wechaty/next?color=yellow&label=wechaty%40next)](https://www.npmjs.com/package/wechaty?activeTab=versions) [![Downloads](https://img.shields.io/npm/dm/wechaty.svg?style=flat-square)](https://www.npmjs.com/package/wechaty) [![install size](https://packagephobia.now.sh/badge?p=wechaty)](https://packagephobia.now.sh/result?p=wechaty) ```shell npm init npm install wechaty # create your first bot.js file, you can copy/paste from the above "The World's Shortest ChatBot Code: 6 lines of JavaScript" # then: node bot.js ``` ### 2. Docker [![Docker Pulls](https://img.shields.io/docker/pulls/wechaty/wechaty.svg?maxAge=2592000)](https://hub.docker.com/r/wechaty/wechaty/) [![Docker Layers](https://images.microbadger.com/badges/image/wechaty/wechaty.svg)](https://microbadger.com/#/images/wechaty/wechaty) - Wechaty Starter Repository for Docker - <https://github.com/wechaty/docker-wechaty-getting-started> > Wechaty Docker supports both JavaScript and TypeScript. To use TypeScript just write in TypeScript and save with extension name `.ts`, no need to compile because we use `ts-node` to run it. 2.1. Run JavaScript ```shell # for JavaScript docker run -ti --rm --volume="$(pwd)":/bot wechaty/wechaty bot.js ``` 2.2. Run TypeScript ```shell # for TypeScript docker run -ti --rm --volume="$(pwd)":/bot wechaty/wechaty bot.ts ``` > Learn more about Wechaty Docker at [Wiki:Docker](https://github.com/Wechaty/wechaty/wiki/Docker). ### 3. Switch Protocol(Puppet) Wechaty is very powerful that it can run over different protocols. You can specify the protocol by set the environment variable `WECHATY_PUPPET` to different puppet provider. If you cannot use Web protocol, you can apply other protocols following the instruction here: <https://github.com/wechaty/wechaty/wiki/Support-Developers> We provide free token to support developers build a valuable WeChat chatbot. Currently we support the following [puppet providers](https://wechaty.js.org/docs/puppet-services/) : | Protocol | Puppet Provider | Environment Variable | | --- | --- | --- | | Web | [PuppetPuppeteer](https://github.com/wechaty/wechaty-puppet-puppeteer) | `export WECHATY_PUPPET=wechaty-puppet-puppeteer` | | Windows | [PuppetWorkPro](https://github.com/RPAChat/workpro-getting-started) | `export WECHATY_PUPPET=wechaty-puppet-service` | | Mock | [PuppetMock](https://github.com/wechaty/wechaty-puppet-mock) | `export WECHATY_PUPPET=wechaty-puppet-mock` | | Web | [PuppetWechat4u](https://github.com/wechaty/wechaty-puppet-wechat4u) | `export WECHATY_PUPPET=wechaty-puppet-wechat4u` | | iPad | [PuppetRock](https://github.com/wechaty/puppet-service-providers) | `export WECHATY_PUPPET=wechaty-puppet-service` | | iPad | [PuppetPadLocal](https://github.com/wechaty/puppet-service-providers) | `export WECHATY_PUPPET=wechaty-puppet-service` | | Windows | [PuppetDonut](https://github.com/wechaty/puppet-service-providers) | `export WECHATY_PUPPET=wechaty-puppet-service` | | iPad | ~~PuppetPadpro~~ **DEPRECATED** | `export WECHATY_PUPPET=wechaty-puppet-padpro` | | iPad | ~~PuppetPadchat~~ **DEPRECATED** | `export WECHATY_PUPPET=wechaty-puppet-padchat` | | iPad | ~~PuppetPadplus~~ **DEPRECATED** | `export WECHATY_PUPPET=wechaty-puppet-padplus` | | Mac | ~~PuppetMacpro~~ **DEPRECATED** | `export WECHATY_PUPPET=wechaty-puppet-macpro` | | Windows | ~~PuppetWxwork~~ **DEPRECATED** | `export WECHATY_PUPPET=wechaty-puppet-service` | Learn more about Wechaty Puppet from the Puppet Wiki: 1. Puppet Directory: <https://github.com/Wechaty/wechaty-puppet/wiki/Directory> 1. Puppet Compatibility: <https://github.com/Wechaty/wechaty-puppet/wiki/Compatibility> ## :guitar: API Read the Full Documentation at [Wechaty Official API Reference](https://wechaty.github.io/wechaty/) ### 1 Class `Wechaty` Main bot class. A `Bot` is a Wechaty instance that control a specific [wechaty-puppet](https://wechaty.js.org/docs/specifications/puppet/). - `new Wechaty(options?: WechatyOptions)` 1. `options.name?: string` the name of this bot(optional) 2. `options.puppet?: string` select which puppet provider we want to use. must be one of the: 1. [wechaty-puppet-wechat](https://github.com/Wechaty/wechaty-puppet-wechat) - Angular Hook for Web Wechat 2. [wechaty-puppet-wechat4u](https://github.com/Wechaty/wechaty-puppet-wechat4u) - HTTP API for Web Wechat 3. [wechaty-puppet-padpro](https://github.com/botorange/wechaty-puppet-padpro) - iPad App Protocol 4. [wechaty-puppet-ioscat](https://github.com/linyimin-bupt/wechaty-puppet-ioscat) - iPhone App Hook 5. [wechaty-puppet-mock](https://github.com/Wechaty/wechaty-puppet-mock) - Mock for Testing 3. `options.puppetOptions?: PuppetOptions` options for the puppet provider. | Wechaty | API | Description | | :--- | :--- | :--- | | event | [`login`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit after bot login full successful | | event | [`logout`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit after the bot log out | | event | [`friendship`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when someone sends bot a friend request| | event | [`message`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when there's a new message | | event | [`room-join`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when anyone join any room | | event | [`room-topic`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when someone change room topic | | event | [`room-leave`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when anyone leave the room | | event | [`room-invite`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when there is a room invitation | | event | [`scan`](https://wechaty.github.io/wechaty/#Wechaty+on) | emit when the bot needs to show you a QR Code for scanning | | method | [`start(): Promise<void>`](https://wechaty.github.io/wechaty/#Wechaty+start) | start the bot | | method | [`stop(): Promise<void>`](https://wechaty.github.io/wechaty/#Wechaty+stop) | stop the bot | | method | [`logonoff(): boolean`](https://wechaty.github.io/wechaty/#Wechaty+logonoff) | bot login status | | method | [`logout(): Promise<void>`](https://wechaty.github.io/wechaty/#Wechaty+logout) | logout the bot | | method | [`currentUser(): ContactSelf`](https://wechaty.github.io/wechaty/#Wechaty+currentUser) | get the login-ed bot contact | | method | [`say(text: string): Promise<void>`](https://wechaty.github.io/wechaty/#Wechaty+say) | let bot say `text` to itself | ### 2 Class `Contact` All wechat contacts(friends/non-friends) will be encapsulated as a Contact. | Contact | API | Description | | :--- | :--- | :--- | | static | [`find(query: string): Promise<null \| Contact>`](https://wechaty.github.io/wechaty/#Contact.find) | find contact by name or alias, if the result more than one, return the first one. | | static | [`findAll(query: string): Promise<Contact[]>`](https://wechaty.github.io/wechaty/#Contact.findAll) | find contact by `name` or `alias` | | static | [`load(query: string): Contact`](https://wechaty.github.io/wechaty/#Contact.load) | get contact by id | | property | `id: readonly string` | get contact id | | method | [`sync(): Promise<void>`](https://wechaty.github.io/wechaty/#Contact+sync) | force reload data for contact , sync data from lowlevel API again| | method | [`say(text: string): Promise<void \| Message>`](https://wechaty.github.io/wechaty/#Contact+say) | send text, Contact, or file to contact, return the message which the bot sent (only `puppet-padplus` supported). | | method | [`self(): boolean`](https://wechaty.github.io/wechaty/#Contact+self) | check if contact is self | | method | [`name(): string`](https://wechaty.github.io/wechaty/#Contact+name) | get the name from a contact | | method | [`alias(): Promise<string>`](https://wechaty.github.io/wechaty/#Contact+alias) | get the alias for a contact | | method | [`alias(newAlias: string): Promise<void>`](https://wechaty.github.io/wechaty/#Contact+alias) | set or delete the alias for a contact | | method | [`friend(): boolean`](https://wechaty.github.io/wechaty/#Contact+friend) | check if contact is friend | | method | [`type(): ContactType`](https://wechaty.github.io/wechaty/#Contact+type) | return the type of the Contact | | method | [`province(): string`](https://wechaty.github.io/wechaty/#Contact+province) | get the region 'province' from a contact | | method | [`city(): string`](https://wechaty.github.io/wechaty/#Contact+city) | get the region 'city' from a contact | | method | [`avatar(): Promise<FileBox>`](https://wechaty.github.io/wechaty/#Contact+avatar) | get avatar picture file stream | | method | [`gender(): ContactGender`](https://wechaty.github.io/wechaty/#Contact+gender) | get gender from a contact | #### 2.1 Class `ContactSelf` Class `ContactSelf` is extended from `Contact`. | ContactSelf | API | Description | | :--- | :--- | :--- | | method | [`avatar(file: FileBox): Promise<void>`](https://wechaty.github.io/wechaty/#ContactSelf+avatar) | set avatar for bot | | method | [`qrcode(): Promise<string>`](https://wechaty.github.io/wechaty/#ContactSelf+qrcode) | get qrcode for bot | | method | [`signature(text: string): Promise<void>`](https://wechaty.github.io/wechaty/#ContactSelf+signature) | set signature for bot | #### 2.2 Class `Friendship` Send, receive friend request, and friend confirmation events. | Friendship | API | Description | | :--- | :--- | :--- | | static | [`add(contact: Contact, hello?: string): Promise<void>`](https://wechaty.github.io/wechaty/#Friendship.add) | send a friend invitation to contact | | method | [`accept(): Promise<void>`](https://wechaty.github.io/wechaty/#Friendship+accept) | accept Friend Request | | method | [`hello(): string`](https://wechaty.github.io/wechaty/#Friendship+hello) | get the hello string from a friendship invitation | | method | [`contact(): Contact`](https://wechaty.github.io/wechaty/#Friendship+contact) | get the contact from friendship | | method | [`type(): FriendshipType`](https://wechaty.github.io/wechaty/#Friendship+type) | return the Friendship Type(unknown, confirm, receive, verify) | ### 3 Class `Message` All wechat messages will be encapsulated as a Message. | Message | API | Description | | :--- | :--- | :--- | | static | [`find(query: string): Promise<null \| Message>`](https://wechaty.github.io/wechaty/#Message.find) | find message in cache and return the first one | | static | [`findAll(query: string): Promise<Message[]>`](https://wechaty.github.io/wechaty/#Message.findAll) | find messages in cache, return a message list | | method | [`from(): Contact`](https://wechaty.github.io/wechaty/#Message+from) | get the sender from a message | | method | [`to(): Contact`](https://wechaty.github.io/wechaty/#Message+to) | get the destination of the message | | method | [`room(): null \| Room`](https://wechaty.github.io/wechaty/#Message+room) | get the room from the message.(If the message is not in a room, then will return `null`) | | method | [`text(): string`](https://wechaty.github.io/wechaty/#Message+text) | get the text content of the message | | method | [`say(text: string): Promise<void \| Message>`](https://wechaty.github.io/wechaty/#Message+say) | reply a Text, Media File , or contact message to the sender, return the message which the bot sent (only `puppet-padplus` supported). | | method | [`type(): MessageType`](https://wechaty.github.io/wechaty/#Message+type) | get the type from the message | | method | [`self(): boolean`](https://wechaty.github.io/wechaty/#Message+self) | check if a message is sent by self | | method | [`mention(): Contact[]`](https://wechaty.github.io/wechaty/#Message+mention) | get message mentioned contactList. | | method | [`mentionSelf(): boolean`](https://wechaty.github.io/wechaty/#Message+mentionSelf) | check if a message is mention self | | method | [`forward(to: Contact): Promise<void>`](https://wechaty.github.io/wechaty/#Message+forward) | Forward the received message | | method | [`age(): number`](https://wechaty.github.io/wechaty/#Message+age) | the number of seconds since it has been created | | method | [`date(): Date`](https://wechaty.github.io/wechaty/#Message+date) | the time it was created | | method | [`toFileBox(): Promise<FileBox>`](https://wechaty.github.io/wechaty/#Message+toFileBox) | extract the Media File from the Message, and put it into the FileBox. | | method | [`toContact(): Promise<Contact>`](https://wechaty.github.io/wechaty/#Message+toContact) | get Share Card of the Message | ### 4 Class `Room` All wechat rooms(groups) will be encapsulated as a Room. | Room | API | Description | | :--- | :--- | :--- | | static | [`create(contactList: Contact[], topic?: string): Promise<Room>`](https://wechaty.github.io/wechaty/#Room.create) | create a new room | | static | [`find(query: string): Promise<null \| Room>`](https://wechaty.github.io/wechaty/#Room.find) | Try to find a room by filter. If get many, return the first one. | | static | [`findAll(query: string): Promise<Room[]>`](https://wechaty.github.io/wechaty/#Room.findAll) | Find all contacts in a room | | static | [`load(query: string): Room`](https://wechaty.github.io/wechaty/#Room.load) | load room by room id | | property | `id: readonly string` | | | event | [`join`](https://wechaty.github.io/wechaty/#Room+on) | emit when anyone join any room | | event | [`topic`](https://wechaty.github.io/wechaty/#Room+on) | emit when someone change room topic | | event | [`leave`](https://wechaty.github.io/wechaty/#Room+on) | emit when anyone leave the room | | event | [`invite`](https://wechaty.github.io/wechaty/#Room+on) | emit when receive a room invitation | | method | [`sync(): <Promise<void>`](https://wechaty.github.io/wechaty/#Room+sync) | force reload data for room, sync data from lowlevel API again. | method | [`say(text: string): Promise<void \| Message>`](https://wechaty.github.io/wechaty/#Room+say) | Send text,media file, contact card, or text with mention @mention contact inside Room, return the message which the bot sent (only `puppet-padplus` supported). | | method | [`add(contact: Contact): Promise<void>`](https://wechaty.github.io/wechaty/#Room+add) | Add contact in a room | | method | [`del(contact: Contact): Promise<void>`](https://wechaty.github.io/wechaty/#Room+del) | Delete a contact from the room | | method | [`quit(): Promise<void>`](https://wechaty.github.io/wechaty/#Room+quit) | Bot quit the room itself | | method | [`topic(): Promise<string>`](https://wechaty.github.io/wechaty/#Room+topic) | GET topic from the room | | method | [`topic(newTopic: string): Promise<void>`](https://wechaty.github.io/wechaty/#Room+topic) | SET topic from the room | | method | [`announce(text: string): Promise<void>`](https://wechaty.github.io/wechaty/#Room+announce) | SET/GET announce from the room | | method | [`qrcode(): Promise<string>`](https://wechaty.github.io/wechaty/#Room+qrcode) | Get QR Code of the Room from the room, which can be used as scan and join the room. | | method | [`alias(contact: Contact): Promise<string>`](https://wechaty.github.io/wechaty/#Room+alias) | Return contact's roomAlias in the room | | method | [`roomAlias(contact: Contact): Promise<string \| null>`](https://wechaty.github.io/wechaty/#Room+roomAlias) | Same as function alias | | method | [`has(contact: Contact): Promise<boolean>`](https://wechaty.github.io/wechaty/#Room+has) | Check if the room has member `contact` | | method | [`memberAll(query?: string): Promise<Contact[]>`](https://wechaty.github.io/wechaty/#Room+memberAll) | Find all contacts or with specific name in a room | | method | [`member(query: string): Promise<null \| Contact>`](https://wechaty.github.io/wechaty/#Room+member) | Find all contacts in a room, if get many, return the first one. | | method | [`memberList():Promise<Contact[]>`](https://wechaty.github.io/wechaty/#Room+memberList) | get all room member from the room | | method | [`owner(): null \| Contact`](https://wechaty.github.io/wechaty/#Room+owner) | Get room's owner from the room. | #### 4.1 Class `RoomInvitation` Accept room invitation | RoomInvitation | API | Description | | :--- | :--- | :--- | | method | [`accept(): Promise<void>`](https://wechaty.github.io/wechaty/#RoomInvitation+accept) | accept Room Invitation | | method | [`inviter(): Contact`](https://wechaty.github.io/wechaty/#RoomInvitation+inviter) | get the inviter from room invitation | | method | [`roomTopic(): Promise<string>`](https://wechaty.github.io/wechaty/#RoomInvitation+inviter) | get the room topic from room invitation | | method | [`date(): Promise<Date>`](https://wechaty.github.io/wechaty/#RoomInvitation+date) | the time it was created | | method | [`age(): Promise<number>`](https://wechaty.github.io/wechaty/#RoomInvitation+age) | the number of seconds since it has been created | ## TEST [![NPM](https://github.com/wechaty/wechaty/workflows/NPM/badge.svg)](https://github.com/wechaty/wechaty/actions?query=workflow%3ANPM) [![Docker](https://github.com/wechaty/wechaty/workflows/Docker/badge.svg)](https://github.com/wechaty/wechaty/actions?query=workflow%3ADocker) [![Coverage Status](https://coveralls.io/repos/github/wechaty/wechaty/badge.svg?branch=main)](https://coveralls.io/github/wechaty/wechaty?branch=main) [![Known Vulnerabilities](https://snyk.io/test/github/Wechaty/wechaty/badge.svg)](https://snyk.io/test/github/Wechaty/wechaty) Wechaty is fully automatically tested by unit and integration tests, with Continuous Integration & Continuous Delivery (CI/CD) support powered by CI like Travis, Shippable and Appveyor. To test Wechaty, run: ```shell npm test ``` Get to know more about the tests from [Wiki:Tests](https://github.com/Wechaty/wechaty/wiki/Tests) ## CREATING WECHATY PLUGIN Creating and publishing a Wechaty Plugin is simple. Simply expose your module as a function that takes 1 parameter: wechaty. When your plugin is imported by Wechaty, it will pass itself in as the argument, and so you are free to add any configuration that Wechaty supports. ```ts import { WechatyPlugin } from 'wechaty' export default const MyPlugin: WechatyPlugin = (wechaty: Wechaty) => { // ... } ``` The `config` exist so the user can pass in customizations to your Plugin. In documenting your Wechaty Plugin, you would lay out your supported config for the user. See: 1. [Wechaty Plugin Support with KickOut Example #1939](https://github.com/wechaty/wechaty/issues/1939) 1. [Wechaty Plugins Contrib](https://github.com/wechaty/wechaty-plugin-contrib) ## :pencil: RELEASE NOTES - [Latest Release](https://github.com/Wechaty/wechaty/releases/latest)(All releases [here](https://github.com/Wechaty/wechaty/releases)) - [Changelog](https://github.com/Wechaty/wechaty/blob/main/CHANGELOG.md) ### :saxophone: Views Since Feb 15, 2019 [![HitCount](http://hits.dwyl.io/wechaty/wechaty.svg)](http://hits.dwyl.io/wechaty/wechaty) ## :sparkling_heart: POWERED BY WECHATY [![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://wechaty.js.org) ### :sparkles: Wechaty Badge ```markdown [![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://wechaty.js.org) ``` Get more embed html/markdown code from [Wiki:Badge](https://github.com/wechaty/wechaty/wiki/Badge) ### :star2: Projects Using Wechaty 1. [一个用CNN深度神经网络给图片评分的wechaty项目](https://github.com/huyingxi/wechaty_selfie) 2. [Relay between Telegram and WeChat](https://github.com/Firaenix/TeleChatRelay) 3. [A chat bot managing the HaoShiYou wechat groups run by volunteers of haoshiyou.org](https://github.com/xinbenlv/haoshiyou-bot) 4. [An interactive chat bot to manage a TODO list](https://github.com/coderbunker/candobot) 5. [Forward WeChat messages to telegram](https://github.com/luosheng/Wegram) 6. [koa与wechaty实现的微信小助手,可定时提醒与发消息设定定时任务](https://github.com/gengchen528/wechat-assistant) 7. [Wechaty Pay - 让线上没有难做的生意](https://github.com/coderwhocode/wechaty-pay) 8. [开源社的微信机器人项目](https://github.com/kaiyuanshe/wechat-robot) Pull Request is welcome to add yours! Learn more about Projects Using Wechaty at [Wiki:Projects Using Wechaty](https://github.com/wechaty/wechaty/wiki/Projects-Using-Wechaty) ## :innocent: Find a Good Server The best practice for running Wechaty Docker/NPM is using a VPS(Virtual Private Server) outside of China, which can save you hours of time because `npm install` and `docker pull` will run smoothly without any problem. The following VPS providers are used by the Wechaty team, and they worked perfectly in production. You can use the following link to get one in minutes. Also, doing this can support Wechaty because you are referred by us. | Location | Price | Ram | Payment | Provider | | --- | --- | --- | --- | --- | | Singapore | $5 | 512MB | Paypal | [DigitalOcean](https://m.do.co/c/01a54778df5c) | | Japan | $5 | 1GB | Paypal | [Linode](https://www.linode.com/?r=5fd2b713d711746bb5451111df0f2b6d863e9f63) | | Korea | $10 | 1GB | Alipay, Paypal | [Netdedi](https://www.netdedi.com/?affid=35) | | Singapore | $3.5 | 512MB | Alipay, Wechat | [Vultr](https://www.vultr.com/?ref=6986613) | ## :notes: See Also - [RelatedProject](https://github.com/Wechaty/wechaty/wiki/RelatedProject) ## :poop: The Story In 2017 ... Huan's daily life/work depends on too much chat on wechat. - Almost 14,000 wechat friends in May 2014, before wechat restricts a total number of friends to 5,000. - Almost 400 wechat rooms, and most of them have more than 400 members. Can you imagine that? He was dying... So a tireless bot working for me 24x7 on wechat, monitoring/filtering the most important message is badly needed. For example, it highlights discussion which contains the KEYWORDS which he want to follow up(especially in a noisy room). ;-) At last, It's built for huan's personal study purpose of Automatically Testing. ## Stargazers over time [![Stargazers over time](https://starchart.cc/wechaty/wechaty.svg)](https://starchart.cc/wechaty/wechaty) ## :two_hearts: Contributors [![GitHub issues](https://img.shields.io/github/issues/wechaty/wechaty.svg)](https://github.com/Wechaty/wechaty/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/wechaty/wechaty.svg)](https://github.com/Wechaty/wechaty/pulls) [![Open Collective Backers](https://opencollective.com/wechaty/backer/badge.svg?label=open%20collective%20backers&color=blue)](https://opencollective.com/wechaty/) [![Open Collective Sponsors](https://opencollective.com/wechaty/sponsors/badge.svg?label=open%20collective%20sponsors&color=blue)](https://opencollective.com/wechaty/) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/0)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/0) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/1)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/1) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/2)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/2) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/3)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/3) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/4)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/4) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/5)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/5) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/6)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/6) [![contributor](https://sourcerer.io/fame/huan/wechaty/wechaty/images/7)](https://sourcerer.io/fame/huan/wechaty/wechaty/links/7) This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. ----- [![Contribute](https://opencollective.com/wechaty/contributors.svg?width=890&button=false)](https://github.com/Wechaty/wechaty/graphs/contributors) ## :sunglasses: Backers [![Backers on Open Collective](https://opencollective.com/wechaty/backers/badge.svg)](#sunglasses-backers) Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/wechaty#backer)] [![Open Collective Wechaty](https://opencollective.com/wechaty/backers.svg?width=890)](https://opencollective.com/wechaty#backers) ## :smirk: Sponsors [![Sponsors on Open Collective](https://opencollective.com/wechaty/sponsors/badge.svg)](#smirk-sponsors) Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/wechaty#sponsor)] [![Wechaty Sponsor](https://opencollective.com/wechaty/sponsor.svg?width=890)](https://opencollective.com/wechaty/#sponsor) ## Multi-language Wechaty [![Python Wechaty](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty) [![Go Wechaty](https://img.shields.io/badge/Wechaty-Go-7de)](https://github.com/wechaty/go-wechaty) [![Java(Kotlin) Wechaty](https://img.shields.io/badge/Wechaty-Java-f80)](https://github.com/wechaty/java-wechaty) [![Scala Wechaty](https://img.shields.io/badge/Wechaty-Scala-890)](https://github.com/wechaty/scala-wechaty) [![PHP Wechaty](https://img.shields.io/badge/Wechaty-PHP-99c)](https://github.com/wechaty/php-wechaty) [![.NET(C#) Wechatyin](https://img.shields.io/badge/Wechaty-.NET-629)](https://github.com/wechaty/dotnet-wechaty) - [Wechaty](https://github.com/wechaty/wechaty) - RPA SDK for Chatot Makers (TypeScript) - [Python Wechaty](https://github.com/wechaty/python-wechaty) - RPA SDK for Chatbot Makers written in Python - [Go Wechaty](https://github.com/wechaty/go-wechaty) - RPA SDK for Chatbot Makers written in Go - [Java Wechaty](https://github.com/wechaty/java-wechaty) - RPA SDK for Chatbot Makers written in Java(Kotlin) - [Scala Wechaty](https://github.com/wechaty/scala-wechaty) - RPA SDK for Chatbot Makers written in Scala - [PHP Wechaty](https://github.com/wechaty/php-wechaty) - RPA SDK for Chatbot Makers written in PHP - [.Net(C#) Wechaty](https://github.com/wechaty/dotnet-wechaty) - RPA SDK for Chatbot Makers written in .NET(C#) ## History ### main v1.11 (Nov 22, 2021) Working on reduxify the Wechaty ecosystem for applying the CQRS pattern. ### v1.10 (Nov 21, 2021) Second beta release of Wechaty, with all ecosystem npm modules with version v1.10 (wechaty-puppet, wechaty-puppet-service, etc) ### v1.0 (Sep 2021) - Release v1.0 of Wechaty is the first beta release of Wechaty. ### v0.69 1. v0.69: Supports ES Modules (with CJS dual support) ([#2232](https://github.com/wechaty/wechaty/issues/2232)) ### v0.68 (Aug 27, 2021) 1. TLS support ([#2231](https://github.com/wechaty/wechaty/issues/2231)) 1. The latest CommonJS version ## Creators 1. [Huan](https://github.com/huan) [(LinkedIn)](http://linkedin.com/in/huan42), 🐧 Tencent TVP of Chatbot・🤖 Chatie Architect・⭐️ GitHub Star・🚀 YC W19・🌐 Microsoft RD & AI MVP・🦾 Google ML GDE ・🤠 Serial Entrepreneur・🔥 Burner 1. [Rui (李佳芮)](https://pre-angel.com/peoples/jiarui-li/), Microsoft AI MVP & RD, Co-founder & CEO of [Juzi.BOT](https://www.juzibot.com/) (YC W19 Alumni) [![Profile of Huan Li on StackOverflow](https://stackoverflow.com/users/flair/1123955.png)](https://stackoverflow.com/users/1123955/huan) ## Cite Wechaty To cite this project in publications: ```bibtex @misc{Wechaty, author = {Huan Li, Rui Li}, title = {Wechaty: Conversational SDK for Chatbot Makers}, year = {2016}, publisher = {GitHub}, journal = {GitHub Repository}, howpublished = {\url{https://github.com/wechaty/wechaty}}, } ``` ## Copyright & License - Code & Docs © 2016-now Huan, Rui, and Wechaty Community Contributors - Code released under the Apache-2.0 License - Docs released under Creative Commons

AI Agents RPA
22.8K Github Stars
python-wechaty
Open Source

python-wechaty

<!-- markdownlint-disable MD033 --> # python-wechaty ![Python Wechaty](./docs/img/getting-started/python-wechaty.png) [![PyPI Version](https://img.shields.io/pypi/v/wechaty?color=blue)](https://pypi.org/project/wechaty/) [![Python Wechaty Getting Started](https://img.shields.io/badge/Python%20Wechaty-Getting%20Started-blue)](https://github.com/wechaty/python-wechaty-getting-started) [![Python 3.7](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/) [![Downloads](https://pepy.tech/badge/wechaty)](https://pepy.tech/project/wechaty) [![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty) [![codecov](https://codecov.io/gh/wechaty/python-wechaty/branch/master/graph/badge.svg)](https://codecov.io/gh/wechaty/python-wechaty) [![PyPI](https://github.com/wechaty/python-wechaty/actions/workflows/pypi.yml/badge.svg)](https://github.com/wechaty/python-wechaty/actions/workflows/pypi.yml) ![PyPI - Downloads](https://img.shields.io/pypi/dm/wechaty?color=blue) [📄 Chinese Document](https://wechaty.readthedocs.io/zh_CN/latest/) [python-wechaty-template](https://github.com/wechaty/python-wechaty-template) ## What's Python Wechaty Python Wechaty is an Open Source software application for building chatbots. It is a modern Conversational RPA SDK which Chatbot makers can use to create a bot in a few lines of code. You can use Wechaty to build a chatbot which automates conversations and interact with people through instant messaging platforms such as WhatsApp, WeChat, WeCom, Gitter and Lark among others. ## Features * **Message Processing**: You can use the simple code, similar to natural language, to process the message receving & sending. * **Plugin System**: You can use the community-contributed plugins to handle your scenario. * **Write onece, run multi IM platform**: python wechaty support many IM platforms with one code, all of you need to do is switch the token token type. * **Wechaty UI**: you can use the powerful wechaty-ui to create interactive chatbot * ... ## Getting Started There are few steps to start your bot, and we give a [bot-template](https://github.com/wechaty/python-wechaty-template) for you to getting started quickly. ## Join Us 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 _python wechaty_, join our **Wechaty Python Developers' Home**. ![Wechaty Friday.BOT QR Code](https://wechaty.js.org/img/friday-qrcode.svg) Scan now, because other Wechaty Python developers want to talk with you too! (secret code: _python wechaty_) ## Requirements 1. Python 3.7+ ## Install ```shell pip3 install wechaty ``` ## See Also - [Packaging Python Projects](https://packaging.python.org/tutorials/packaging-projects/) ### Static & Instance of Class - [Static variables and methods in Python](https://radek.io/2011/07/21/static-variables-and-methods-in-python/) ### Typings - [PEP 526 -- Syntax for Variable Annotations - Class and instance variable annotations](https://www.python.org/dev/peps/pep-0526/#class-and-instance-variable-annotations) - [Python Type Checking (Guide)](https://realpython.com/python-type-checking/) by [Geir Arne Hjelle](https://realpython.com/team/gahjelle/) ## History ### v0.6 (Jun 19, 2020) Python Wechaty Scala Wechaty **BETA** Released! Read more from our Multi-language Wechaty Beta Release event from our blog: - [Multi Language Wechaty Beta Release Announcement!](https://wechaty.js.org/2020/06/19/multi-language-wechaty-beta-release/) ### v0.4 (Mar 15, 2020) master Welcome [@huangaszaq](https://github.com/huangaszaq) for joining the project! [#42](https://github.com/wechaty/python-wechaty/pull/42) 1. Add a friendly exception message for PyPI users. [#24](https://github.com/wechaty/python-wechaty/issues/24) ### v0.1 (Mar 8, 2020) Welcome [@wj-Mcat](https://github.com/wj-Mcat) for joining the project! [#4](https://github.com/wechaty/python-wechaty/pull/4) 1. Starting translate TypeScript of Wechaty to Python 1. DevOps Setup 1. Type Checking: mypy & pytype 1. Unit Testing: pytest 1. Linting: pylint, pycodestyle, and flake8 1. CI/CD: GitHub Actions 1. Publish to PyPI automatically after the tests passed. ### v0.0.1 (Aug 25, 2018) Project created, publish a empty module `wechaty` on PyPI. ## Related Projects - [Wechaty](https://github.com/wechaty/wechaty) - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript) - [Python Wechaty](https://github.com/wechaty/python-wechaty) - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python) - [Go Wechaty](https://github.com/wechaty/go-wechaty) - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go) - [Java Wechaty](https://github.com/wechaty/java-wechaty) - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java) - [Scala Wechaty](https://github.com/wechaty/scala-wechaty) - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala) ## Badge [![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty) ```md [![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty) ``` ## Stargazers over time [![Stargazers over time](https://starchart.cc/wechaty/python-wechaty.svg)](https://starchart.cc/wechaty/python-wechaty) ## Contributors <a href="https://github.com/wechaty/python-wechaty/graphs/contributors"> <img src="https://contrib.rocks/image?repo=wechaty/python-wechaty" /> </a> Made with [contrib.rocks](https://contrib.rocks). ## Support Thanks the following supported Software. [![test image size](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg?_gl=1*1lb7oaa*_ga*MjE5ODE2MzAwLjE2MzYxODMyNTE.*_ga_V0XZL7QHEB*MTY0MTI2NzU5OS41LjEuMTY0MTI2NzY3OC4w&_ga=2.157122558.411488113.1641267600-219816300.1636183251)](https://jb.gg/OpenSourceSupport) ## Committers 1. [@huangaszaq](https://github.com/huangaszaq) - Chunhong HUANG (黄纯洪) ## Creators - [@wj-Mcat](https://github.com/wj-Mcat) - Jingjing WU (吴京京) - [@huan](https://github.com/huan) - ([李卓桓](http://linkedin.com/in/zixia)) [email protected] ## Copyright & License - Code & Docs © 2018 Wechaty Contributors <https://github.com/wechaty> - Code released under the Apache-2.0 License - Docs released under Creative Commons

AI Tools RPA
1.8K Github Stars
getting-started
Open Source

getting-started

# Wechaty Getting Started [![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://wechaty.js.org) [![Node.js CI](https://github.com/wechaty/getting-started/workflows/Node.js%20CI/badge.svg)](https://github.com/wechaty/getting-started/actions?query=workflow%3A%22Node.js+CI%22) ![Node.js v16](https://img.shields.io/badge/node-%3E%3D16-green.svg) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/) [![ES Modules](https://img.shields.io/badge/ES-Modules-brightgreen)](https://github.com/Chatie/tsconfig/issues/16) ## About Wechaty [Wechaty](https://github.com/wechaty/wechaty/) is a Conversational RPA(Robotic Process Automation) SDK(Software Development Kit) for Chatbot Makers. It's well designed with an easy to use API. It supports all operating systems including Linux, OSX, Win32, Docker, and lots of IMs(Instant Messaging services) including WeChat, WeCom, Whatsapp, Lark, Gitter, etc. As a developer, you can use Wechaty to easily build your bot, effectively manage message sending and receiving, room creation and sending out invitations, contact friends, and delightfully add artificial intelligence between users and your bot. ## About Wechaty Getting Started Project 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 on a local setup on your machine as described in the sections below. If you encounter difficulties or have any questions, you are welcome to ask for help in our Discord Community at <https://discord.gg/7q8NBZbQzt>. Notice: the current active version of Wechaty is v1.x which is not compatible with most of the v0.x modules. - **`[email protected]`** - To use the Wechaty v0.x, please visit the [Wechaty Getting Started v0.x](https://github.com/wechaty/getting-started/tree/v0.x) branch. ### Features of Wechaty Getting Started project 1. It works out of the box on Linux, Mac or Windows. 1. Supports all puppets like Web, Pad, Windows, and Mac. 1. It replies with a `dong` message when it receives a `ding` message. ### Wechaty Getting Started video tutorial <div align="center"> <a target="_blank" href="https://youtu.be/GdmikkU4ZfM?si=cpsuh7RyQjtgLE5F"><img src="docs/images/video-tutorial-img.webp" border=0 width="60%"></a> </div> Above is a short run-through of deploying the ding-dong-bot using WeChat, WhatsApp, and WeCom. ### Running Wechaty Getting Started Project on a cloud based IDE The fastest way to getting 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 recommed Gitpod. #### Using [Gitpod ❤️ Wechaty](docs/gitpod.md) Gitpod is an online and open source platform for automated and ready-to-code development environments. You can click the button below to access a complete setup of [Wechaty Getting Started ding-dong BOT](examples/ding-dong-bot.ts) project on gitpod. If you have never used gitpod before, you will be required to login using your gitHub account. [![GitPod Ready-to-Code][gitpod_img]][gitpod_link] You can learn more about [Gitpod ❤️ Wechaty](docs/gitpod.md) from our blog: [Getting Started Without Leaving Your Browser: Wechaty ❤️ Gitpod, @huan, Feb 06, 2021](https://wechaty.js.org/2021/02/06/wechaty-getting-started-without-leave-your-browser/) #### Using Google Cloud Shell Google Cloud Shell is an online development and operations environment accessible anywhere with your browser. You can run this project on Google Cloud Shell by clicking the button below. [![Open in Cloud Shell][shell_img]][shell_link] > Generated via [open-in-cloud-shell](https://cloud.google.com/shell/docs/open-in-cloud-shell) After opening the Google Cloud Shell editor, there should be an open tutorial in the right panel which you can follow to learn more about Wechaty. Learn more about running this project on Google Cloud Shell from our blog: [Google Cloud Shell Tutorials for Wechaty, @huan, Feb 20, 2021](https://wechaty.js.org/2021/02/20/google-cloud-shell-tutorials/) ### Running Wechaty Getting Started project on your local machine #### Prerequisites For you to run this project on your local machine, you need to: 1. Have [Node.js](https://nodejs.dev/) v16+ installed on your machine. You can run the command `node -v` on the terminal to check whether you have `Node.js` installed. If you have it, you should be able to see the version printed on the terminal like `v16.13.0`. Your version might be different from `v16.13.0`. If it is not installed or your version is below 16, You need to install the latest version by following the links below: - [Windows](https://nodejs.org/en/download/package-manager/#windows) - [Linux(Debian/Ubuntu)](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) - [macOS](https://nodejs.org/en/download/package-manager/#macos) > Node.js for other platforms can be found at <https://nodejs.org/en/download/package-manager/> 2. Have [Wechaty Puppet Service TOKEN](https://wechaty.js.org/docs/puppet-services/) if you want to use RPA protocols other than Web #### Step 1: Clone this Repository You need to clone this repository to your local machine and then switch to `wechaty-getting-started` directory by running the commands below. ```sh git clone https://github.com/wechaty/getting-started.git cd getting-started ``` #### Step 2: Install Dependencies You need to install dependencies by running the command below. ```sh npm install ``` #### Step 3: Run the Bot You can use `export` to set environment variables in Linux, and use `set` in Windows. If you run into errors while running this command, check the troubleshooting tips in step 4. ##### Linux ```shell export WECHATY_LOG=verbose export WECHATY_PUPPET=wechaty-puppet-wechat npm start # the above is equals to the below command: # npx ts-node examples/ding-dong-bot.ts ``` ##### Windows ```shell set WECHATY_LOG=verbose set WECHATY_PUPPET=wechaty-puppet-wechat npm start # the above is equals to the below command: # npx ts-node examples/ding-dong-bot.ts ``` You are all set! #### Step 4: Troubleshooting If you run into problems while following the above steps, try the options below. You are also welcome to ask questions in our [gitter chatroom](https://gitter.im/wechaty/wechaty). 1. You might also need [windows-build-tool](https://www.npmjs.com/package/windows-build-tool) if you are using windows: ```sh npm install windows-build-tools ``` ## Working with Different Puppets In our getting started example, the ding-dong BOT uses [wechaty-puppet-wechat4u](https://github.com/wechaty/wechaty-puppet-wechat4u) when `WECHATY_PUPPET` is not set, which is just for newcomer's convenience. By default, Wechaty will use the [Puppet Service](https://wechaty.js.org/docs/puppet-services/) for logging in your bot. You can use other [Puppet Provider](https://github.com/wechaty/wechaty-puppet/wiki/Directory) like Whatsapp Web protocol( [wechaty-puppet-whatsapp](https://github.com/wechaty/wechaty-puppet-whatsapp)). If you want to use a Wechaty Puppet Provider for a different protocol, then you need to specify a puppet service provider name (the same as its NPM name) by setting the `WECHATY_PUPPET` environment variable. Thanks to the great contributions from our community, there are many Wechaty Puppets which can be used by Wechaty. They have helped us use protocols like Web, Pad, Mac, and Windows. ### Wechaty Puppets | Protocol | NPM | | :--- | :--- | | Puppet Service | `wechaty-puppet-service` | | Whatsapp Web | `wechaty-puppet-whatsapp` | | WeChat Web | `wechaty-puppet-wechat` | | WeChat Pad | `wechaty-puppet-padlocal` | > Visit our website to learn more about [Wechaty Puppet Service Providers](https://wechaty.js.org/docs/puppet-services/) For example, if you want to use the `padlocal` puppet, you should set `WECHATY_PUPPET=wechaty-puppet-padlocal` before you run `npm start`. You also need a TOKEN for `wechaty-puppet-padlocal` which you need to set to the `WECHATY_PUPPET_PADLOCAL_TOKEN` environment variable. You can apply for the PadLocal TOKEN from [here](https://wechaty.js.org/docs/puppet-services/padlocal/). The code snippets below illustrate what has been described above on Linux/ MacOS and on Windows. ### On Linux / macOS ```sh export WECHATY_PUPPET=wechaty-puppet-padlocal export WECHATY_PUPPET_PADLOCAL_TOKEN='puppet_padlocal_your-token-here' npm start ``` ### On Windows ```sh set WECHATY_PUPPET=wechaty-puppet-padlocal set WECHATY_PUPPET_PADLOCAL_TOKEN='puppet_padlocal_your-token-here' npm start ``` Learn more about installing Wechaty on windows from this [blog post](https://wechaty.js.org/2018/07/24/wechaty-installation-in-windows-10/). ## Advanced tutorials ### 1. Wechaty Tutorial <div align="center"> <a target="_blank" href="https://wechaty.js.org/2017/01/01/getting-started-wechaty/"><img src="https://cloud.githubusercontent.com/assets/1361891/21722581/3ec957d0-d468-11e6-8888-a91c236e0ba2.jpg" border=0 width="60%"></a> </div> Above is a 10 minute video tutorial. It is using version 0.14 or older versions of Wechaty therefore it is also outdated. It is a good way to start if you are new to Wechaty. ### 2. More Examples > Note: Before you attempt more examples, make sure you have tried out the wechaty getting started project in this repository. - [Official Wechaty Examples Directory](https://github.com/wechaty/getting-started/tree/master/examples) ## API REFERENCE 1. Official API Docs: <https://wechaty.js.org/docs/api> ## MORE RESOURCES ### 1. Docker Wechaty Getting Started [![Docker](https://avatars0.githubusercontent.com/u/5429470?s=200)](https://github.com/wechaty/docker-wechaty-getting-started) <https://github.com/wechaty/docker-wechaty-getting-started> ### 2. Heroku Wechaty Getting Started [![Heroku](https://avatars3.githubusercontent.com/u/23211?s=200)](https://github.com/wechaty/heroku-wechaty-getting-started) <https://github.com/wechaty/heroku-wechaty-getting-started> ### 3. Wechaty Home <https://wechaty.github.io> ## FAQ ### 1. I can not login with my Wechat account WeChat account registered after 2017 will not be able to login via Web API. Learn more about it at <https://github.com/Chatie/wechaty/issues/872> Solution: You can use Wechaty support protocols other than Web API, such as pad. Learn more at <https://github.com/Chatie/wechaty/issues/1296> ### 2. What is a `Puppet` in Wechaty The term [Puppet](https://github.com/Chatie/wechaty/wiki/Puppet) in Wechaty is an Abstract Class for implementing protocol plugins. The plugins are the components that help Wechaty to control Wechat and that's the reason why we call it puppet. The plugins are named `PuppetXXX`, for example [PuppetWeChat](https://github.com/Chatie/wechaty-puppet-wechat) is using the [google puppeteer](https://github.com/GoogleChrome/puppeteer) to control the [WeChat Web API](https://wx.qq.com) via a chrome browser, [PuppetPadchat](https://github.com/lijiarui/wechaty-puppet-padchat) uses the WebSocket protocol to connect with a Protocol Server for controlling the iPad Wechat program. For more details you can go to [Puppet in wiki](https://github.com/Chatie/wechaty/wiki/Puppet). Learn more about Wechaty Puppet from our documentation at [Wechaty Puppet](https://wechaty.js.org/docs/specifications/puppet) ## Wechaty Getting Started in Multiple Languages [![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty) [![Wechaty in Go](https://img.shields.io/badge/Wechaty-Go-7de)](https://github.com/wechaty/go-wechaty) [![Wechaty in Java](https://img.shields.io/badge/Wechaty-Java-f80)](https://github.com/wechaty/java-wechaty) [![Wechaty in Scala](https://img.shields.io/badge/Wechaty-Scala-890)](https://github.com/wechaty/scala-wechaty) [![Wechaty in PHP](https://img.shields.io/badge/Wechaty-PHP-99c)](https://github.com/wechaty/php-wechaty) [![Wechaty in .NET(C#)](https://img.shields.io/badge/Wechaty-.NET-629)](https://github.com/wechaty/dotnet-wechaty) - [TypeScript Wechaty Getting Started](https://github.com/wechaty/getting-started) - [Python Wechaty Getting Started](https://github.com/wechaty/python-wechaty-getting-started) - [Go Wechaty Getting Started](https://github.com/wechaty/go-wechaty-getting-started) - [Java Wechaty Getting Started](https://github.com/wechaty/java-wechaty-getting-started) - [Scala Wechaty Getting Started](https://github.com/wechaty/scala-wechaty-getting-started) - [PHP Wechaty Getting Started](https://github.com/wechaty/php-wechaty-getting-started) - [.NET(C#) Wechaty Getting Started](https://github.com/wechaty/dotnet-wechaty-getting-started) ## History ### main v1.18 (Mar 14, 2022) Add CQRS Wechaty examples. ### v1.11 (Oct 30, 2021) Branch: [v1.11](https://github.com/wechaty/getting-started/tree/v1.11): release v1.11 of Wechaty. 1. v0.13: Enable ESM (ES Module) support ([chatie/tsconfig#16](https://github.com/Chatie/tsconfig/issues/16)) ### v0.8 (Feb 20, 2021) [![Open in Cloud Shell][shell_img]][shell_link] Using Google Cloud Shell for a quick setup! ### v0.6 (Feb 11, 2021) [![GitPod Ready-to-Code][gitpod_img]][gitpod_link] Using Gitpod for a quick setup! ### v0.0.1 (Jan 12, 2017) Init version ## Contributors [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/0)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/0) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/1)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/1) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/2)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/2) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/3)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/3) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/4)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/4) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/5)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/5) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/6)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/6) [![contributor](https://sourcerer.io/fame/huan/wechaty/getting-started/images/7)](https://sourcerer.io/fame/huan/wechaty/getting-started/links/7) ## Maintainers [@wechaty/contributors](https://github.com/orgs/wechaty/teams/contributors/members) ## Copyright & License - Code & Docs © 2018-now Huan and [Wechaty Contributors](https://wechaty.js.org/contributors/) - Code released under the Apache-2.0 License - Docs released under Creative Commons [gitpod_img]: https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod [gitpod_link]: https://gitpod.io/#https://github.com/wechaty/getting-started [shell_img]: https://gstatic.com/cloudssh/images/open-btn.svg [shell_link]: https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fwechaty%2Fgetting-started&cloudshell_open_in_editor=examples/ding-dong-bot.ts&cloudshell_workspace=.&cloudshell_tutorial=examples/tutorials/google-cloud-shell-tutorial.md

AI Tools Live Chat & Chatbots
848 Github Stars
wechaty-puppet-padplus
Open Source

wechaty-puppet-padplus

# THIS REPO HAS BEEN DEPRECATED Learn more about Wechaty Puppet Services from <https://wechaty.js.org/docs/puppet-services> You can use Wechaty with other puppet services like WXWork, Rock, PadLocal, etc as well. ## 通知 (Nov, 2020) 亲爱的开发者,您好! 为了更好的提供服务,JuziBot Puppet Service 计划于11月30日进行一次 wechaty-puppet-padplus 重大升级。 如您正在使用 wechaty-puppet-padplus服务, 则需要进行如下升级操作。(如未使用 wechaty-puppet-padplus,可安全的忽视本通知) wechaty-puppet-padplus 升级说明如下: 1. 卸载 wechaty-puppet-padplus, 安装 wechaty-puppet-hostie 2. 代码中启动wechaty的 wechaty-puppet-padplus 更换成 wechaty-puppet-hostie 详细说明: wechaty-puppet-padplus 将会在11月30日下线,已付费的用户可以升级到下面的两个puppet: 1. wechaty-puppet-donut: 基于 windows 的个人微信,除了 padplus 的基础功能外,还支持接受企业微信消息,详细信息见 https://github.com/juzibot/donut-tester 2. wechaty-puppet-wxwork: 基于 windows 客户端的企业微信,详细信息见 https://github.com/juzibot/wxwork-tester 如在11月30日前没有升级代码库,wechaty-puppet-padplus 服务将会在12月1日00:00停止服务,导致您托管的微信不可用,所以强烈建议提前进行代码升级,以避免机器人意外终止服务。 如果您有任何问题,请及时与我们的客服联系,微信:`juzibot` 详情见:https://github.com/wechaty/puppet-service-providers/issues/11 # WECHATY-PUPPET-PADPLUS [![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-blue.svg)](https://github.com/chatie/wechaty) [![NPM Version](https://badge.fury.io/js/wechaty-puppet-padplus.svg)](https://www.npmjs.com/package/wechaty-puppet-padplus) [![npm (tag)](https://img.shields.io/npm/v/wechaty-puppet-padplus/next.svg)](https://www.npmjs.com/package/wechaty-puppet-padplus?activeTab=versions) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/) [![Linux/Mac Build Status](https://travis-ci.com/wechaty/wechaty-puppet-padplus.svg?branch=master)](https://travis-ci.com/wechaty/wechaty-puppet-padplus) ## Notice Our Mission: Make it easy to build a WeChat Chatbot for developers. We provide a **free** token for the developers who have a strong will and ability to build a valuable chatbot for users. See more: [Token Support](https://github.com/juzibot/Welcome/wiki/Support-Developers), [Everything about wechaty](https://github.com/juzibot/Welcome/wiki/Everything-about-Wechaty) ## Install ### 1. Init #### 1.1. Check your `Node` version first ```shell node --version // v10.16.0 ``` > for windows system To make sure you could install `wechaty-puppet-padplus` successfully, you have to start PowerShell as Administrator and run these commands: ```shell npm install -g windows-build-tools npm install -g node-gyp ``` #### 1.2. Create your bot folder and do some init config ```shell mkdir my-padplus-bot && cd my-padplus-bot npm init -y npm install ts-node typescript -g tsc --init --target ES6 touch bot.ts // copy the example code to it ``` ### 2. Install Wechaty Dependencies ```shell npm install wechaty@latest npm install wechaty-puppet-padplus@latest ``` Or some new features developing version: ```shell npm install wechaty@next npm install wechaty-puppet-padplus@next ``` ### 3. Install Other Dependencies > There's no need to install `wechaty-puppet` in my-padplus-bot ```shell npm install qrcode-terminal ... ``` ### 4. Run > If you want to see detail logs about your bot, just run: ```shell BROLOG_LEVEL=silly ts-node bot.ts ``` or ```shell BROLOG_LEVEL=silly node bot.js ``` ### 5. Cache Option > wechaty-puppet-padplus use flash-store or mongo as cache store - flash-store[default] - mongo > If you want to use mongo as cache sotre, just set the cacheOption, like this: ```ts const puppet: Puppet = new PuppetPadplus({ token, cacheOption: { type: 'mongo', url: 'mongodb://127.0.0.1:27017/testdb', }, }) ``` #### Caution *When you use mongo as cache store, wechaty-puppet-cache use some tables which have `wechaty-cache` prefix. [detail>>](https://www.npmjs.com/package/wechaty-puppet-cache#4-caution)* ### 6. Other Tips > Set environment in windows ```shell $Env:BROLOG_LEVEL='silly' ts-node bot.ts ``` > If step 1~3 can not help you install successfully, please try this suggestion, otherwise just skip it please. ```shell rm -rf node_modules package-lock.json npm install ``` ## Example ```ts // bot.ts import { Contact, Message, Wechaty } from 'wechaty' import { ScanStatus } from 'wechaty-puppet' import { PuppetPadplus } from 'wechaty-puppet-padplus' import QrcodeTerminal from 'qrcode-terminal' const token = 'your-token' const puppet = new PuppetPadplus({ token, }) const name = 'your-bot-name' const bot = new Wechaty({ puppet, name, // generate xxxx.memory-card.json and save login data for the next login }) bot .on('scan', (qrcode, status) => { if (status === ScanStatus.Waiting) { QrcodeTerminal.generate(qrcode, { small: true }) } }) .on('login', (user: Contact) => { console.log(`login success, user: ${user}`) }) .on('message', (msg: Message) => { console.log(`msg : ${msg}`) }) .on('logout', (user: Contact, reason: string) => { console.log(`logout user: ${user}, reason : ${reason}`) }) .start() ``` ## How to emit the message that you sent Please use environment variable `PADPLUS_REPLAY_MESSAGE` to activate this function. ```shell PADPLUS_REPLAY_MESSAGE=true node bot.js ``` ## Puppet Comparison 功能 | padpro | padplus | macpro ---|---|---|--- **<消息>**| | | 收发文本| ✅ |✅ |✅ 收发个人名片| ✅ |✅ |✅ 收发图文链接| ✅ |✅ |✅ 发送图片、文件| ✅ | ✅(对内容有大小限制,20M以下) |✅ 接收图片、文件| ✅ | ✅(对内容有大小限制,25M以下) |✅ 发送视频| ✅ | ✅ | ✅ 接收视频| ✅ | ✅ | ✅ 发送小程序| ❌ | ✅ | ✅ 接收动图| ❌ | ✅ | ✅ 发送动图| ❌ | ✅ | ✅ 接收语音消息| ✅ | ✅ | ✅ 发送语音消息| ✅ | ❌ | ❌ 转发文本| ✅ | ✅ | ✅ 转发图片| ✅ | ✅ | ✅ 转发图文链接| ✅ | ✅ | ✅ 转发音频| ✅ | ❌ | ✅ 转发视频| ✅ | ✅ | ✅ 转发文件| ✅ | ✅ | ✅ 转发动图| ❌ | ❌ | ❌ 转发小程序| ❌ | ✅ | ❌ **<群组>**| | | 创建群聊|✅|✅|✅ 设置群公告|✅|✅|✅ 获取群公告|❌|✅|❌ 群二维码|✅|✅|✅ 拉人进群|✅|✅|✅ 踢人出群|✅|✅|✅ 退出群聊|✅|✅|✅ 改群名称|✅|✅|✅ 入群事件|✅|✅|✅ 离群事件|✅|✅|✅ 群名称变更事件|✅|✅|✅ @群成员|✅|✅|✅ 群列表|✅|✅|✅ 群成员列表|✅|✅|✅ 群详情|✅|✅|✅ **<联系人>**| | | 修改备注|✅|✅|✅ 添加好友|✅|✅|✅ 自动通过好友|✅|✅|❌ 添加好友|✅|✅|✅ 好友列表|✅|✅|✅ 好友详情|✅|✅|✅ **<其他>**| | | 登录微信|✅|✅|✅ 扫码状态|✅|✅|❌ 退出微信|✅|✅|✅ 依赖协议|iPad|iPad|Mac|

JavaScript Libraries & Components
337 Github Stars