ppagent / WeWorkSource
Class: WeWorkSource
Defined in: src/source/wework.source.ts:238
企业微信应用的消息源。支持应用单聊,客服聊天以及应用和机器人的单向群推送(应用推送仅支持通过应用接口创建的群,没有机器人方便,且机器人支持Markdown,但是机器人不支持发送视频) 群消息一次只发送一个群。只有机器人消息支持@
如果希望一次性发给一群人,可以使用应用单聊同事发送多个对象,支持发群到部门ID或者标签ID,而不需要通过群
注意:当启动后第一次收到客服消息时,仅会处理最新的一条客服消息。后续有新的消息进来时,将会处理最后一次到当前消息之间所有的消息。
企微的客服逻辑:创建应用-设置应用可以通过API访问(允许的JS回调需先配置)以及可信IP-设置API接收,勾选接收客服消息;微信客服中创建一个客服,指定一个接待人员,最下方打开通过API管理会话消息的企业内部开发,选中之前创建的应用
这样就可以通过这个应用来管理刚创建的客服的对话了,默认是机器人接管状态,有需要转人工可通过调用转人工接口实现转人工或者其他状态的流转。
Implements
Constructors
Constructor
new WeWorkSource(
_app
,_options
):WeWorkSource
Defined in: src/source/wework.source.ts:467
Parameters
_app
_options
Returns
WeWorkSource
Properties
event
event:
Emittery
Defined in: src/source/wework.source.ts:499
用户发布订阅事件的对象,事件类型为SourceEventType
Implementation of
params
static
params:ISourceParamas
Defined in: src/source/wework.source.ts:239
Accessors
actions
Get Signature
get actions():
ISourceActionInfo
[]
Defined in: src/source/wework.source.ts:487
消息源的路由和ws处理器列表,需要在消息源的构造函数阶段创建
Returns
Implementation of
options
Get Signature
get options():
ISourceOptions
Defined in: src/source/wework.source.ts:484
初始化过程中的动态参数
Returns
Implementation of
params
Get Signature
get params():
ISourceParamas
Defined in: src/source/wework.source.ts:481
这个Source的固有属性,比如source的平台名称
Returns
Implementation of
Methods
createAppGroupChats()
createAppGroupChats(
info
):Promise
<void
>
Defined in: src/source/wework.source.ts:1647
Parameters
info
object
[]
Returns
Promise
<void
>
getContactDetail()
getContactDetail(
baseInfo
):Promise
<ISourceUserInfo
>
Defined in: src/source/wework.source.ts:1643
根据获取联系人列表接口返回的粗略信息
Parameters
baseInfo
Returns
Promise
<ISourceUserInfo
>
Implementation of
getContacts()
getContacts(
mode
,force
):Promise
<object
&Partial
<ISourceUserInfo
>[]>
Defined in: src/source/wework.source.ts:1639
获取用户信息,至少返回nickName
Parameters
mode
all返回全部,user仅返回个人用户,group仅返回群组
"all"
| "user"
| "group"
force
boolean
= false
Returns
Promise
<object
& Partial
<ISourceUserInfo
>[]>
Implementation of
hasLogin()
hasLogin():
boolean
Defined in: src/source/wework.source.ts:1576
是否是登录状态。仅被用来检查登录状态,未登录不代表出错,也可能是正处于登录中。
Returns
boolean
Implementation of
login()
login():
Promise
<void
>
Defined in: src/source/wework.source.ts:1586
执行登录,如果有需要扫码等,应发出全局TODO事件,登录成功后发出LOGIN消息,并携带用户信息
Returns
Promise
<void
>
Implementation of
me()
me(
force?
):Promise
<ISourceUserInfo
>
Defined in: src/source/wework.source.ts:1550
获取当前登录用户的个人信息
Parameters
force?
boolean
Returns
Promise
<ISourceUserInfo
>
Implementation of
sendMessage()
sendMessage(
message
,fromMessage?
):Promise
<string
>
Defined in: src/source/wework.source.ts:1609
发送消息,如果返回内容不为空,说明发送失败
Parameters
message
要发送的消息
fromMessage?
该条消息如果是对某条消息的响应,可以传入原始消息。某些平台可能只允许被动发送消息,此时可能需要用到原始触发回复的那条消息。
Returns
Promise
<string
>