1 | <?php |
||
23 | class Bot |
||
24 | { |
||
25 | /** @var Bot */ |
||
26 | protected static $instance; |
||
27 | |||
28 | private $container; |
||
29 | private $channel; |
||
30 | private $driver; |
||
31 | |||
32 | /** @var Context|null */ |
||
33 | private $context; |
||
34 | |||
35 | 10 | protected function __construct( |
|
44 | |||
45 | /** |
||
46 | * Create new bot instance. |
||
47 | * |
||
48 | * @param Container $container |
||
49 | * @param Channel $channel |
||
50 | * @param Driver $driver |
||
51 | */ |
||
52 | 10 | public static function createInstance( |
|
61 | |||
62 | /** |
||
63 | * Get current instance. |
||
64 | * |
||
65 | * @return Bot |
||
66 | */ |
||
67 | 10 | public static function getInstance(): Bot |
|
71 | |||
72 | /** |
||
73 | * Set instance of the bot. |
||
74 | * |
||
75 | * @param Bot $instance |
||
76 | */ |
||
77 | 81 | public static function setInstance(Bot $instance): void |
|
81 | |||
82 | /** |
||
83 | * Get context instance. |
||
84 | * |
||
85 | * @return Context|null |
||
86 | */ |
||
87 | 2 | public function getContext(): ?Context |
|
91 | |||
92 | /** |
||
93 | * Set context instance. |
||
94 | * |
||
95 | * @param Context $context |
||
96 | */ |
||
97 | 2 | public function setContext(Context $context): void |
|
101 | |||
102 | /** |
||
103 | * Clear context. |
||
104 | */ |
||
105 | 1 | public function clearContext(): void |
|
112 | |||
113 | /** |
||
114 | * Resolve from container. |
||
115 | * |
||
116 | * @param string $class |
||
117 | * |
||
118 | * @return mixed |
||
119 | */ |
||
120 | 3 | public function get(string $class) |
|
124 | |||
125 | /** |
||
126 | * Process webhook request. |
||
127 | * |
||
128 | * @return mixed |
||
129 | */ |
||
130 | 4 | public function process() |
|
163 | |||
164 | /** |
||
165 | * Start conversation. |
||
166 | * |
||
167 | * @param Conversable $conversable |
||
168 | */ |
||
169 | 2 | public function converse(Conversable $conversable): void |
|
181 | |||
182 | /** |
||
183 | * Send message. |
||
184 | * |
||
185 | * @param User $recipient |
||
186 | * @param string $text |
||
187 | * @param Keyboard|null $keyboard |
||
188 | * @param string|null $driver |
||
189 | * |
||
190 | * @return OutgoingMessage|null |
||
191 | */ |
||
192 | 2 | public function sendMessage( |
|
208 | |||
209 | /** |
||
210 | * Send attachment. |
||
211 | * |
||
212 | * @param User $recipient |
||
213 | * @param Attachment $attachment |
||
214 | */ |
||
215 | 1 | public function sendAttachment(User $recipient, Attachment $attachment): void |
|
219 | |||
220 | /** |
||
221 | * Get context manager. |
||
222 | * |
||
223 | * @return ContextManager |
||
224 | */ |
||
225 | 3 | private function contextManager(): ContextManager |
|
229 | |||
230 | /** |
||
231 | * Get intent manager. |
||
232 | * |
||
233 | * @return IntentManager |
||
234 | */ |
||
235 | 1 | private function intentManager(): IntentManager |
|
239 | } |
||
240 |