提交 4a46be78 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

#33 add verify user interface in WechatyBro

上级 f6c8f419
......@@ -423,7 +423,7 @@ this.onResourceRequested = function(request, net) {
return this.driver.executeScript.apply(this.driver, arguments)
.catch(e => {
// this.dead(e)
log.warn('PuppetWebBrowser', 'execute() exception: %s', e.message)
log.warn('PuppetWebBrowser', 'execute() exception: %s', e.message.substr(0,99))
throw e
})
}
......
......@@ -266,6 +266,7 @@ class PuppetWeb extends Puppet {
return this.userId == message.get('from')
}
send(message) {
const to = message.get('to')
const room = message.get('room')
......@@ -275,6 +276,7 @@ class PuppetWeb extends Puppet {
let destination = to
if (room) {
destination = room
// TODO use the right @
// if (to && to!==room) {
// content = `@[${to}] ${content}`
// }
......@@ -287,6 +289,7 @@ class PuppetWeb extends Puppet {
throw e
})
}
reply(message, replyContent) {
if (this.self(message)) {
return Promise.reject(new Error('will not to reply message of myself'))
......@@ -301,10 +304,10 @@ class PuppetWeb extends Puppet {
// log.verbose('PuppetWeb', 'reply() by message: %s', util.inspect(m))
return this.send(m)
.catch(e => {
log.error('PuppetWeb', 'reply() exception: %s', e.message)
throw e
})
.catch(e => {
log.error('PuppetWeb', 'reply() exception: %s', e.message)
throw e
})
}
/**
......
......@@ -502,10 +502,57 @@
return 'no callback (yet)'
}
function verifyUserRequest(UserName, VerifyContent = '') {
var contactFactory = WechatyBro.glue.contactFactory
var confFactory = WechatyBro.glue.confFactory
var Ticket = '' // what's this?
contactFactory.verifyUser({
UserName
, Opcode: confFactory.VERIFYUSER_OPCODE_SENDREQUEST
, Scene: confFactory.ADDSCENE_PF_WEB
, Ticket
, VerifyContent
})
.then(function() { // succ
// alert('ok')
log('friendAdd(' + UserName + ', ' + VerifyContent + ') succ')
}, function(t) { // fail
// alert('not ok')
log('friendAdd(' + UserName + ', ' + VerifyContent + ') fail: ' + t)
})
}
function verifyUserOk(UserName, Ticket) {
var contactFactory = WechatyBro.glue.contactFactory
var confFactory = WechatyBro.glue.confFactory
contactFactory.verifyUser({
UserName
, Opcode: confFactory.VERIFYUSER_OPCODE_VERIFYOK
, Scene: confFactory.ADDSCENE_PF_WEB
, Ticket
}).then(function() { // succ
// alert('ok')
log('friendVerify(' + UserName + ', ' + Ticket + ') succ')
}, function() { // fail
// alert('err')
log('friendVerify(' + UserName + ', ' + Ticket + ') fail')
})
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
port = port || 8788
/*
......@@ -567,6 +614,12 @@
, roomDelMember
, roomModTopic
// for Friend Request
, verifyUserRequest
, verifyUserOk
// , friendAdd
// , friendVerify
// test purpose
, isLogin: isLogin
, initClog: initClog
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册