-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAliceBase.php
46 lines (40 loc) · 1.09 KB
/
AliceBase.php
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
<?
class AliceBase
{
/**
* AliceBase constructor.
*/
public function __construct($session, $request, $meta, $version)
{
$this->session = $session;
$this->request = $request;
$this->meta = $meta;
$this->version = $version;
}
public function isNew()
{
return $this->session['new'];
}
public function getCommand()
{
return $this->request['command'];
}
public function checkRequestForKeyWord($keyword)
{
if (strpos(strtolower($this->getCommand()), $keyword)!==false) return true;
// echo strpos(strtolower($this->getCommand()), $keyword);
return false;
}
public function printAnswer($text, $tts, $buttons = array(), $end_session = false)
{
$answer['response'] = array(
"text" => $text,
"tts" => $tts,
"buttons" => $buttons,
"end_session" => $end_session,
);
$answer['session'] = $this->session;
$answer['version'] = $this->version;
echo json_encode($answer);
}
}