-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
无法自动通过好友请求 #115
Comments
Need More InformationSorry, you did not follow the ISSUE Template, and there's not enough information about your problem. In order to help us to find the problem out, you should provide the steps to reproduce the problem. I'll close this issue. Please re-submit a new issue to provide the information that needed. |
I'm sorry for not providing the standart issue... code as follows: import {
Wechaty
, log
, Room
} from 'wechaty'
const bot = Wechaty.instance({ profile: 'juzimi11' })
const AutoReply_1 = "hi,我是专门管理微信群的机器人,你要加入的群是 【切尔西】还是【曼城】?"
const AutoReply_2 = "回复我加群暗号,我会将你拉入指定的微信群"
let logMsg = ''
bot
.on('scan', (url, code) => {
if (!/201|200/.test(String(code))){
let loginUrl = url.replace(/\/qrcode\//, '/l/')
require('qrcode-terminal').generate(loginUrl)
}
console.log(`${url}\n[${code}] Scan QR Code in above url to login: `)
})
.on('friend', async function(contact, request){
try {
if (request) {
let name = contact.name()
let friendlog = "addfriend("+name+")"
addTaskFunc(async _ => {
await request.accept()
contact.say(AutoReply_1)
contact.say(AutoReply_2)
},friendlog)
} else {
contact.say(AutoReply_1)
contact.say(AutoReply_2)
logMsg = 'friend ship confirmed with ' + contact.name()
}
} catch (e) {
logMsg = e.message
}
})
.init()
const taskFuncList: Function[] = []
let taskSerialNumber = 0
function addTaskFunc(taskFunc: Function, taskName='unnamed') {
taskSerialNumber++
taskFunc['taskName'] = '#' + taskSerialNumber + ' ' + taskName
taskFuncList.push(taskFunc)
}
function processTaskList() {
if (taskFuncList.length > 0) {
const taskFunc = taskFuncList.shift()
if (taskFunc) {
console.log('processTaskList: ' + taskFunc['taskName'])
taskFunc()
} else {
console.error('processTaskList: pop task empty?')
}
}
console.log('setTimeout processTaskList 5 seconds')
setTimeout(processTaskList, 5 * 1000)
}
processTaskList() Silly log as follows:
|
I found you did tell me it failed in function onServerLog() , is it right?
|
Yes, if You can use the return value of The following code shows you how to do that: on('friend', async (contact, request) => {
if (request) {
result = await request.accept()
if (result) {
console.log('succeed')
} else {
console.error('failed')
}
}
} Notice that in order to do that, you need to use the latest master branch code, or version above 0.6.41 |
Thanks! |
Run
npm run doctor
orwechaty run doctor
(for docker user), paste output hereExpected behavior
自动通过好友请求
Actual behavior
无法成功通过好友请求
Paste the full output logs here with
WECHATY_LOG=silly
set部分verbose日志:
The text was updated successfully, but these errors were encountered: