Skip to content

ppagent / DingRobotSource

Class: DingRobotSource

Defined in: src/source/ding.robot.source.ts:146

需要开启机器人发消息相关权限、通讯录和部门管理相关权限、应用管理相关权限、互动卡片相关权限

钉钉支持直接引用外部图片显示,因此需要本服务器具备公网访问能力

钉钉应用机器人暂不支持@人,webhook机器人支持,因此可以配合使用

Implements

Constructors

Constructor

new DingRobotSource(_app, _options): DingRobotSource

Defined in: src/source/ding.robot.source.ts:326

Parameters

_app

PPAgent

_options

IDingRobotSourceOptions

Returns

DingRobotSource

Properties

event

event: Emittery

Defined in: src/source/ding.robot.source.ts:364

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

Implementation of

ISource.event


params

static params: IDingRobotSourceParams

Defined in: src/source/ding.robot.source.ts:147

Accessors

actions

Get Signature

get actions(): ISourceActionInfo[]

Defined in: src/source/ding.robot.source.ts:361

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

Returns

ISourceActionInfo[]

Implementation of

ISource.actions


options

Get Signature

get options(): IDingRobotSourceOptions

Defined in: src/source/ding.robot.source.ts:358

初始化过程中的动态参数

Returns

IDingRobotSourceOptions

Implementation of

ISource.options


params

Get Signature

get params(): ISourceParamas

Defined in: src/source/ding.robot.source.ts:355

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

Returns

ISourceParamas

Implementation of

ISource.params

Methods

afterSend()

afterSend(sourceMessage): Promise<void>

Defined in: src/source/ding.robot.source.ts:1055

当agent把内容发送给bot之后,可以用来给source释放相关资源,如结束卡片的写入状态。

Parameters

sourceMessage

ISourceChatMessage

Returns

Promise<void>

Implementation of

ISource.afterSend


beforeSend()

beforeSend(sourceMessage): Promise<void>

Defined in: src/source/ding.robot.source.ts:1007

当agent把内容送给bot回复之前。可以用来做一系列的准备工作,如提前下发卡片stream卡片。

Parameters

sourceMessage

ISourceChatMessage

Returns

Promise<void>

Implementation of

ISource.beforeSend


dispose()

dispose(): Promise<string>

Defined in: src/source/ding.robot.source.ts:1144

Returns

Promise<string>

Implementation of

IDisposable.dispose


getContactDetail()

getContactDetail(baseInfo): Promise<ISourceUserInfo>

Defined in: src/source/ding.robot.source.ts:1140

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

Parameters

baseInfo

ISourceUserInfo

Returns

Promise<ISourceUserInfo>

Implementation of

ISource.getContactDetail


getContacts()

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

Defined in: src/source/ding.robot.source.ts:1091

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

Parameters

mode

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

"all" | "user" | "group"

forece

boolean = false

Returns

Promise<object & Partial<ISourceUserInfo>[]>

Implementation of

ISource.getContacts


hasLogin()

hasLogin(): boolean

Defined in: src/source/ding.robot.source.ts:947

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

Returns

boolean

Implementation of

ISource.hasLogin


login()

login(): Promise<void>

Defined in: src/source/ding.robot.source.ts:957

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

Returns

Promise<void>

Implementation of

ISource.login


me()

me(): Promise<ISourceUserInfo>

Defined in: src/source/ding.robot.source.ts:910

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

Returns

Promise<ISourceUserInfo>

Implementation of

ISource.me


sendMessage()

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

Defined in: src/source/ding.robot.source.ts:1073

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

Parameters

message

ISourceChatMessage

要发送的消息

fromMessage?

ISourceChatMessage

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

Returns

Promise<string>

Implementation of

ISource.sendMessage