Room
All wechat rooms(groups) will be encapsulated as a Room.
Classes
All wechat rooms(groups) will be encapsulated as a Room.
Typedefs
The filter to find the room: {topic: string | RegExp} RoomEventName
Room Class Event Type RoomEventFunction
Room Class Event Function RoomMemberQueryFilter
The way to search member by Room.member()
Room
All wechat rooms(groups) will be encapsulated as a Room.
Kind: global class Properties
Name
Type
Description
id
string
Get Room id. This function is depending on the Puppet Implementation, see puppet-compatible-table
instance
.sync() ⇒
Promise <void>.say(textOrContactOrFileOrUrl, ...mentionList) ⇒
Promise <void>.on(event, listener) ⇒
Room.add(contact) ⇒
Promise <void>.del(contact) ⇒
Promise <void>.quit() ⇒
Promise <void>.topic([newTopic]) ⇒
Promise <void | string>.announce([text]) ⇒
Promise <void | string>.qrcode() ⇒
Promise <string>.alias(contact) ⇒
Promise <null | string>.has(contact) ⇒
Promise <boolean>.memberAll([query]) ⇒
Promise <Contact []>.member(queryArg) ⇒
Promise <Contact | null>.owner() ⇒
Contact|null.avatar() ⇒
Promise <FileBox>
static
.create(contactList, [topic]) ⇒
Promise <Room>.findAll([query]) ⇒
Promise <Room []>.find(query) ⇒
Promise <Room | null>
room.sync() ⇒ Promise <void>
Promise <void>Force reload data for Room, Sync data from lowlevel API again.
Kind: instance method of Room Example
room.say(textOrContactOrFileOrUrlLinkOrMiniProgram, ...mentionList) ⇒ Promise <void>
Promise <void>Send message inside Room, if set mentionList, wechaty will mention the contact list as well.
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room
Param
Type
Description
textOrContactOrFileOrUrlLinkOrMiniProgram
string | Contact | FileBox | UrlLink | MiniProgram
Send text, media file or link inside Room. You can use FileBox to send file
...mentionList
Contact []
Send content inside Room, and mention @contact list.
Example
room.on(event, listener) ⇒ this
thisKind: instance method of Room Returns: this - - Room for chain
Param
Type
Description
Example (Event:join )
Example (Event:leave )
Example (Event:topic )
Example (Event:invite )
room.add(contact) ⇒ Promise <void>
Promise <void>Add contact in a room
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room
Param
Type
contact
Contact
Example
room.del(contact) ⇒ Promise <void>
Promise <void>Delete a contact from the room It works only when the bot is the owner of the room
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room
Param
Type
contact
Contact
Example
room.quit() ⇒ Promise <void>
Promise <void>Bot quit the room itself
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room Example
room.topic([newTopic]) ⇒ Promise <void | string>
Promise <void | string>SET/GET topic from the room
Kind: instance method of Room
Param
Type
Description
[newTopic]
string
If set this para, it will change room topic.
Example (When you say anything in a room, it will get room topic. )
Example (When you say anything in a room, it will change room topic. )
room.announce([text]) ⇒ Promise <void | string>
Promise <void | string>SET/GET announce from the room
Tips: It only works when bot is the owner of the room.
This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room
Param
Type
Description
[text]
string
If set this para, it will change room announce.
Example (When you say anything in a room, it will get room announce. )
Example (When you say anything in a room, it will change room announce. )
room.qrcode() ⇒ Promise <string>
Promise <string>Get QR Code of the Room from the room, which can be used as scan and join the room.
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room
room.alias(contact) ⇒ Promise <string | null>
Promise <string | null>Return contact's roomAlias in the room
Kind: instance method of Room Returns: Promise <string | null> - - If a contact has an alias in room, return string, otherwise return null
Param
Type
contact
Contact
Example
room.has(contact) ⇒ Promise <boolean>
Promise <boolean>Check if the room has member contact, the return is a Promise and must be await-ed
Kind: instance method of Room Returns: Promise. - Return true if has contact, else return false.
Param
Type
contact
Contact
Example (Check whether 'lijiarui' is in the room 'wechaty')
room.memberAll([query]) ⇒ Promise <Contact []>
Promise <Contact []>Find all contacts in a room
definition
namethe name-string set by user-self, should be called name, equal toContact.name()roomAliasthe name-string set by user-self in the room, should be called roomAliascontactAliasthe name-string set by bot for others, should be called alias, equal toContact.alias()
Kind: instance method of Room
Param
Type
Description
[query]
RoomMemberQueryFilter | string
Optional parameter, When use memberAll(name:string), return all matched members, including name, roomAlias, contactAlias
Example
room.member(queryArg) ⇒ Promise <Contact | null>
Promise <Contact | null>Find all contacts in a room, if get many, return the first one.
Kind: instance method of Room
Param
Type
Description
queryArg
RoomMemberQueryFilter | string
When use member(name:string), return all matched members, including name, roomAlias, contactAlias
Example (Find member by name)
Example (Find member by MemberQueryFilter)
room.owner() ⇒ Contact | null
Contact | nullGet room's owner from the room.
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room Example
room.avatar() ⇒ Promise <FileBox>
Promise <FileBox>Get room's avatar
Tips: This function is depending on the Puppet Implementation, see puppet-compatible-table
Kind: instance method of Room Example
Room.create(contactList, [topic]) ⇒ Promise <Room>
Promise <Room>Create a new room.
Kind: static method of Room
Param
Type
contactList
Array
[topic]
string
Example (Creat a room with 'lijiarui' and 'juxiaomi', the room topic is 'ding - created')
Room.findAll([query]) ⇒ Promise <Room []>
Promise <Room []>Find room by by filter: {topic: string | RegExp}, return all the matched room
Kind: static method of Room
Param
Type
[query]
Example
Room.find(query) ⇒ Promise <Room>
Promise <Room>Try to find a room by filter: {topic: string | RegExp}. If get many, return the first one.
Kind: static method of Room Returns: Promise <Room> - If can find the room, return Room, or return null
Param
Type
query
Example
RoomQueryFilter
The filter to find the room: {topic: string | RegExp}
Kind: global typedef Properties
Name
Type
topic
string
RoomEventName
Room Class Event Type
Kind: global typedef Properties
Name
Type
Description
join
string
Emit when anyone join any room.
topic
string
Get topic event, emitted when someone change room topic.
leave
string
Emit when anyone leave the room. If someone leaves the room by themselves, wechat will not notice other people in the room, so the bot will never get the "leave" event.
RoomEventFunction
Room Class Event Function
Kind: global typedef Properties
Name
Type
Description
room-join
function
(this: Room, inviteeList: Contact[] , inviter: Contact) => void
room-topic
function
(this: Room, topic: string, oldTopic: string, changer: Contact) => void
room-leave
function
(this: Room, leaver: Contact) => void
RoomMemberQueryFilter
The way to search member by Room.member()
Kind: global typedef Properties
Name
Type
Description
name
string
Find the contact by wechat name in a room, equal to Contact.name().
roomAlias
string
Find the contact by alias set by the bot for others in a room.
contactAlias
string
Find the contact by alias set by the contact out of a room, equal to Contact.alias(). More Detail
Last updated
Was this helpful?