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 abe5edb4
authored
Jan 30, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加公众号推送消息类型,Official
1 parent
1069688f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
2 deletions
example/index.php
src/Collections/Account.php
src/Message/Entity/Message.php
src/Message/Entity/Official.php
src/Message/Entity/ShareFactory.php
example/index.php
View file @
abe5edb
...
@@ -21,6 +21,7 @@ use Hanson\Vbot\Message\Entity\RedPacket;
...
@@ -21,6 +21,7 @@ use Hanson\Vbot\Message\Entity\RedPacket;
use
Hanson\Vbot\Message\Entity\Transfer
;
use
Hanson\Vbot\Message\Entity\Transfer
;
use
Hanson\Vbot\Message\Entity\Recommend
;
use
Hanson\Vbot\Message\Entity\Recommend
;
use
Hanson\Vbot\Message\Entity\Share
;
use
Hanson\Vbot\Message\Entity\Share
;
use
Hanson\Vbot\Message\Entity\Official
;
use
Hanson\Vbot\Message\Entity\Touch
;
use
Hanson\Vbot\Message\Entity\Touch
;
use
Hanson\Vbot\Message\Entity\RequestFriend
;
use
Hanson\Vbot\Message\Entity\RequestFriend
;
...
@@ -150,6 +151,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
...
@@ -150,6 +151,16 @@ $robot->server->setMessageHandler(function ($message) use ($path) {
return
$reply
;
return
$reply
;
}
}
// 公众号推送信息
if
(
$message
instanceof
Official
){
/** @var $message Official */
$reply
=
"收到公众号推送
\n
标题:
{
$message
->
title
}
\n
描述:
{
$message
->
description
}
\n
链接:
{
$message
->
url
}
"
;
if
(
$message
->
app
){
$reply
.=
"
\n
来源公众号名称:
{
$message
->
app
}
"
;
}
return
$reply
;
}
// 手机点击聊天事件
// 手机点击聊天事件
if
(
$message
instanceof
Touch
){
if
(
$message
instanceof
Touch
){
Text
::
send
(
$message
->
msg
[
'ToUserName'
],
"我点击了此聊天"
);
Text
::
send
(
$message
->
msg
[
'ToUserName'
],
"我点击了此聊天"
);
...
...
src/Collections/Account.php
View file @
abe5edb
...
@@ -43,6 +43,8 @@ class Account
...
@@ -43,6 +43,8 @@ class Account
$account
=
$account
?:
contact
()
->
get
(
$username
,
null
);
$account
=
$account
?:
contact
()
->
get
(
$username
,
null
);
$account
=
$account
?:
official
()
->
get
(
$username
,
null
);
return
$account
?:
member
()
->
get
(
$username
,
[]);
return
$account
?:
member
()
->
get
(
$username
,
[]);
}
}
...
...
src/Message/Entity/Message.php
View file @
abe5edb
...
@@ -83,7 +83,7 @@ class Message
...
@@ -83,7 +83,7 @@ class Message
$this
->
fromType
=
'Group'
;
$this
->
fromType
=
'Group'
;
}
elseif
(
contact
()
->
get
(
$this
->
msg
[
'FromUserName'
]))
{
}
elseif
(
contact
()
->
get
(
$this
->
msg
[
'FromUserName'
]))
{
$this
->
fromType
=
'Contact'
;
$this
->
fromType
=
'Contact'
;
}
elseif
(
Official
::
getInstance
()
->
get
(
$this
->
msg
[
'FromUserName'
]))
{
}
elseif
(
official
()
->
get
(
$this
->
msg
[
'FromUserName'
]))
{
$this
->
fromType
=
'Official'
;
$this
->
fromType
=
'Official'
;
}
elseif
(
Special
::
getInstance
()
->
get
(
$this
->
msg
[
'FromUserName'
],
false
))
{
}
elseif
(
Special
::
getInstance
()
->
get
(
$this
->
msg
[
'FromUserName'
],
false
))
{
$this
->
fromType
=
'Special'
;
$this
->
fromType
=
'Special'
;
...
...
src/Message/Entity/Official.php
0 → 100644
View file @
abe5edb
<?php
/**
* Created by PhpStorm.
* User: Hanson
* Date: 2017/1/15
* Time: 12:29
*/
namespace
Hanson\Vbot\Message\Entity
;
use
Hanson\Vbot\Message\MessageInterface
;
class
Official
extends
Message
implements
MessageInterface
{
public
$title
;
public
$description
;
public
$url
;
public
$app
;
public
function
__construct
(
$msg
)
{
parent
::
__construct
(
$msg
);
$this
->
make
();
}
public
function
make
()
{
$array
=
(
array
)
simplexml_load_string
(
$this
->
msg
[
'Content'
],
'SimpleXMLElement'
,
LIBXML_NOCDATA
);
$info
=
(
array
)
$array
[
'appmsg'
];
$this
->
title
=
$info
[
'title'
];
$this
->
description
=
$info
[
'des'
];
$appInfo
=
(
array
)
$array
[
'appinfo'
];
$this
->
app
=
$appInfo
[
'appname'
];
$this
->
url
=
$this
->
msg
[
'Url'
];
}
}
src/Message/Entity/ShareFactory.php
View file @
abe5edb
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
namespace
Hanson\Vbot\Message\Entity
;
namespace
Hanson\Vbot\Message\Entity
;
use
Hanson\Vbot\Message\MessageInterface
;
use
Hanson\Vbot\Support\Content
;
use
Hanson\Vbot\Support\Content
;
class
ShareFactory
class
ShareFactory
...
@@ -26,6 +25,8 @@ class ShareFactory
...
@@ -26,6 +25,8 @@ class ShareFactory
if
(
$this
->
type
==
6
){
if
(
$this
->
type
==
6
){
return
new
File
(
$msg
);
return
new
File
(
$msg
);
}
else
if
(
official
()
->
get
(
$msg
[
'FromUserName'
])){
return
new
Official
(
$msg
);
}
else
{
}
else
{
return
new
Share
(
$msg
);
return
new
Share
(
$msg
);
}
}
...
...
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