1 | <?php |
||
31 | class Chat extends Entity |
||
32 | { |
||
33 | public function __construct($data) |
||
34 | { |
||
35 | parent::__construct($data); |
||
36 | |||
37 | if (!$this->getType()) { |
||
38 | if ($this->getId() > 0) { |
||
39 | $this->type = 'private'; |
||
40 | } elseif ($this->getId() < 0) { |
||
41 | $this->type = 'group'; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Try mention |
||
48 | * |
||
49 | * @return string|null |
||
50 | */ |
||
51 | public function tryMention() |
||
52 | 19 | { |
|
53 | if ($this->isPrivateChat()) { |
||
54 | 19 | if ($this->username === null) { |
|
55 | 19 | if ($this->last_name !== null) { |
|
56 | return $this->first_name . ' ' . $this->last_name; |
||
57 | } |
||
58 | |||
59 | 19 | return $this->first_name; |
|
60 | 15 | } |
|
61 | |||
62 | 10 | return '@' . $this->username; |
|
63 | 9 | } |
|
64 | 1 | ||
65 | 1 | return $this->getTitle(); |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * Check if this is a group chat |
||
70 | * |
||
71 | 19 | * @return bool |
|
72 | 19 | */ |
|
73 | 19 | public function isGroupChat() |
|
74 | 19 | { |
|
75 | 19 | return $this->type === 'group' || $this->id < 0; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * Check if this is a private chat |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | public function isPrivateChat() |
||
87 | |||
88 | /** |
||
89 | * Check if this is a super group |
||
90 | * |
||
91 | * @return bool |
||
92 | */ |
||
93 | public function isSuperGroup() |
||
97 | |||
98 | /** |
||
99 | * Check if this is a channel |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | public function isChannel() |
||
107 | } |
||
108 |