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 1069688f
authored
Jan 30, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' into master1
# Conflicts: # src/Core/MessageHandler.php
2 parents
5572cfba
8ec8c3e1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
15 deletions
src/Collections/ContactFactory.php
src/Core/MessageHandler.php
src/Core/Myself.php
src/Core/Server.php
src/Message/Entity/Recall.php
src/Message/MediaTrait.php
src/Support/FileManager.php
src/Support/System.php
src/Collections/ContactFactory.php
View file @
1069688
...
...
@@ -9,8 +9,7 @@
namespace
Hanson\Vbot\Collections
;
use
Hanson\Vbot\Core\Server
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\FileManager
;
class
ContactFactory
{
...
...
@@ -58,12 +57,15 @@ class ContactFactory
}
$this
->
getBatchGroupMembers
();
myself
()
->
alias
=
contact
()
->
get
(
myself
()
->
username
)[
'Alias'
]
?
:
myself
()
->
username
;
if
(
server
()
->
config
[
'debug'
]){
file_put_contents
(
server
()
->
config
[
'tmp'
]
.
'contact.json'
,
json_encode
(
contact
()
->
all
()));
file_put_contents
(
server
()
->
config
[
'tmp'
]
.
'member.json'
,
json_encode
(
member
()
->
all
()));
file_put_contents
(
server
()
->
config
[
'tmp'
]
.
'group.json'
,
json_encode
(
group
()
->
all
()));
file_put_contents
(
server
()
->
config
[
'tmp'
]
.
'official.json'
,
json_encode
(
Official
::
getInstance
()
->
all
()));
file_put_contents
(
server
()
->
config
[
'tmp'
]
.
'special.json'
,
json_encode
(
Special
::
getInstance
()
->
all
()));
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/MessageHandler.php
View file @
1069688
...
...
@@ -15,6 +15,7 @@ use Hanson\Vbot\Message\Entity\Message;
use
Hanson\Vbot\Message\Entity\Text
;
use
Hanson\Vbot\Message\Entity\Video
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\System
;
class
MessageHandler
{
...
...
@@ -193,7 +194,7 @@ class MessageHandler
{
message
()
->
put
(
$message
->
msg
[
'MsgId'
],
$message
);
$file
=
fopen
(
server
()
->
config
[
'tmp'
]
.
'/
message.json'
,
'a'
);
$file
=
fopen
(
System
::
getPath
()
.
'
message.json'
,
'a'
);
fwrite
(
$file
,
json_encode
(
$message
)
.
PHP_EOL
);
fclose
(
$file
);
}
...
...
src/Core/Myself.php
View file @
1069688
...
...
@@ -22,6 +22,8 @@ class Myself
public
$sex
;
public
$alias
;
public
static
function
getInstance
()
{
if
(
!
static
::
$instance
)
{
...
...
src/Core/Server.php
View file @
1069688
...
...
@@ -13,6 +13,8 @@ use Endroid\QrCode\QrCode;
use
Hanson\Vbot\Collections\ContactFactory
;
use
Hanson\Vbot\Collections\Group
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\FileManager
;
use
Hanson\Vbot\Support\System
;
class
Server
{
...
...
@@ -140,7 +142,9 @@ class Server
mkdir
(
$this
->
config
[
'tmp'
],
0700
,
true
);
}
$file
=
$this
->
config
[
'tmp'
]
.
'qr.png'
;
$file
=
System
::
getPath
()
.
'qr.png'
;
FileManager
::
download
(
'qr.png'
,
file_get_contents
(
$url
));
$qrCode
->
save
(
$file
);
}
...
...
src/Message/Entity/Recall.php
View file @
1069688
...
...
@@ -49,10 +49,10 @@ class Recall extends Message implements MessageInterface
$msgId
=
$this
->
parseMsgId
(
$this
->
msg
[
'Content'
]);
/** @var Message $message */
$this
->
origin
=
$message
=
message
()
->
get
(
$msgId
,
null
);
$this
->
origin
=
message
()
->
get
(
$msgId
,
null
);
if
(
!
$message
){
$this
->
nickname
=
$
message
->
sender
?
$message
->
sender
[
'NickName'
]
:
account
()
->
getAccount
(
$message
->
msg
[
'FromUserName'
])[
'NickName'
];
if
(
$this
->
origin
){
$this
->
nickname
=
$
this
->
origin
->
sender
?
$message
->
sender
[
'NickName'
]
:
account
()
->
getAccount
(
$this
->
origin
->
msg
[
'FromUserName'
])[
'NickName'
];
$this
->
setContent
();
}
...
...
src/Message/MediaTrait.php
View file @
1069688
...
...
@@ -7,6 +7,7 @@
*/
namespace
Hanson\Vbot\Message
;
use
Hanson\Vbot\Support\System
;
/**
...
...
@@ -19,7 +20,7 @@ trait MediaTrait
public
static
function
getPath
(
$folder
)
{
$path
=
server
()
->
config
[
'tmp'
]
.
$folder
;
$path
=
System
::
getPath
()
.
$folder
;
return
realpath
(
$path
);
}
...
...
src/Support/FileManager.php
View file @
1069688
...
...
@@ -12,9 +12,9 @@ namespace Hanson\Vbot\Support;
class
FileManager
{
public
static
function
download
(
$name
,
$data
,
$path
)
public
static
function
download
(
$name
,
$data
,
$path
=
''
)
{
$path
=
server
()
->
config
[
'tmp'
]
.
$path
;
$path
=
System
::
getPath
()
.
$path
;
if
(
!
is_dir
(
realpath
(
$path
))){
mkdir
(
$path
,
0700
,
true
);
}
...
...
src/Support/System.php
View file @
1069688
...
...
@@ -21,4 +21,9 @@ class System
{
return
strtoupper
(
substr
(
PHP_OS
,
0
,
3
))
===
'WIN'
;
}
public
static
function
getPath
()
{
return
server
()
->
config
[
'tmp'
]
.
'/'
.
myself
()
->
alias
.
'/'
;
}
}
\ No newline at end of file
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