how could I send multiple messages within one event?
I just try your robot, it is great. However I tried to send multiple message when I received a message, I tried to do multiple paste(reply) $('.btn_send')[0].click()
but it doesn't work, do you know how could I do this?
@xmcharles0 hey, thanks! I'm sorry about this. Let me try and give you more information soon!
I tried that, it seem that every timeout funtion could only do paste once. have to write different timeout function. don't know why
yeah, it was written in callback style.. and was simply designed.. it could be hard to support "multiple replies" with just a small patch.. looks like a rewrite is needed, maybe a promise, generator or async/await is much better.
for example,
function* onReddot($chat_item){
// ...
for (let i = 0; i < 3; i++) {
yield send(reply)
}
reset()
}
function send(reply){
return new Promise((resolve) => {
// 借用clipboard 实现输入文字 更新ng-model=EditAreaCtn
// ~~直接设#editArea的innerText无效 暂时找不到其他方法~~
paste(reply)
// 发送text 可以直接更新scope中的变量 @昌爷 提点
// 但不知为毛 发不了表情
// if (reply.image) {
// paste(reply)
// } else {
// angular.element('#editArea').scope().editAreaCtn = reply.text
// }
// $('.web_wechat_face')[0].click()
// $('[title=阴险]')[0].click()
if (reply.image) {
setTimeout(function(){
var tryClickBtn = setInterval(function(){
var $btn = $('.dialog_ft .btn_primary')
if ($btn.length) {
$('.dialog_ft .btn_primary')[0].click()
} else {
clearInterval(tryClickBtn)
resolve()
}
}, 200)
}, 100)
} else {
$('.btn_send')[0].click()
resolve()
}
})
}