Recommend.php
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
 * Created by PhpStorm.
 * User: Hanson
 * Date: 2017/1/15
 * Time: 12:29
 */
namespace Hanson\Vbot\Message\Entity;
use Hanson\Vbot\Message\MessageInterface;
class Recommend extends Message implements MessageInterface
{
    /**
     * @var array 推荐信息
     */
    public $info;
    public $bigAvatar;
    public $smallAvatar;
    public $isOfficial = false;
    public $description;
    /**
     * 国内为省,国外为国
     *
     * @var string
     */
    public $province;
    /**
     * 城市
     *
     * @var string
     */
    public $city;
    public function __construct($msg)
    {
        parent::__construct($msg);
        $this->make();
    }
    public function make()
    {
        $this->info = $this->msg['RecommendInfo'];
        $this->parseContent();
    }
    private function parseContent()
    {
        $isMatch = preg_match('/bigheadimgurl="(http:\/\/.+?)"\ssmallheadimgurl="(http:\/\/.+?)".+province="(.+?)"\scity="(.+?)".+certflag="(\d+)"\scertinfo="(.+?)"/', $this->msg['Content'], $matches);
        if($isMatch){
            $this->bigAvatar = $matches[1];
            $this->smallAvatar = $matches[2];
            $this->province = $matches[3];
            $this->city = $matches[4];
            $flag = $matches[5];
            $desc = $matches[6];
            if(official()->isOfficial($flag)){
                $this->isOfficial = true;
                $this->description = $desc;
            }
        }
    }
}