wechaty-puppet

Wechaty Puppet v0.9.12 Interface > Puppet

Class: Puppet

Puppet Base Class

See: https://github.com/Chatie/wechaty/wiki/Puppet

Hierarchy

EventEmitter

↳ Puppet

Index

Constructors

Properties

Methods


Constructors

constructor

new Puppet(options?: PuppetOptions): Puppet

Defined in src/puppet.ts:127

Constructor

Parameters:

Param Type Default value
Default value options PuppetOptions {}

Returns: Puppet


Properties

<Static> VERSION

● VERSION: “0.0.0” = “0.0.0”

Defined in src/puppet.ts:100

Must overwrite by child class to identify their version


<Static> defaultMaxListeners

● defaultMaxListeners: number

Inherited from EventEmitter.defaultMaxListeners

Defined in node_modules/@types/node/index.d.ts:1022


Methods

addListener

addListener(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.addListener

Overrides EventEmitter.addListener

Defined in node_modules/@types/node/index.d.ts:1024

Parameters:

Param Type
event string | symbol
listener function

Returns: this


<Abstract> contactAlias

contactAlias(contactId: string): Promise<string>

contactAlias(contactId: string, alias: * string | null*): Promise<void>

Defined in src/puppet.ts:460

Contact

Parameters:

Param Type
contactId string

Returns: Promise<string>

Defined in src/puppet.ts:461

Parameters:

Param Type
contactId string
alias string | null

Returns: Promise<void>


<Abstract> contactAvatar

contactAvatar(contactId: string): Promise<FileBox>

contactAvatar(contactId: string, file: FileBox): Promise<void>

Defined in src/puppet.ts:463

Parameters:

Param Type
contactId string

Returns: Promise<FileBox>

Defined in src/puppet.ts:464

Parameters:

Param Type
contactId string
file FileBox

Returns: Promise<void>


<Abstract> contactList

contactList(): Promise<string[]>

Defined in src/puppet.ts:466

Returns: Promise<string[]>


contactPayload

contactPayload(contactId: string): Promise<ContactPayload>

Defined in src/puppet.ts:644

Parameters:

Param Type
contactId string

Returns: Promise<ContactPayload>


<Abstract> contactQrcode

contactQrcode(contactId: string): Promise<string>

Defined in src/puppet.ts:468

Parameters:

Param Type
contactId string

Returns: Promise<string>


contactRoomList

contactRoomList(contactId: string): Promise<string[]>

Defined in src/puppet.ts:473

Parameters:

Param Type
contactId string

Returns: Promise<string[]>


contactSearch

contactSearch(query?: * string | ContactQueryFilter, searchIdList?: *string[]): Promise<string[]>

Defined in src/puppet.ts:496

Parameters:

Param Type
Optional query string | ContactQueryFilter
Optional searchIdList string[]

Returns: Promise<string[]>


contactValidate

contactValidate(contactId: string): Promise<boolean>

Defined in src/puppet.ts:623

Check a Contact Id if it’s still valid. For example: talk to the server, and see if it should be deleted in the local cache.

Parameters:

Param Type
contactId string

Returns: Promise<boolean>


<Abstract> ding

ding(data?: * undefined | string*): void

Defined in src/puppet.ts:415

Check whether the puppet is work property.

Parameters:

Param Type
Optional data undefined | string

Returns: void false if something went wrong ‘dong’ if everything is OK


emit

emit(event: “dong”, data?: * undefined | string*): boolean

emit(event: “error”, error: Error): boolean

emit(event: “friendship”, friendshipId: string): boolean

emit(event: “login”, contactId: string): boolean

emit(event: “logout”, contactId: string): boolean

emit(event: “message”, messageId: string): boolean

emit(event: “reset”, reason: string): boolean

emit(event: “room-join”, roomId: string, inviteeIdList: string[], inviterId: string): boolean

emit(event: “room-leave”, roomId: string, leaverIdList: string[], remover?: * undefined | string*): boolean

emit(event: “room-topic”, roomId: string, newTopic: string, oldTopic: string, changerId: string): boolean

emit(event: “room-invite”, roomInvitationId: string): boolean

emit(event: “scan”, qrcode: string, status: number, data?: * undefined | string*): boolean

emit(event: “watchdog”, food: WatchdogFood): boolean

emit(event: never, …args: never[]): never

Overrides EventEmitter.emit

Defined in src/puppet.ts:263

Events

Parameters:

Param Type
event “dong”
Optional data undefined | string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:264

Parameters:

Param Type
event “error”
error Error

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:265

Parameters:

Param Type
event “friendship”
friendshipId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:266

Parameters:

Param Type
event “login”
contactId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:267

Parameters:

Param Type
event “logout”
contactId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:268

Parameters:

Param Type
event “message”
messageId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:269

Parameters:

Param Type
event “reset”
reason string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:270

Parameters:

Param Type
event “room-join”
roomId string
inviteeIdList string[]
inviterId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:271

Parameters:

Param Type
event “room-leave”
roomId string
leaverIdList string[]
Optional remover undefined | string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:272

Parameters:

Param Type
event “room-topic”
roomId string
newTopic string
oldTopic string
changerId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:273

Parameters:

Param Type
event “room-invite”
roomInvitationId string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:274

Parameters:

Param Type
event “scan”
qrcode string
status number
Optional data undefined | string

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:276

Parameters:

Param Type
event “watchdog”
food WatchdogFood

Returns: boolean

Overrides EventEmitter.emit

Defined in src/puppet.ts:278

Parameters:

Param Type
event never
Rest args never[]

Returns: never


eventNames

eventNames(): Array< string | symbol>

Inherited from EventEmitter.eventNames

Overrides EventEmitter.eventNames

Defined in node_modules/@types/node/index.d.ts:1037

Returns: Array< string | symbol>


<Abstract> friendshipAccept

friendshipAccept(friendshipId: string): Promise<void>

Defined in src/puppet.ts:679

Parameters:

Param Type
friendshipId string

Returns: Promise<void>


<Abstract> friendshipAdd

friendshipAdd(contactId: string, hello?: * undefined | string*): Promise<void>

Defined in src/puppet.ts:678

Friendship

Parameters:

Param Type
contactId string
Optional hello undefined | string

Returns: Promise<void>


friendshipPayload

friendshipPayload(friendshipId: string): Promise<FriendshipPayload>

Defined in src/puppet.ts:705

Parameters:

Param Type
friendshipId string

Returns: Promise<FriendshipPayload>


getMaxListeners

getMaxListeners(): number

Inherited from EventEmitter.getMaxListeners

Overrides EventEmitter.getMaxListeners

Defined in node_modules/@types/node/index.d.ts:1033

Returns: number


listenerCount

listenerCount(type: * string | symbol*): number

Inherited from EventEmitter.listenerCount

Overrides EventEmitter.listenerCount

Defined in node_modules/@types/node/index.d.ts:1038

Parameters:

Param Type
type string | symbol

Returns: number


listeners

listeners(event: * string | symbol*): Function[]

Inherited from EventEmitter.listeners

Overrides EventEmitter.listeners

Defined in node_modules/@types/node/index.d.ts:1034

Parameters:

Param Type
event string | symbol

Returns: Function[]


logonoff

logonoff(): boolean

Defined in src/puppet.ts:395

Returns: boolean


<Abstract> logout

logout(): Promise<void>

Defined in src/puppet.ts:383

Need to be called internaly/externaly when the puppet need to be logouted this method will emit a logout event,

Note: must set this.id = undefined in this function.

Returns: Promise<void>


<Abstract> messageFile

messageFile(messageId: string): Promise<FileBox>

Defined in src/puppet.ts:738

Message

Parameters:

Param Type
messageId string

Returns: Promise<FileBox>


<Abstract> messageForward

messageForward(receiver: Receiver, messageId: string): Promise<void>

Defined in src/puppet.ts:739

Parameters:

Param Type
receiver Receiver
messageId string

Returns: Promise<void>


messagePayload

messagePayload(messageId: string): Promise<MessagePayload>

Defined in src/puppet.ts:767

Parameters:

Param Type
messageId string

Returns: Promise<MessagePayload>


<Abstract> messageSendContact

messageSendContact(receiver: Receiver, contactId: string): Promise<void>

Defined in src/puppet.ts:741

Parameters:

Param Type
receiver Receiver
contactId string

Returns: Promise<void>


<Abstract> messageSendFile

messageSendFile(receiver: Receiver, file: FileBox): Promise<void>

Defined in src/puppet.ts:742

Parameters:

Param Type
receiver Receiver
file FileBox

Returns: Promise<void>


<Abstract> messageSendText

messageSendText(receiver: Receiver, text: string): Promise<void>

Defined in src/puppet.ts:740

Parameters:

Param Type
receiver Receiver
text string

Returns: Promise<void>


off

off(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.off

Overrides EventEmitter.off

Defined in node_modules/@types/node/index.d.ts:1030

Parameters:

Param Type
event string | symbol
listener function

Returns: this


on

on(event: “dong”, listener: function): this

on(event: “error”, listener: function): this

on(event: “friendship”, listener: function): this

on(event: “login”, listener: function): this

on(event: “logout”, listener: function): this

on(event: “message”, listener: function): this

on(event: “reset”, listener: function): this

on(event: “room-join”, listener: function): this

on(event: “room-leave”, listener: function): this

on(event: “room-topic”, listener: function): this

on(event: “room-invite”, listener: function): this

on(event: “scan”, listener: function): this

on(event: “watchdog”, listener: function): this

on(event: never, listener: never): never

Overrides EventEmitter.on

Defined in src/puppet.ts:294

Listeners

Parameters:

Param Type
event “dong”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:295

Parameters:

Param Type
event “error”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:296

Parameters:

Param Type
event “friendship”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:297

Parameters:

Param Type
event “login”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:298

Parameters:

Param Type
event “logout”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:299

Parameters:

Param Type
event “message”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:300

Parameters:

Param Type
event “reset”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:301

Parameters:

Param Type
event “room-join”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:302

Parameters:

Param Type
event “room-leave”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:303

Parameters:

Param Type
event “room-topic”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:304

Parameters:

Param Type
event “room-invite”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:305

Parameters:

Param Type
event “scan”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:307

Parameters:

Param Type
event “watchdog”
listener function

Returns: this

Overrides EventEmitter.on

Defined in src/puppet.ts:309

Parameters:

Param Type
event never
listener never

Returns: never


once

once(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.once

Overrides EventEmitter.once

Defined in node_modules/@types/node/index.d.ts:1026

Parameters:

Param Type
event string | symbol
listener function

Returns: this


prependListener

prependListener(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.prependListener

Overrides EventEmitter.prependListener

Defined in node_modules/@types/node/index.d.ts:1027

Parameters:

Param Type
event string | symbol
listener function

Returns: this


prependOnceListener

prependOnceListener(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.prependOnceListener

Overrides EventEmitter.prependOnceListener

Defined in node_modules/@types/node/index.d.ts:1028

Parameters:

Param Type
event string | symbol
listener function

Returns: this


rawListeners

rawListeners(event: * string | symbol*): Function[]

Inherited from EventEmitter.rawListeners

Overrides EventEmitter.rawListeners

Defined in node_modules/@types/node/index.d.ts:1035

Parameters:

Param Type
event string | symbol

Returns: Function[]


removeAllListeners

removeAllListeners(event?: * string | symbol*): this

Inherited from EventEmitter.removeAllListeners

Overrides EventEmitter.removeAllListeners

Defined in node_modules/@types/node/index.d.ts:1031

Parameters:

Param Type
Optional event string | symbol

Returns: this


removeListener

removeListener(event: * string | symbol, listener: *function): this

Inherited from EventEmitter.removeListener

Overrides EventEmitter.removeListener

Defined in node_modules/@types/node/index.d.ts:1029

Parameters:

Param Type
event string | symbol
listener function

Returns: this


<Abstract> roomAdd

roomAdd(roomId: string, contactId: string): Promise<void>

Defined in src/puppet.ts:818

Room

Parameters:

Param Type
roomId string
contactId string

Returns: Promise<void>


<Abstract> roomAnnounce

roomAnnounce(roomId: string): Promise<string>

roomAnnounce(roomId: string, text: string): Promise<void>

Defined in src/puppet.ts:839

Parameters:

Param Type
roomId string

Returns: Promise<string>

Defined in src/puppet.ts:840

Parameters:

Param Type
roomId string
text string

Returns: Promise<void>


<Abstract> roomAvatar

roomAvatar(roomId: string): Promise<FileBox>

Defined in src/puppet.ts:819

Parameters:

Param Type
roomId string

Returns: Promise<FileBox>


<Abstract> roomCreate

roomCreate(contactIdList: string[], topic?: * undefined | string*): Promise<string>

Defined in src/puppet.ts:820

Parameters:

Param Type
contactIdList string[]
Optional topic undefined | string

Returns: Promise<string>


<Abstract> roomDel

roomDel(roomId: string, contactId: string): Promise<void>

Defined in src/puppet.ts:821

Parameters:

Param Type
roomId string
contactId string

Returns: Promise<void>


<Abstract> roomInvitationAccept

roomInvitationAccept(roomInvitationId: string): Promise<void>

Defined in src/puppet.ts:801

Room Invitation

Parameters:

Param Type
roomInvitationId string

Returns: Promise<void>


roomInvitationPayload

roomInvitationPayload(roomInvitationId: string): Promise<RoomInvitationPayload>

Defined in src/puppet.ts:806

Parameters:

Param Type
roomInvitationId string

Returns: Promise<RoomInvitationPayload>


<Abstract> roomList

roomList(): Promise<string[]>

Defined in src/puppet.ts:830

Returns: Promise<string[]>


<Abstract> roomMemberList

roomMemberList(roomId: string): Promise<string[]>

Defined in src/puppet.ts:831

Parameters:

Param Type
roomId string

Returns: Promise<string[]>


roomMemberPayload

roomMemberPayload(roomId: string, contactId: string): Promise<RoomMemberPayload>

Defined in src/puppet.ts:1075

Parameters:

Param Type
roomId string
contactId string

Returns: Promise<RoomMemberPayload>


roomMemberSearch

roomMemberSearch(roomId: string, query: * string | unique symbol| RoomMemberQueryFilter*): Promise<string[]>

Defined in src/puppet.ts:842

Parameters:

Param Type
roomId string
query string | unique symbol| RoomMemberQueryFilter

Returns: Promise<string[]>


roomPayload

roomPayload(roomId: string): Promise<RoomPayload>

Defined in src/puppet.ts:1024

Parameters:

Param Type
roomId string

Returns: Promise<RoomPayload>


<Abstract> roomQrcode

roomQrcode(roomId: string): Promise<string>

Defined in src/puppet.ts:828

Parameters:

Param Type
roomId string

Returns: Promise<string>


<Abstract> roomQuit

roomQuit(roomId: string): Promise<void>

Defined in src/puppet.ts:822

Parameters:

Param Type
roomId string

Returns: Promise<void>


roomSearch

roomSearch(query?: RoomQueryFilter): Promise<string[]>

Defined in src/puppet.ts:922

Parameters:

Param Type
Optional query RoomQueryFilter

Returns: Promise<string[]>


<Abstract> roomTopic

roomTopic(roomId: string): Promise<string>

roomTopic(roomId: string, topic: string): Promise<void>

roomTopic(roomId: string, topic?: * undefined | string*): Promise< string | void>

Defined in src/puppet.ts:824

Parameters:

Param Type
roomId string

Returns: Promise<string>

Defined in src/puppet.ts:825

Parameters:

Param Type
roomId string
topic string

Returns: Promise<void>

Defined in src/puppet.ts:826

Parameters:

Param Type
roomId string
Optional topic undefined | string

Returns: Promise< string | void>


roomValidate

roomValidate(roomId: string): Promise<boolean>

Defined in src/puppet.ts:999

Check a Room Id if it’s still valid. For example: talk to the server, and see if it should be deleted in the local cache.

Parameters:

Param Type
roomId string

Returns: Promise<boolean>


selfId

selfId(): string

Defined in src/puppet.ts:385

Returns: string


setMaxListeners

setMaxListeners(n: number): this

Inherited from EventEmitter.setMaxListeners

Overrides EventEmitter.setMaxListeners

Defined in node_modules/@types/node/index.d.ts:1032

Parameters:

Param Type
n number

Returns: this


<Private> setMemory

setMemory(memory: MemoryCard): void

Defined in src/puppet.ts:246

Parameters:

Param Type
memory MemoryCard

Returns: void


<Abstract> start

start(): Promise<void>

Defined in src/puppet.ts:326

Start / Stop

Returns: Promise<void>


<Abstract> stop

stop(): Promise<void>

Defined in src/puppet.ts:327

Returns: Promise<void>


toString

toString(): string

Defined in src/puppet.ts:220

Returns: string


unref

unref(): void

Defined in src/puppet.ts:236

Unref

Returns: void


version

version(): string

Defined in src/puppet.ts:420

Get version from the Puppet Implementation

Returns: string


wechatyVersionRange

wechatyVersionRange(strict?: boolean): string

Defined in src/puppet.ts:430

will be used by semver.satisfied(version, range)

Parameters:

Param Type Default value
Default value strict boolean false

Returns: string


<Static> listenerCount

listenerCount(emitter: EventEmitter, event: * string | symbol*): number

Inherited from EventEmitter.listenerCount

Defined in node_modules/@types/node/index.d.ts:1021

deprecated: since v4.0.0

Parameters:

Param Type
emitter EventEmitter
event string | symbol

Returns: number