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 e8b1913e
authored
Jan 30, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复Recall bug
增加路径获取 System::getPath() 以微信号为文件夹名称
1 parent
c0bd1927
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
12 deletions
example/index.php
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
example/index.php
View file @
e8b1913
...
@@ -63,23 +63,23 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
...
@@ -63,23 +63,23 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
// 图片信息 返回接收到的图片
// 图片信息 返回接收到的图片
if
(
$message
instanceof
Image
)
{
if
(
$message
instanceof
Image
)
{
return
$message
;
//
return $message;
}
}
// 视频信息 返回接收到的视频
// 视频信息 返回接收到的视频
if
(
$message
instanceof
Video
)
{
if
(
$message
instanceof
Video
)
{
return
$message
;
//
return $message;
}
}
// 表情信息 返回接收到的表情
// 表情信息 返回接收到的表情
if
(
$message
instanceof
Emoticon
)
{
if
(
$message
instanceof
Emoticon
)
{
return
$message
;
//
return $message;
}
}
// 语音消息
// 语音消息
if
(
$message
instanceof
Voice
){
if
(
$message
instanceof
Voice
){
/** @var $message Voice */
/** @var $message Voice */
return
'收到一条语音并下载在'
.
$message
::
getPath
(
$message
::
$folder
)
.
"/
{
$message
->
msg
[
'MsgId'
]
}
.mp3"
;
//
return '收到一条语音并下载在' . $message::getPath($message::$folder) . "/{$message->msg['MsgId']}.mp3";
}
}
// 撤回信息
// 撤回信息
...
@@ -152,7 +152,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
...
@@ -152,7 +152,7 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
// 手机点击聊天事件
// 手机点击聊天事件
if
(
$message
instanceof
Touch
){
if
(
$message
instanceof
Touch
){
Text
::
send
(
$message
->
msg
[
'ToUserName'
],
"我点击了此聊天"
);
//
Text::send($message->msg['ToUserName'], "我点击了此聊天");
}
}
return
false
;
return
false
;
...
...
src/Collections/ContactFactory.php
View file @
e8b1913
...
@@ -57,6 +57,9 @@ class ContactFactory
...
@@ -57,6 +57,9 @@ class ContactFactory
}
}
$this
->
getBatchGroupMembers
();
$this
->
getBatchGroupMembers
();
myself
()
->
alias
=
contact
()
->
get
(
myself
()
->
username
)[
'Alias'
]
?
:
myself
()
->
username
;
if
(
server
()
->
config
[
'debug'
]){
if
(
server
()
->
config
[
'debug'
]){
FileManager
::
download
(
'contact.json'
,
json_encode
(
contact
()
->
all
()));
FileManager
::
download
(
'contact.json'
,
json_encode
(
contact
()
->
all
()));
FileManager
::
download
(
'member.json'
,
json_encode
(
member
()
->
all
()));
FileManager
::
download
(
'member.json'
,
json_encode
(
member
()
->
all
()));
...
...
src/Core/MessageHandler.php
View file @
e8b1913
...
@@ -15,6 +15,7 @@ use Hanson\Vbot\Message\Entity\Message;
...
@@ -15,6 +15,7 @@ use Hanson\Vbot\Message\Entity\Message;
use
Hanson\Vbot\Message\Entity\Text
;
use
Hanson\Vbot\Message\Entity\Text
;
use
Hanson\Vbot\Message\Entity\Video
;
use
Hanson\Vbot\Message\Entity\Video
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\System
;
class
MessageHandler
class
MessageHandler
{
{
...
@@ -193,7 +194,7 @@ class MessageHandler
...
@@ -193,7 +194,7 @@ class MessageHandler
{
{
message
()
->
put
(
$message
->
msg
[
'MsgId'
],
$message
);
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
);
fwrite
(
$file
,
json_encode
(
$message
)
.
PHP_EOL
);
fclose
(
$file
);
fclose
(
$file
);
}
}
...
...
src/Core/Myself.php
View file @
e8b1913
...
@@ -22,6 +22,8 @@ class Myself
...
@@ -22,6 +22,8 @@ class Myself
public
$sex
;
public
$sex
;
public
$alias
;
public
static
function
getInstance
()
public
static
function
getInstance
()
{
{
if
(
!
static
::
$instance
)
{
if
(
!
static
::
$instance
)
{
...
...
src/Core/Server.php
View file @
e8b1913
...
@@ -13,6 +13,8 @@ use Endroid\QrCode\QrCode;
...
@@ -13,6 +13,8 @@ use Endroid\QrCode\QrCode;
use
Hanson\Vbot\Collections\ContactFactory
;
use
Hanson\Vbot\Collections\ContactFactory
;
use
Hanson\Vbot\Collections\Group
;
use
Hanson\Vbot\Collections\Group
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\Console
;
use
Hanson\Vbot\Support\FileManager
;
use
Hanson\Vbot\Support\System
;
class
Server
class
Server
{
{
...
@@ -140,7 +142,9 @@ class Server
...
@@ -140,7 +142,9 @@ class Server
mkdir
(
$this
->
config
[
'tmp'
],
0700
,
true
);
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
);
$qrCode
->
save
(
$file
);
}
}
...
...
src/Message/Entity/Recall.php
View file @
e8b1913
...
@@ -49,10 +49,10 @@ class Recall extends Message implements MessageInterface
...
@@ -49,10 +49,10 @@ class Recall extends Message implements MessageInterface
$msgId
=
$this
->
parseMsgId
(
$this
->
msg
[
'Content'
]);
$msgId
=
$this
->
parseMsgId
(
$this
->
msg
[
'Content'
]);
/** @var Message $message */
/** @var Message $message */
$this
->
origin
=
$message
=
message
()
->
get
(
$msgId
,
null
);
$this
->
origin
=
message
()
->
get
(
$msgId
,
null
);
if
(
!
$message
){
if
(
$this
->
origin
){
$this
->
nickname
=
$
message
->
sender
?
$message
->
sender
[
'NickName'
]
:
account
()
->
getAccount
(
$message
->
msg
[
'FromUserName'
])[
'NickName'
];
$this
->
nickname
=
$
this
->
origin
->
sender
?
$message
->
sender
[
'NickName'
]
:
account
()
->
getAccount
(
$this
->
origin
->
msg
[
'FromUserName'
])[
'NickName'
];
$this
->
setContent
();
$this
->
setContent
();
}
}
...
...
src/Message/MediaTrait.php
View file @
e8b1913
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
*/
*/
namespace
Hanson\Vbot\Message
;
namespace
Hanson\Vbot\Message
;
use
Hanson\Vbot\Support\System
;
/**
/**
...
@@ -19,7 +20,7 @@ trait MediaTrait
...
@@ -19,7 +20,7 @@ trait MediaTrait
public
static
function
getPath
(
$folder
)
public
static
function
getPath
(
$folder
)
{
{
$path
=
server
()
->
config
[
'tmp'
]
.
$folder
;
$path
=
System
::
getPath
()
.
$folder
;
return
realpath
(
$path
);
return
realpath
(
$path
);
}
}
...
...
src/Support/FileManager.php
View file @
e8b1913
...
@@ -14,7 +14,7 @@ class FileManager
...
@@ -14,7 +14,7 @@ class FileManager
public
static
function
download
(
$name
,
$data
,
$path
=
''
)
public
static
function
download
(
$name
,
$data
,
$path
=
''
)
{
{
$path
=
server
()
->
config
[
'tmp'
]
.
myself
()
->
nickname
.
'/'
.
$path
;
$path
=
System
::
getPath
()
.
$path
;
if
(
!
is_dir
(
realpath
(
$path
))){
if
(
!
is_dir
(
realpath
(
$path
))){
mkdir
(
$path
,
0700
,
true
);
mkdir
(
$path
,
0700
,
true
);
}
}
...
...
src/Support/System.php
View file @
e8b1913
...
@@ -21,4 +21,9 @@ class System
...
@@ -21,4 +21,9 @@ class System
{
{
return
strtoupper
(
substr
(
PHP_OS
,
0
,
3
))
===
'WIN'
;
return
strtoupper
(
substr
(
PHP_OS
,
0
,
3
))
===
'WIN'
;
}
}
public
static
function
getPath
()
{
return
server
()
->
config
[
'tmp'
]
.
'/'
.
myself
()
->
alias
.
'/'
;
}
}
}
\ No newline at end of file
\ 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