Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
vbot
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 17f576d3
authored
Feb 06, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加视频下载失败提示
修改构造联系人方法 增加好友数量输出
1 parent
b8c48e08
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
17 deletions
src/Collections/ContactFactory.php
src/Core/Server.php
src/Core/Sync.php
src/Message/Entity/Video.php
src/Collections/ContactFactory.php
View file @
17f576d
...
...
@@ -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
*/
p
rotected
function
makeContactList
(
$memberList
)
p
ublic
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
()));
}
}
/**
...
...
src/Core/Server.php
View file @
17f576d
...
...
@@ -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
();
}
...
...
src/Core/Sync.php
View file @
17f576d
...
...
@@ -31,13 +31,14 @@ class Sync
'_'
=>
time
()
]);
try
{
$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
];
}
}
...
...
src/Message/Entity/Video.php
View file @
17f576d
...
...
@@ -89,8 +89,12 @@ class Video extends Message implements MessageInterface, MediaInterface
'Range'
=>
'bytes=0-'
]
]);
if
(
strlen
(
$content
)
===
0
){
Console
::
log
(
'下载视频失败'
,
Console
::
ERROR
);
}
else
{
FileManager
::
download
(
$this
->
msg
[
'MsgId'
]
.
'.mp4'
,
$content
,
static
::
$folder
);
}
}
public
function
make
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment