Skip to content

ppagent / WCAISource

Class: WCAISource

Defined in: src/source/wcai.source.ts:54

微信对话开放平台的消息源。支持公众号、企业微信、小程序、微信客服、网页H5

Implements

Constructors

Constructor

new WCAISource(_app, _options): WCAISource

Defined in: src/source/wcai.source.ts:163

Parameters

_app

PPAgent

_options

IWCAISourceOptions

Returns

WCAISource

Properties

event

event: Emittery

Defined in: src/source/wcai.source.ts:198

用户发布订阅事件的对象,事件类型为SourceEventType

Implementation of

ISource.event


params

static params: ISourceParamas

Defined in: src/source/wcai.source.ts:55

Accessors

actions

Get Signature

get actions(): ISourceActionInfo[]

Defined in: src/source/wcai.source.ts:185

消息源的路由和ws处理器列表,需要在消息源的构造函数阶段创建

Returns

ISourceActionInfo[]

Implementation of

ISource.actions


options

Get Signature

get options(): ISourceOptions

Defined in: src/source/wcai.source.ts:181

初始化过程中的动态参数

Returns

ISourceOptions

Implementation of

ISource.options


params

Get Signature

get params(): ISourceParamas

Defined in: src/source/wcai.source.ts:177

这个Source的固有属性,比如source的平台名称

Returns

ISourceParamas

Implementation of

ISource.params

Methods

getContactDetail()

getContactDetail(baseInfo): Promise<ISourceUserInfo>

Defined in: src/source/wcai.source.ts:532

根据获取联系人列表接口返回的粗略信息

Parameters

baseInfo

ISourceUserInfo

Returns

Promise<ISourceUserInfo>

Implementation of

ISource.getContactDetail


getContacts()

getContacts(mode, force): Promise<object & Partial<ISourceUserInfo>[]>

Defined in: src/source/wcai.source.ts:528

获取用户信息,至少返回nickName

Parameters

mode

all返回全部,user仅返回个人用户,group仅返回群组

"all" | "user" | "group"

force

boolean = false

Returns

Promise<object & Partial<ISourceUserInfo>[]>

Implementation of

ISource.getContacts


hasLogin()

hasLogin(): boolean

Defined in: src/source/wcai.source.ts:310

是否是登录状态。仅被用来检查登录状态,未登录不代表出错,也可能是正处于登录中。

Returns

boolean

Implementation of

ISource.hasLogin


login()

login(): Promise<void>

Defined in: src/source/wcai.source.ts:314

执行登录,如果有需要扫码等,应发出全局TODO事件,登录成功后发出LOGIN消息,并携带用户信息

Returns

Promise<void>

Implementation of

ISource.login


me()

me(): Promise<ISourceUserInfo>

Defined in: src/source/wcai.source.ts:306

获取当前登录用户的个人信息

Returns

Promise<ISourceUserInfo>

Implementation of

ISource.me


sendMessage()

sendMessage(message, fromMessage?): Promise<string>

Defined in: src/source/wcai.source.ts:318

发送消息,如果返回内容不为空,说明发送失败

Parameters

message

ISourceChatMessage

要发送的消息

fromMessage?

ISourceChatMessage

该条消息如果是对某条消息的响应,可以传入原始消息。某些平台可能只允许被动发送消息,此时可能需要用到原始触发回复的那条消息。

Returns

Promise<string>

Implementation of

ISource.sendMessage