Commit 17f576d3 by HanSon

增加视频下载失败提示

修改构造联系人方法
增加好友数量输出
1 parent b8c48e08
......@@ -30,20 +30,30 @@ class ContactFactory
public function getContacts()
{
$url = sprintf(server()->baseUri . '/webwxgetcontact?pass_ticket=%s&skey=%s&r=%s', server()->passTicket, server()->skey, time());
$content = http()->json($url, [], true);
$this->makeContactList();
$this->getBatchGroupMembers();
$this->makeContactList($content['MemberList']);
if(server()->config['debug']){
FileManager::download('contact.json', json_encode(contact()->all()));
FileManager::download('member.json', json_encode(member()->all()));
FileManager::download('group.json', json_encode(group()->all()));
FileManager::download('official.json', json_encode(official()->all()));
FileManager::download('special.json', json_encode(Special::getInstance()->all()));
}
}
/**
* make instance model
*
* @param $memberList
*/
protected function makeContactList($memberList)
public function makeContactList()
{
$url = sprintf(server()->baseUri . '/webwxgetcontact?pass_ticket=%s&skey=%s&r=%s', server()->passTicket, server()->skey, time());
$memberList = http()->json($url, [], true)['MemberList'];
foreach ($memberList as $contact) {
if(official()->isOfficial($contact['VerifyFlag'])){ #公众号
Official::getInstance()->put($contact['UserName'], $contact);
......@@ -56,17 +66,7 @@ class ContactFactory
}
}
$this->getBatchGroupMembers();
myself()->alias = contact()->get(myself()->username)['Alias'] ?? myself()->nickname ? : myself()->username;
if(server()->config['debug']){
FileManager::download('contact.json', json_encode(contact()->all()));
FileManager::download('member.json', json_encode(member()->all()));
FileManager::download('group.json', json_encode(group()->all()));
FileManager::download('official.json', json_encode(official()->all()));
FileManager::download('special.json', json_encode(Special::getInstance()->all()));
}
}
/**
......
......@@ -12,6 +12,7 @@ namespace Hanson\Vbot\Core;
use Endroid\QrCode\QrCode;
use Hanson\Vbot\Collections\ContactFactory;
use Hanson\Vbot\Collections\Group;
use Hanson\Vbot\Collections\Special;
use Hanson\Vbot\Support\Console;
use Hanson\Vbot\Support\FileManager;
use Hanson\Vbot\Support\System;
......@@ -87,7 +88,7 @@ class Server
$this->statusNotify();
Console::log('开始初始化联系人');
$this->initContact();
Console::log('初始化联系人成功');
Console::log(sprintf("初始化联系人成功\n群数量: %d\n联系人数量: %d\n公众号数量: %d\n特殊号数量: %d", group()->count(), contact()->count(), official()->count(), Special::getInstance()->count()));
MessageHandler::getInstance()->listen();
}
......
......@@ -31,13 +31,14 @@ class Sync
'_' => time()
]);
try{
$content = http()->get($url);
$content = http()->get($url);
try{
preg_match('/window.synccheck=\{retcode:"(\d+)",selector:"(\d+)"\}/', $content, $matches);
return [$matches[1], $matches[2]];
}catch (\Exception $e){
Console::log('Sync check return:' . $content);
return [-1, -1];
}
}
......
......@@ -89,7 +89,11 @@ class Video extends Message implements MessageInterface, MediaInterface
'Range' => 'bytes=0-'
]
]);
FileManager::download($this->msg['MsgId'] . '.mp4', $content, static::$folder);
if(strlen($content) === 0){
Console::log('下载视频失败', Console::ERROR);
}else{
FileManager::download($this->msg['MsgId'] . '.mp4', $content, static::$folder);
}
}
public function make()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!