diff --git a/README.md b/README.md index 4e8faa5ef0b5887179137558d31d7f9d1d8828f1..c8528c9d43cff5ef1a8c210d4f986d26e2bde969 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Connecting ChatBots. -Wechaty is a Bot Framework for Wechat **Personal** Account that helps you easy creating bot in 6 lines of javascript, with cross-platform support to [Linux](https://travis-ci.org/wechaty/wechaty), [Win32](https://ci.appveyor.com/project/zixia/wechaty), [Darwin(OSX/Mac)](https://travis-ci.org/wechaty/wechaty) and [Docker](https://circleci.com/gh/wechaty/wechaty). +Wechaty is a Bot Framework for Wechat **Personal** Account that helps you easy creating bot in 6 lines of javascript, with cross-platform support include [Linux](https://travis-ci.org/wechaty/wechaty), [Win32](https://ci.appveyor.com/project/zixia/wechaty), [Darwin(OSX/Mac)](https://travis-ci.org/wechaty/wechaty) and [Docker](https://circleci.com/gh/wechaty/wechaty). :octocat: :beetle: @@ -86,6 +86,8 @@ Use Docker to deploy wechaty is highly recommended. [![dockeri.co](http://dockeri.co/image/zixia/wechaty)](https://hub.docker.com/r/zixia/wechaty/) +Working in progress details: [Dockerize Wechaty for easy start #66](https://github.com/wechaty/wechaty/issues/66) + Wechaty is fully dockerized. So it will be very easy to be used as a MicroService. ```bash @@ -490,15 +492,15 @@ get the sender from a message, or set it. get the sender from a message. -#### 2. Message.from(contact: Contact): Contact +#### 2. Message.from(contact: Contact): void set a sender to the message -#### 3. Message.from(contactId: string): Contact +#### 3. Message.from(contactId: string): void set a sender to the message by contact id -### Message.to(contact?: Contact|Room|string): Contact|Room +### Message.to(contact?: Contact|Room|string): Contact|Room|void get the receiver from a message, or set it. @@ -506,19 +508,19 @@ get the receiver from a message, or set it. get the destination of the message -#### 2. Message.to(contact: Contact): Contact +#### 2. Message.to(contact: Contact): void set the destination as Contact for the message -#### 3. Message.to(room: Room): Room +#### 3. Message.to(room: Room): void set the destination as Room for the message -#### 4. Message.to(contactOrRoomId: string): Contact | Room +#### 4. Message.to(contactOrRoomId: string): void set the destination as Room or Contact by id, for the message -### Message.room(room?: Room|string): Room +### Message.room(room?: Room|string): Room|void get the room from a message, or set it. @@ -528,11 +530,11 @@ get the room from Message. if the message is not in a room, then will return `null` -#### 2. Message.room(room: Room): Room +#### 2. Message.room(room: Room): void set the room for a Message -#### 3. Message.room(roomId: string): Room +#### 3. Message.room(roomId: string): void set the room by id for a Message @@ -856,9 +858,9 @@ Github Issue ## Similar Project ### Javascript +1. [Wechat4U](https://github.com/nodeWechat/wechat4u) 微信 wechat web 网页版接口的 JavaScript 实现,兼容Node和浏览器 1. [Weixinbot](https://github.com/feit/Weixinbot) Nodejs 封装网页版微信的接口,可编程控制微信消息 1. [wechatBot](https://github.com/stonexer/wechatBot) 面向个人的微信 wechat 机器人平台 - 使用微信网页版接口wechat4u -1. [Wechat4U](https://github.com/nodeWechat/wechat4u) 微信 wechat web 网页版接口的 JavaScript 实现,兼容Node和浏览器 2. [wechat-user-bot](https://github.com/HalfdogStudio/wechat-user-bot) 正在组装中的微信机器人 2. [Hubot-WeChat](https://github.com/KasperDeng/Hubot-WeChat) Hubot是一个具有真实微信号的机器人,可以自动回复信息到微信群和某联系人,并能给维护者的微信自动发送Hubot在线状态 diff --git a/src/message.ts b/src/message.ts index ab2b52860c672c8c94cc218e9d936f15e0f43298..a622c90c1d3f7645b369154a1a8c5545b7a0aa65 100644 --- a/src/message.ts +++ b/src/message.ts @@ -150,10 +150,10 @@ export class Message implements Sayable { return '{' + this.type() + '}' + content } - public from(contact?: Contact): Contact - public from(id?: string): Contact + public from(contact?: Contact): void + public from(id?: string): void public from(): Contact - public from(contact?: Contact|string): Contact { + public from(contact?: Contact|string): Contact|void { if (contact) { if (contact instanceof Contact) { this.obj.from = contact.id @@ -162,6 +162,7 @@ export class Message implements Sayable { } else { throw new Error('unsupport from param: ' + typeof contact) } + return } const loadedContact = Contact.load(this.obj.from) @@ -171,11 +172,11 @@ export class Message implements Sayable { return loadedContact } - public to(contact: Contact): Contact - public to(room: Room): Room - public to(id: string): Contact|Room + public to(contact: Contact): void + public to(room: Room): void + public to(id: string): void public to(): Contact|Room - public to(contact?: Contact|Room|string): Contact|Room { + public to(contact?: Contact|Room|string): Contact|Room|void { if (contact) { if (contact instanceof Contact || contact instanceof Room) { this.obj.to = contact.id @@ -184,6 +185,7 @@ export class Message implements Sayable { } else { throw new Error('unsupport to param ' + typeof contact) } + return } // FIXME: better to identify a room id? @@ -196,10 +198,10 @@ export class Message implements Sayable { return loadedInstance } - public room(room: Room): Room - public room(id: string): Room + public room(room: Room): void + public room(id: string): void public room(): Room|null - public room(room?: Room|string): Room|null { + public room(room?: Room|string): Room|null|void { if (room) { if (room instanceof Room) { this.obj.room = room.id @@ -208,6 +210,7 @@ export class Message implements Sayable { } else { throw new Error('unsupport room param ' + typeof room) } + return } if (!this.obj.room) { return null