-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Run npm run doctor
or wechaty run doctor
(for docker user), paste output here
wechaty@0.5.9 doctor /wechaty
ts-node bin/doctor
Wechaty Doctor
- Wechaty version: 0.5.9
- Linux x64 version 3.16.0-4-amd64 memory 283/1000 MB
- Docker: true
- Node version: v7.1.0
Expected behavior
Using function 'Message.to()' to set the destination for the message, when the destination is Room, the function 'Wechaty.send(message) ' occured the following error:
ERR Wechaty send() exception: to.name is not a function
(node:34) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: to.name is not a function
Code
import { Wechaty,Message,Room} from 'wechaty'
const bot = Wechaty.instance()
bot
.on('scan' ,(url,code)=>{console.log(url)})
.on('login',username=>{console.log(username.name())})
.on('message', m=> {
const content = m.content()
var testmsg = new Message()
if(/^contact/.test(content)){
console.log(`receive message${content}`)
testmsg.to('lizhuohuan')
testmsg.content('hellomessage')
bot.send(testmsg)
}
if(/^filehelper/.test(content)){
console.log(`receive message${content}`)
testmsg.to('filehelper')
testmsg.content('hellomessage')
bot.send(testmsg)
}
if(/^roomname/.test(content)){
console.log(`receive message${content}`)
testmsg.to('testmsg')
testmsg.content('hellomessage')
bot.send(testmsg)
}
if(/^roomid/.test(content)){
console.log(`receive message${content}`)
testmsg.to('@@85c81ebaabbaf9ab18b2e4b358e032fc2add11d232a9a16c1bc0c07a19567f5a')
testmsg.content('hellomessage')
bot.send(testmsg)
}
if(/^room/.test(content)){
Room.find({topic:'testmsg'})
.then(roomfind=>{
if(roomfind){
console.log(`roomfind---${roomfind.topic()}`)
testmsg.to(roomfind)
testmsg.content('sendhello')
console.log(testmsg.to())
bot.send(testmsg)
}
})
}
})
.init()
In order to find the reason, I tried 5 methods to test as the above code shows, and find something useful as follows:
1.send message to a contact(the parameter is "微信号")
log as follows:
SILL Contact constructor(MissJuzimi)
SILL PuppetWeb send() destination: , content: hellomessage)
Although log showed destination is null, but my contact 'MissJuzimi' can receive the message 'hellomessage'
No Error Report
2.send message to a filehelper
log as follows:
SILL PuppetWeb send() destination: File Transfer, content: hellomessage)
filehelper can receive the message 'hellomessage'
No Error Report
3.send message to a room called 'testmsg'(parameter is roomtopic)
log as follows:
SILL Contact constructor(testmsg)
SILL PuppetWeb send() destination: , content: hellomessage)
the log showed destination is null, Room 'testmsg' cannot receive the message 'hellomessage' .I thought maybe the code dealt 'testmsg' as '微信号', and it can't find 'testmsg' in my friend, so it failed to send the message.
No Error Report
4.send message to a room called 'testmsg'(parameter is roomid)
log as follows:
SILL Room constructor(@@85c81ebaabbaf9ab18b2e4b358e032fc2add11d232a9a16c1bc0c07a19567f5a)
ERR Wechaty send() exception: to.name is not a function
(node:34) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: to.name is not a function
(node:34) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
No PuppetWeb send(),Error Report.
5.send message to a room called 'testmsg'(parameter is Room)
log as follows:
ERR Wechaty send() exception: to.name is not a function
(node:34) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: to.name is not a function
No PuppetWeb send(),Error Report.
Paste the full output logs here with WECHATY_LOG=silly
set
As the code showd above, I used function 'wechaty.send()' in following scenario:
1.send message to a contact(the parameter is "微信号")
if(/^contact/.test(content)){
console.log(`receive message${content}`)
testmsg.to('lizhuohuan')
testmsg.content('hellomessage')
bot.send(testmsg)
}
SILL Message constructor() SN:62
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message constructor() SN:63
receive messagecontact
SILL Contact constructor(MissJuzimi)
SILL PuppetWeb send() destination: , content: hellomessage)
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Message constructor() SN:64
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Contact contactGetter(MissJuzimi) resolved
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Contact contactGetter(MissJuzimi) resolved
SILL Message constructor() SN:65
2.send message to a filehelper
if(/^filehelper/.test(content)){
console.log(`receive message${content}`)
testmsg.to('filehelper')
testmsg.content('hellomessage')
bot.send(testmsg)
}
SILL Message constructor() SN:14
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message constructor() SN:15
receive messagefilehelper
SILL PuppetWeb send() destination: File Transfer, content: hellomessage)
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Message constructor() SN:16
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message constructor() SN:17
3.send message to a room called 'testmsg'(parameter is roomtopic)
if(/^roomname$/.test(content)){
console.log(`receive message${content}`)
testmsg.to('testmsg')
testmsg.content('hellomessage')
bot.send(testmsg)
}
SILL Message constructor() SN:3
receive messageroomname
SILL Contact constructor(testmsg)
SILL PuppetWeb send() destination: , content: hellomessage)
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Message constructor() SN:4
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Contact contactGetter(testmsg) resolved
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Contact contactGetter(testmsg) resolved
SILL Message constructor() SN:5
4.send message to a room called 'testmsg'(parameter is roomid)
if(/^roomid$/.test(content)){
console.log(`receive message${content}`)
testmsg.to('@@85c81ebaabbaf9ab18b2e4b358e032fc2add11d232a9a16c1bc0c07a19567f5a')
testmsg.content('hellomessage')
bot.send(testmsg)
}
SILL Message constructor() SN:6
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message constructor() SN:7
receive messageroomid
SILL Room constructor(@@85c81ebaabbaf9ab18b2e4b358e032fc2add11d232a9a16c1bc0c07a19567f5a)
ERR Wechaty send() exception: to.name is not a function
(node:34) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: to.name is not a function
(node:34) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
5.send message to a room called 'testmsg'(parameter is Room)
if(/^room$/.test(content)){
Room.find({topic:'testmsg'})
.then(roomfind=>{
if(roomfind){
console.log(`roomfind---${roomfind.topic()}`)
testmsg.to(roomfind)
testmsg.content('sendhello')
console.log(testmsg.to())
bot.send(testmsg)
}
})
}
SILL Message constructor() SN:8
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message constructor() SN:9
VERB Room find({ topic: testmsg })
VERB Room findAll({ topic: testmsg })
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Room constructor(@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d)
SILL Room ready()
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Room contactGetter(@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d) resolved
SILL Contact constructor(@30caeda9cac31070014cbfac5a8f2ff89e653c7573e9116da7f57351ed4815ef)
SILL Contact constructor(@704a71ffdd97ec88cc54c72ff510a333e3f03632d5dee73331f4cc5ab38882c2)
VERB Contact remark()
VERB Contact remark()
VERB Contact remark()
SILL Contact ready(function)
SILL Contact ready(function)
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL Contact ready(function)
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() open
SILL Contact contactGetter(@30caeda9cac31070014cbfac5a8f2ff89e653c7573e9116da7f57351ed4815ef) resolved
SILL Contact contactGetter(@704a71ffdd97ec88cc54c72ff510a333e3f03632d5dee73331f4cc5ab38882c2) resolved
roomfind---testmsg
Room {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
id: '@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d',
rawObj:
{ Alias: '',
AppAccountFlag: 0,
AttrStatus: 0,
ChatRoomId: 0,
City: '',
ContactFlag: 0,
DisplayName: '',
EncryChatRoomId: '@04fbafa7ee5e60459976be35388159c2',
HeadImgUrl: '/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d&skey=',
HideInputBarFlag: 0,
KeyWord: '',
MMFromBatchGet: true,
MMFromBatchget: true,
MMInChatroom: true,
MMOrderSymbol: 'TESTMSG',
MemberCount: 3,
MemberList: [ [Object], [Object], [Object] ],
NickName: 'testmsg',
OwnerUin: 121141715,
PYInitial: 'TESTMSG',
PYQuanPin: 'testmsg',
Province: '',
RemarkName: '',
RemarkPYInitial: '',
RemarkPYQuanPin: '',
Sex: 0,
Signature: '',
SnsFlag: 0,
StarFriend: 0,
Statues: 1,
Uin: 0,
UniFriend: 0,
UserName: '@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d',
VerifyFlag: 0,
stranger: true },
obj:
{ id: '@@8fea12bb9003ff485823d9f2fb91a9117e82289e6dfe17b0c0364853f61d806d',
encryId: '@04fbafa7ee5e60459976be35388159c2',
topic: 'testmsg',
ownerUin: 121141715,
memberList: [ [Object], [Object], [Object] ],
nickMap:
Map {
'@875673659a0a8d00fd964584ea07fdb7': '李佳芮',
'@30caeda9cac31070014cbfac5a8f2ff89e653c7573e9116da7f57351ed4815ef': '邀群助手',
'@704a71ffdd97ec88cc54c72ff510a333e3f03632d5dee73331f4cc5ab38882c2': 'wuli舞哩客服' } } }
ERR Wechaty send() exception: to.name is not a function
(node:34) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: to.name is not a function