Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
596943f0
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
596943f0
编写于
10月 31, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#34 add `Contact.remark(newRemark: string)` support
上级
028fb3a6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
89 addition
and
1 deletion
+89
-1
src/contact.ts
src/contact.ts
+27
-1
src/puppet-web/bridge.ts
src/puppet-web/bridge.ts
+9
-0
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+16
-0
src/puppet-web/wechaty-bro.js
src/puppet-web/wechaty-bro.js
+36
-0
src/puppet.ts
src/puppet.ts
+1
-0
未找到文件。
src/contact.ts
浏览文件 @
596943f0
...
...
@@ -92,7 +92,6 @@ export class Contact implements Sayable {
public
weixin
()
{
return
this
.
obj
&&
this
.
obj
.
weixin
||
''
}
public
name
()
{
return
UtilLib
.
plainText
(
this
.
obj
&&
this
.
obj
.
name
||
''
)
}
public
remark
()
{
return
this
.
obj
&&
this
.
obj
.
remark
}
public
stranger
()
{
return
this
.
obj
&&
this
.
obj
.
stranger
}
public
star
()
{
return
this
.
obj
&&
this
.
obj
.
star
}
...
...
@@ -199,6 +198,33 @@ export class Contact implements Sayable {
})
}
/**
* get the remark for contact
*/
public
remark
():
string
/**
* set the remark for contact
*/
public
remark
(
newRemark
:
string
):
Promise
<
boolean
>
public
remark
(
newRemark
?:
string
):
Promise
<
boolean
>
|
string
{
log
.
verbose
(
'
Contact
'
,
'
remark(%s)
'
,
newRemark
||
''
)
if
(
newRemark
===
undefined
)
{
return
this
.
obj
&&
this
.
obj
.
remark
||
''
}
return
Config
.
puppetInstance
()
.
contactRemark
(
this
,
newRemark
)
.
catch
(
e
=>
{
log
.
error
(
'
Contact
'
,
'
remark(%s) rejected: %s
'
,
newRemark
,
e
.
message
)
return
false
// fail safe
})
}
/**
* try to find a contact by filter: {name: string | RegExp}
*/
public
static
async
find
(
query
:
ContactQueryFilter
):
Promise
<
Contact
>
{
log
.
verbose
(
'
Contact
'
,
'
find(%s)
'
,
query
.
name
)
...
...
src/puppet-web/bridge.ts
浏览文件 @
596943f0
...
...
@@ -129,6 +129,15 @@ export class Bridge {
})
}
public
async
contactRemark
(
contactId
:
string
,
remark
:
string
):
Promise
<
boolean
>
{
try
{
return
await
this
.
proxyWechaty
(
'
contactRemarkAsync
'
,
contactId
,
remark
)
}
catch
(
e
)
{
log
.
error
(
'
PuppetWebBridge
'
,
'
contactRemarkAsync() exception: %s
'
,
e
.
message
)
throw
e
}
}
public
contactFind
(
filterFunc
:
string
):
Promise
<
string
[]
>
{
return
this
.
proxyWechaty
(
'
contactFindAsync
'
,
filterFunc
)
.
catch
(
e
=>
{
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
596943f0
...
...
@@ -370,6 +370,22 @@ export class PuppetWeb extends Puppet {
})
}
public
async
contactRemark
(
contact
:
Contact
,
remark
:
string
):
Promise
<
boolean
>
{
try
{
const
ret
=
await
this
.
bridge
.
contactRemark
(
contact
.
id
,
remark
)
if
(
!
ret
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
contactRemark(%s, %s) bridge.contactRemark() return false
'
,
contact
.
id
,
remark
)
}
return
ret
}
catch
(
e
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
contactFind(%s) rejected: %s
'
,
filterFunc
,
e
.
message
)
throw
e
}
}
public
contactFind
(
filterFunc
:
string
):
Promise
<
Contact
[]
>
{
if
(
!
this
.
bridge
)
{
return
Promise
.
reject
(
new
Error
(
'
contactFind fail: no bridge(yet)!
'
))
...
...
src/puppet-web/wechaty-bro.js
浏览文件 @
596943f0
...
...
@@ -196,6 +196,7 @@
var
chatFactory
=
injector
.
get
(
'
chatFactory
'
)
var
contactFactory
=
injector
.
get
(
'
contactFactory
'
)
var
confFactory
=
injector
.
get
(
'
confFactory
'
)
var
emojiFactory
=
injector
.
get
(
'
emojiFactory
'
)
var
loginFactory
=
injector
.
get
(
'
loginFactory
'
)
var
http
=
injector
.
get
(
'
$http
'
)
...
...
@@ -244,6 +245,7 @@
WechatyBro
.
glue
=
{
injector
:
injector
,
http
:
http
,
mmHttp
,
state
,
accountFactory
:
accountFactory
...
...
@@ -251,6 +253,7 @@
,
chatFactory
:
chatFactory
,
confFactory
:
confFactory
,
contactFactory
:
contactFactory
,
emojiFactory
,
loginFactory
:
loginFactory
,
rootScope
:
rootScope
...
...
@@ -520,6 +523,38 @@
}
}
function
contactRemarkAsync
(
UserName
,
remark
)
{
const
callback
=
arguments
[
arguments
.
length
-
1
]
if
(
typeof
callback
!==
'
function
'
)
{
// here we should in sync mode, because there's no callback
throw
new
Error
(
'
async method need to be called via webdriver.executeAsyncScript
'
)
}
var
accountFactory
=
WechatyBro
.
glue
.
accountFactory
var
confFactory
=
WechatyBro
.
glue
.
confFactory
var
emojiFactory
=
WechatyBro
.
glue
.
emojiFactory
var
mmHttp
=
WechatyBro
.
glue
.
mmHttp
mmHttp
({
method
:
"
POST
"
,
url
:
confFactory
.
API_webwxoplog
,
data
:
angular
.
extend
({
UserName
:
UserName
,
CmdId
:
confFactory
.
oplogCmdId
.
MODREMARKNAME
,
RemarkName
:
emojiFactory
.
formatHTMLToSend
(
remark
)
},
accountFactory
.
getBaseRequest
()),
MMRetry
:
{
count
:
3
,
timeout
:
1
e4
,
serial
:
!
0
}
}).
success
(
function
()
{
callback
(
true
)
}).
error
(
function
()
{
callback
(
false
)
})
}
function
roomFind
(
filterFunction
)
{
var
contactFactory
=
WechatyBro
.
glue
.
contactFactory
...
...
@@ -703,6 +738,7 @@
// for Wechaty Contact Class
,
contactFindAsync
,
contactRemarkAsync
// for Wechaty Room Class
,
roomCreateAsync
...
...
src/puppet.ts
浏览文件 @
596943f0
...
...
@@ -81,6 +81,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
* Contact
*/
public
abstract
contactFind
(
filterFunc
:
string
):
Promise
<
Contact
[]
>
public
abstract
contactRemark
(
contact
:
Contact
,
remark
:
string
):
Promise
<
boolean
>
}
export
default
Puppet
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录