@@ -17,6 +17,9 @@ |
||
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $sentence |
|
22 | + */ |
|
20 | 23 | public function answer($sentence) { |
21 | 24 | foreach(JarvisBehaviourLanguage::$jbl_set->rules as $rule) { |
22 | 25 | foreach($rule->matches as $match) { |
@@ -9,23 +9,23 @@ |
||
9 | 9 | */ |
10 | 10 | class JarvisBehaviourLanguage { |
11 | 11 | |
12 | - public static $jbl_set = array(); |
|
12 | + public static $jbl_set = array(); |
|
13 | 13 | |
14 | - public function loadBehaviourLanguage() { |
|
15 | - if(file_exists('language/jbl_'._LANGUAGE.'.jbl')) { |
|
16 | - JarvisBehaviourLanguage::$jbl_set = json_decode(file_get_contents('language/jbl_'._LANGUAGE.'.jbl')); |
|
17 | - } |
|
18 | - } |
|
14 | + public function loadBehaviourLanguage() { |
|
15 | + if(file_exists('language/jbl_'._LANGUAGE.'.jbl')) { |
|
16 | + JarvisBehaviourLanguage::$jbl_set = json_decode(file_get_contents('language/jbl_'._LANGUAGE.'.jbl')); |
|
17 | + } |
|
18 | + } |
|
19 | 19 | |
20 | - public function answer($sentence) { |
|
21 | - foreach(JarvisBehaviourLanguage::$jbl_set->rules as $rule) { |
|
22 | - foreach($rule->matches as $match) { |
|
23 | - if(preg_match($match, $sentence)) { |
|
24 | - return $rule->responses[array_rand($rule->responses)]; |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
28 | - return false; |
|
29 | - } |
|
20 | + public function answer($sentence) { |
|
21 | + foreach(JarvisBehaviourLanguage::$jbl_set->rules as $rule) { |
|
22 | + foreach($rule->matches as $match) { |
|
23 | + if(preg_match($match, $sentence)) { |
|
24 | + return $rule->responses[array_rand($rule->responses)]; |
|
25 | + } |
|
26 | + } |
|
27 | + } |
|
28 | + return false; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -12,15 +12,15 @@ |
||
12 | 12 | public static $jbl_set = array(); |
13 | 13 | |
14 | 14 | public function loadBehaviourLanguage() { |
15 | - if(file_exists('language/jbl_'._LANGUAGE.'.jbl')) { |
|
15 | + if (file_exists('language/jbl_'._LANGUAGE.'.jbl')) { |
|
16 | 16 | JarvisBehaviourLanguage::$jbl_set = json_decode(file_get_contents('language/jbl_'._LANGUAGE.'.jbl')); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function answer($sentence) { |
21 | - foreach(JarvisBehaviourLanguage::$jbl_set->rules as $rule) { |
|
22 | - foreach($rule->matches as $match) { |
|
23 | - if(preg_match($match, $sentence)) { |
|
21 | + foreach (JarvisBehaviourLanguage::$jbl_set->rules as $rule) { |
|
22 | + foreach ($rule->matches as $match) { |
|
23 | + if (preg_match($match, $sentence)) { |
|
24 | 24 | return $rule->responses[array_rand($rule->responses)]; |
25 | 25 | } |
26 | 26 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | /** |
56 | 56 | * Is it the right plugin for the command? |
57 | 57 | * @param string $command |
58 | - * @return boolean |
|
58 | + * @return integer |
|
59 | 59 | */ |
60 | 60 | function isLikely($command) { |
61 | 61 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace JarvisPHP\Plugins\ActualOutsideTemperature_plugin; |
4 | 4 | |
5 | -use JarvisPHP\Core\JarvisSession; |
|
6 | 5 | use JarvisPHP\Core\JarvisPHP; |
7 | 6 | use JarvisPHP\Core\JarvisLanguage; |
8 | 7 | use JarvisPHP\Core\JarvisTTS; |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | $BASE_URL = "http://query.yahooapis.com/v1/public/yql"; |
31 | 31 | $yql_query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'.$this->place.'") and u="c"'; |
32 | - $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json"; |
|
32 | + $yql_query_url = $BASE_URL."?q=".urlencode($yql_query)."&format=json"; |
|
33 | 33 | |
34 | 34 | // Make call with cURL |
35 | 35 | $session = curl_init($yql_query_url); |
36 | - curl_setopt($session, CURLOPT_RETURNTRANSFER,true); |
|
36 | + curl_setopt($session, CURLOPT_RETURNTRANSFER, true); |
|
37 | 37 | $json = curl_exec($session); |
38 | 38 | // Convert JSON to PHP object |
39 | - $phpObj = json_decode($json); |
|
40 | - $answer = sprintf(JarvisLanguage::translate('actual_temperature_outside_is',get_called_class()),$phpObj->query->results->channel->item->condition->temp, $phpObj->query->results->channel->atmosphere->humidity); |
|
39 | + $phpObj = json_decode($json); |
|
40 | + $answer = sprintf(JarvisLanguage::translate('actual_temperature_outside_is', get_called_class()), $phpObj->query->results->channel->item->condition->temp, $phpObj->query->results->channel->atmosphere->humidity); |
|
41 | 41 | JarvisTTS::speak($answer); |
42 | 42 | $response = new \JarvisPHP\Core\JarvisResponse($answer, JarvisPHP::getRealClassName(get_called_class()), true); |
43 | 43 | $response->send(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | 60 | function isLikely($command) { |
61 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
61 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,7 +68,7 @@ |
||
68 | 68 | /** |
69 | 69 | * Is it the right plugin for the command? |
70 | 70 | * @param string $command |
71 | - * @return boolean |
|
71 | + * @return integer |
|
72 | 72 | */ |
73 | 73 | function isLikely($command) { |
74 | 74 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Stefano Bianchini |
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | */ |
15 | -class CheckMail_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
15 | +class CheckMail_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
16 | 16 | /** |
17 | 17 | * Priority of plugin |
18 | 18 | * @var int |
@@ -27,27 +27,27 @@ discard block |
||
27 | 27 | $answer = ''; |
28 | 28 | |
29 | 29 | //Load credentials from json config |
30 | - if(file_exists('Plugins/CheckMail_plugin/credentials.json')) { |
|
30 | + if (file_exists('Plugins/CheckMail_plugin/credentials.json')) { |
|
31 | 31 | $json_config = json_decode(file_get_contents('Plugins/CheckMail_plugin/credentials.json')); |
32 | 32 | } |
33 | 33 | |
34 | - if($json_config) { |
|
34 | + if ($json_config) { |
|
35 | 35 | |
36 | 36 | $mbox = imap_open($json_config->connection_string, $json_config->user, $json_config->password, OP_READONLY); |
37 | 37 | |
38 | - $uids = imap_search($mbox, 'UNSEEN', SE_UID); |
|
38 | + $uids = imap_search($mbox, 'UNSEEN', SE_UID); |
|
39 | 39 | |
40 | - if(is_array($uids)) { |
|
41 | - $answer = sprintf(JarvisLanguage::translate('you_have_new_messages',get_called_class()), count($uids)); |
|
40 | + if (is_array($uids)) { |
|
41 | + $answer = sprintf(JarvisLanguage::translate('you_have_new_messages', get_called_class()), count($uids)); |
|
42 | 42 | } else { |
43 | - $answer = JarvisLanguage::translate('no_messages',get_called_class()); |
|
43 | + $answer = JarvisLanguage::translate('no_messages', get_called_class()); |
|
44 | 44 | } |
45 | 45 | |
46 | - if(preg_match(JarvisLanguage::translate('preg_match_read',get_called_class()), $command) && is_array($uids)) { |
|
46 | + if (preg_match(JarvisLanguage::translate('preg_match_read', get_called_class()), $command) && is_array($uids)) { |
|
47 | 47 | //Read last message |
48 | 48 | $result = imap_fetch_overview($mbox, end($uids), FT_UID); |
49 | 49 | $mail = end($result); |
50 | - $answer = JarvisLanguage::translate('from',get_called_class()).': '.$mail->from.'. '.JarvisLanguage::translate('subject',get_called_class()).': '.imap_utf8($mail->subject); |
|
50 | + $answer = JarvisLanguage::translate('from', get_called_class()).': '.$mail->from.'. '.JarvisLanguage::translate('subject', get_called_class()).': '.imap_utf8($mail->subject); |
|
51 | 51 | JarvisSession::terminate(); |
52 | 52 | } |
53 | 53 | imap_close($mbox); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return boolean |
72 | 72 | */ |
73 | 73 | function isLikely($command) { |
74 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
74 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -48,7 +48,7 @@ |
||
48 | 48 | /** |
49 | 49 | * Is it the right plugin for the command? |
50 | 50 | * @param string $command |
51 | - * @return boolean |
|
51 | + * @return integer |
|
52 | 52 | */ |
53 | 53 | function isLikely($command) { |
54 | 54 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Stefano Bianchini |
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | */ |
15 | -class Echo_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
15 | +class Echo_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
16 | 16 | /** |
17 | 17 | * Priority of plugin |
18 | 18 | * @var int |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function answer($command) { |
27 | 27 | $answer = ''; |
28 | - if(JarvisSession::get('echo_not_first_passage')) { |
|
28 | + if (JarvisSession::get('echo_not_first_passage')) { |
|
29 | 29 | $answer = $command; |
30 | 30 | } else { |
31 | - JarvisSession::set('echo_not_first_passage',true); |
|
31 | + JarvisSession::set('echo_not_first_passage', true); |
|
32 | 32 | JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"'); |
33 | - $answer = JarvisLanguage::translate('let_s_play',get_called_class()); |
|
33 | + $answer = JarvisLanguage::translate('let_s_play', get_called_class()); |
|
34 | 34 | } |
35 | 35 | JarvisTTS::speak($answer); |
36 | 36 | $response = new \JarvisPHP\Core\JarvisResponse($answer, JarvisPHP::getRealClassName(get_called_class()), true); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return boolean |
52 | 52 | */ |
53 | 53 | function isLikely($command) { |
54 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
54 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * Is it the right plugin for the command? |
85 | 85 | * @param string $command |
86 | - * @return boolean |
|
86 | + * @return integer |
|
87 | 87 | */ |
88 | 88 | function isLikely($command) { |
89 | 89 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Returns an authorized API client. |
102 | - * @return Google_Client the authorized client object |
|
102 | + * @return null|\Google_Client the authorized client object |
|
103 | 103 | */ |
104 | 104 | function getClient() { |
105 | 105 | $client = new \Google_Client(); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace JarvisPHP\Plugins\Gcalendar_plugin; |
4 | 4 | |
5 | -use JarvisPHP\Core\JarvisSession; |
|
6 | 5 | use JarvisPHP\Core\JarvisPHP; |
7 | 6 | use JarvisPHP\Core\JarvisLanguage; |
8 | 7 | use JarvisPHP\Core\JarvisTTS; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | define('CREDENTIALS_PATH', 'Plugins/Gcalendar_plugin/api-key.json'); |
12 | 12 | define('CLIENT_SECRET_PATH', 'Plugins/Gcalendar_plugin/secret-client-key.json'); |
13 | 13 | define('SCOPES', implode(' ', array( |
14 | - \Google_Service_Calendar::CALENDAR_READONLY) |
|
14 | + \Google_Service_Calendar::CALENDAR_READONLY) |
|
15 | 15 | )); |
16 | 16 | define('_MAX_EVENTS', 4); |
17 | 17 | |
@@ -46,26 +46,26 @@ discard block |
||
46 | 46 | // Print the next _MAX_EVENTS events on the user's calendar. |
47 | 47 | $calendarId = 'primary'; |
48 | 48 | $optParams = array( |
49 | - 'maxResults' => _MAX_EVENTS, |
|
50 | - 'orderBy' => 'startTime', |
|
51 | - 'singleEvents' => TRUE, |
|
52 | - 'timeMin' => date('c'), |
|
49 | + 'maxResults' => _MAX_EVENTS, |
|
50 | + 'orderBy' => 'startTime', |
|
51 | + 'singleEvents' => TRUE, |
|
52 | + 'timeMin' => date('c'), |
|
53 | 53 | ); |
54 | 54 | $results = $service->events->listEvents($calendarId, $optParams); |
55 | 55 | |
56 | 56 | if (count($results->getItems()) == 0) { |
57 | - $answer = JarvisLanguage::translate('no_appointments',get_called_class()); |
|
57 | + $answer = JarvisLanguage::translate('no_appointments',get_called_class()); |
|
58 | 58 | } else { |
59 | 59 | |
60 | - foreach ($results->getItems() as $event) { |
|
60 | + foreach ($results->getItems() as $event) { |
|
61 | 61 | $start = $event->start->dateTime; |
62 | 62 | if (empty($start)) { |
63 | - $start = $event->start->date; |
|
63 | + $start = $event->start->date; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $date = new \DateTime($start); |
67 | 67 | $answer.= sprintf(JarvisLanguage::translate('list_events',get_called_class()), $date->format('j'), JarvisLanguage::translate('month_'.$date->format('n'),get_called_class()), $date->format('H'), $date->format('i'), $event->getSummary())."\n"; |
68 | - } |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | JarvisTTS::speak($answer); |
@@ -102,27 +102,27 @@ discard block |
||
102 | 102 | * @return Google_Client the authorized client object |
103 | 103 | */ |
104 | 104 | function getClient() { |
105 | - $client = new \Google_Client(); |
|
106 | - $client->setApplicationName(APPLICATION_NAME); |
|
107 | - $client->setScopes(SCOPES); |
|
108 | - $client->setAuthConfigFile(CLIENT_SECRET_PATH); |
|
109 | - $client->setAccessType('offline'); |
|
105 | + $client = new \Google_Client(); |
|
106 | + $client->setApplicationName(APPLICATION_NAME); |
|
107 | + $client->setScopes(SCOPES); |
|
108 | + $client->setAuthConfigFile(CLIENT_SECRET_PATH); |
|
109 | + $client->setAccessType('offline'); |
|
110 | 110 | |
111 | - // Load previously authorized credentials from a file. |
|
112 | - $credentialsPath = CREDENTIALS_PATH; |
|
113 | - if (file_exists($credentialsPath)) { |
|
111 | + // Load previously authorized credentials from a file. |
|
112 | + $credentialsPath = CREDENTIALS_PATH; |
|
113 | + if (file_exists($credentialsPath)) { |
|
114 | 114 | $accessToken = file_get_contents($credentialsPath); |
115 | - } else { |
|
115 | + } else { |
|
116 | 116 | return null; |
117 | - } |
|
118 | - $client->setAccessToken($accessToken); |
|
117 | + } |
|
118 | + $client->setAccessToken($accessToken); |
|
119 | 119 | |
120 | - // Refresh the token if it's expired. |
|
121 | - if ($client->isAccessTokenExpired()) { |
|
120 | + // Refresh the token if it's expired. |
|
121 | + if ($client->isAccessTokenExpired()) { |
|
122 | 122 | $client->refreshToken($client->getRefreshToken()); |
123 | 123 | file_put_contents($credentialsPath, $client->getAccessToken()); |
124 | - } |
|
125 | - return $client; |
|
124 | + } |
|
125 | + return $client; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @author Stefano Bianchini |
21 | 21 | * @website http://www.stefanobianchini.net |
22 | 22 | */ |
23 | -class Gcalendar_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
23 | +class Gcalendar_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
24 | 24 | /** |
25 | 25 | * Priority of plugin |
26 | 26 | * @var int |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // Get the API client and construct the service object. |
40 | 40 | $client = Gcalendar_plugin::getClient(); |
41 | 41 | |
42 | - if($client==null) return null; |
|
42 | + if ($client == null) return null; |
|
43 | 43 | |
44 | 44 | $service = new \Google_Service_Calendar($client); |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $results = $service->events->listEvents($calendarId, $optParams); |
55 | 55 | |
56 | 56 | if (count($results->getItems()) == 0) { |
57 | - $answer = JarvisLanguage::translate('no_appointments',get_called_class()); |
|
57 | + $answer = JarvisLanguage::translate('no_appointments', get_called_class()); |
|
58 | 58 | } else { |
59 | 59 | |
60 | 60 | foreach ($results->getItems() as $event) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $date = new \DateTime($start); |
67 | - $answer.= sprintf(JarvisLanguage::translate('list_events',get_called_class()), $date->format('j'), JarvisLanguage::translate('month_'.$date->format('n'),get_called_class()), $date->format('H'), $date->format('i'), $event->getSummary())."\n"; |
|
67 | + $answer .= sprintf(JarvisLanguage::translate('list_events', get_called_class()), $date->format('j'), JarvisLanguage::translate('month_'.$date->format('n'), get_called_class()), $date->format('H'), $date->format('i'), $event->getSummary())."\n"; |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | 88 | function isLikely($command) { |
89 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
89 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -39,7 +39,9 @@ |
||
39 | 39 | // Get the API client and construct the service object. |
40 | 40 | $client = Gcalendar_plugin::getClient(); |
41 | 41 | |
42 | - if($client==null) return null; |
|
42 | + if($client==null) { |
|
43 | + return null; |
|
44 | + } |
|
43 | 45 | |
44 | 46 | $service = new \Google_Service_Calendar($client); |
45 | 47 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | /** |
57 | 57 | * Is it the right plugin for the command? |
58 | 58 | * @param string $command |
59 | - * @return boolean |
|
59 | + * @return integer |
|
60 | 60 | */ |
61 | 61 | function isLikely($command) { |
62 | 62 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace JarvisPHP\Plugins\Hello_plugin; |
4 | 4 | |
5 | -use JarvisPHP\Core\JarvisSession; |
|
6 | 5 | use JarvisPHP\Core\JarvisPHP; |
7 | 6 | use JarvisPHP\Core\JarvisLanguage; |
8 | 7 | use JarvisPHP\Core\JarvisTTS; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Stefano Bianchini |
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | */ |
15 | -class Hello_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
15 | +class Hello_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
16 | 16 | /** |
17 | 17 | * Priority of plugin |
18 | 18 | * @var int |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | $answer = ''; |
28 | 28 | JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"'); |
29 | 29 | $hour = date("H"); |
30 | - if($hour>5 && $hour<=13) { |
|
30 | + if ($hour > 5 && $hour <= 13) { |
|
31 | 31 | //Morning |
32 | - $answer = JarvisLanguage::translate('hello_morning',get_called_class()); |
|
32 | + $answer = JarvisLanguage::translate('hello_morning', get_called_class()); |
|
33 | 33 | } |
34 | - else if($hour>13 && $hour<18) { |
|
34 | + else if ($hour > 13 && $hour < 18) { |
|
35 | 35 | //Afternoon |
36 | - $answer = JarvisLanguage::translate('hello_afternoon',get_called_class()); |
|
36 | + $answer = JarvisLanguage::translate('hello_afternoon', get_called_class()); |
|
37 | 37 | } else { |
38 | 38 | //Evening (and night, of course) |
39 | - $answer = JarvisLanguage::translate('hello_evening',get_called_class()); |
|
39 | + $answer = JarvisLanguage::translate('hello_evening', get_called_class()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return boolean |
60 | 60 | */ |
61 | 61 | function isLikely($command) { |
62 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
62 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -30,8 +30,7 @@ |
||
30 | 30 | if($hour>5 && $hour<=13) { |
31 | 31 | //Morning |
32 | 32 | $answer = JarvisLanguage::translate('hello_morning',get_called_class()); |
33 | - } |
|
34 | - else if($hour>13 && $hour<18) { |
|
33 | + } else if($hour>13 && $hour<18) { |
|
35 | 34 | //Afternoon |
36 | 35 | $answer = JarvisLanguage::translate('hello_afternoon',get_called_class()); |
37 | 36 | } else { |
@@ -51,7 +51,7 @@ |
||
51 | 51 | /** |
52 | 52 | * Is it the right plugin for the command? |
53 | 53 | * @param string $command |
54 | - * @return boolean |
|
54 | + * @return integer |
|
55 | 55 | */ |
56 | 56 | function isLikely($command) { |
57 | 57 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Stefano Bianchini |
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | */ |
15 | -class Info_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
15 | +class Info_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
16 | 16 | /** |
17 | 17 | * Priority of plugin |
18 | 18 | * @var int |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function answer($command) { |
27 | 27 | $answer = ''; |
28 | - if(preg_match(JarvisLanguage::translate('preg_match_tell_more',get_called_class()), $command)) { |
|
28 | + if (preg_match(JarvisLanguage::translate('preg_match_tell_more', get_called_class()), $command)) { |
|
29 | 29 | //Testing session |
30 | 30 | JarvisPHP::getLogger()->debug('User says: '.$command); |
31 | - $answer = 'Ok, i am on '. php_uname(); |
|
31 | + $answer = 'Ok, i am on '.php_uname(); |
|
32 | 32 | JarvisSession::terminate(); |
33 | 33 | } |
34 | 34 | else { |
35 | 35 | JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"'); |
36 | - $answer = sprintf(JarvisLanguage::translate('my_name_is',get_called_class()),_SYSTEM_NAME, $_SERVER['SERVER_NAME'],$_SERVER['SERVER_ADDR']); |
|
36 | + $answer = sprintf(JarvisLanguage::translate('my_name_is', get_called_class()), _SYSTEM_NAME, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_ADDR']); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | JarvisTTS::speak($answer); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return boolean |
55 | 55 | */ |
56 | 56 | function isLikely($command) { |
57 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
57 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -30,8 +30,7 @@ |
||
30 | 30 | JarvisPHP::getLogger()->debug('User says: '.$command); |
31 | 31 | $answer = 'Ok, i am on '. php_uname(); |
32 | 32 | JarvisSession::terminate(); |
33 | - } |
|
34 | - else { |
|
33 | + } else { |
|
35 | 34 | JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"'); |
36 | 35 | $answer = sprintf(JarvisLanguage::translate('my_name_is',get_called_class()),_SYSTEM_NAME, $_SERVER['SERVER_NAME'],$_SERVER['SERVER_ADDR']); |
37 | 36 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | /** |
58 | 58 | * Is it the right plugin for the command? |
59 | 59 | * @param string $command |
60 | - * @return boolean |
|
60 | + * @return integer |
|
61 | 61 | */ |
62 | 62 | function isLikely($command) { |
63 | 63 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace JarvisPHP\Plugins\InformationOn_plugin; |
4 | 4 | |
5 | -use JarvisPHP\Core\JarvisSession; |
|
6 | 5 | use JarvisPHP\Core\JarvisPHP; |
7 | 6 | use JarvisPHP\Core\JarvisLanguage; |
8 | 7 | use JarvisPHP\Core\JarvisTTS; |
@@ -28,8 +28,8 @@ |
||
28 | 28 | //Extract search term |
29 | 29 | preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command, $matches); |
30 | 30 | $search_term = $matches[2]; |
31 | - $wiki_query_url = _WIKI_URL . "?action=opensearch&search=" . urlencode($search_term) . "&format=xml&limit=5"; |
|
32 | - $xml = simplexml_load_string(file_get_contents($wiki_query_url)); |
|
31 | + $wiki_query_url = _WIKI_URL . "?action=opensearch&search=" . urlencode($search_term) . "&format=xml&limit=5"; |
|
32 | + $xml = simplexml_load_string(file_get_contents($wiki_query_url)); |
|
33 | 33 | $item_array = $xml->Section->Item; |
34 | 34 | $answer = JarvisLanguage::translate('nothing_found',get_called_class()); |
35 | 35 | //Have i got results? |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | * Based on Wiki_plugin of UgoRaffaele https://github.com/UgoRaffaele/ |
15 | 15 | */ |
16 | -class InformationOn_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
16 | +class InformationOn_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
17 | 17 | /** |
18 | 18 | * Priority of plugin |
19 | 19 | * @var int |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function answer($command) { |
28 | 28 | //Extract search term |
29 | - preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command, $matches); |
|
29 | + preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command, $matches); |
|
30 | 30 | $search_term = $matches[2]; |
31 | - $wiki_query_url = _WIKI_URL . "?action=opensearch&search=" . urlencode($search_term) . "&format=xml&limit=5"; |
|
31 | + $wiki_query_url = _WIKI_URL."?action=opensearch&search=".urlencode($search_term)."&format=xml&limit=5"; |
|
32 | 32 | $xml = simplexml_load_string(file_get_contents($wiki_query_url)); |
33 | 33 | $item_array = $xml->Section->Item; |
34 | - $answer = JarvisLanguage::translate('nothing_found',get_called_class()); |
|
34 | + $answer = JarvisLanguage::translate('nothing_found', get_called_class()); |
|
35 | 35 | //Have i got results? |
36 | - if(count($item_array)>0) { |
|
36 | + if (count($item_array) > 0) { |
|
37 | 37 | foreach ($item_array as $item) { |
38 | 38 | if (strlen($item->Description) > 0) { |
39 | - $answer = sprintf(JarvisLanguage::translate('search_result_is',get_called_class()), $item->Description); |
|
39 | + $answer = sprintf(JarvisLanguage::translate('search_result_is', get_called_class()), $item->Description); |
|
40 | 40 | break; |
41 | 41 | } |
42 | 42 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return boolean |
61 | 61 | */ |
62 | 62 | function isLikely($command) { |
63 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
63 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,7 +69,7 @@ |
||
69 | 69 | /** |
70 | 70 | * Is it the right plugin for the command? |
71 | 71 | * @param string $command |
72 | - * @return boolean |
|
72 | + * @return integer |
|
73 | 73 | */ |
74 | 74 | function isLikely($command) { |
75 | 75 | return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace JarvisPHP\Plugins\Movie_plugin; |
4 | 4 | |
5 | -use JarvisPHP\Core\JarvisSession; |
|
6 | 5 | use JarvisPHP\Core\JarvisPHP; |
7 | 6 | use JarvisPHP\Core\JarvisLanguage; |
8 | 7 | use JarvisPHP\Core\JarvisTTS; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Stefano Bianchini |
13 | 13 | * @website http://www.stefanobianchini.net |
14 | 14 | */ |
15 | -class Movie_plugin implements \JarvisPHP\Core\JarvisPluginInterface{ |
|
15 | +class Movie_plugin implements \JarvisPHP\Core\JarvisPluginInterface { |
|
16 | 16 | /** |
17 | 17 | * Priority of plugin |
18 | 18 | * @var int |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"'); |
29 | 29 | |
30 | 30 | //Understand the movie |
31 | - preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command, $matches); |
|
31 | + preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command, $matches); |
|
32 | 32 | |
33 | 33 | $movie_title = end($matches); |
34 | 34 | |
35 | 35 | $_THEMOVIEDB_API_KEY = ''; |
36 | 36 | |
37 | 37 | //Load API key from json config |
38 | - if(file_exists('Plugins/Movie_plugin/api-key.json')) { |
|
38 | + if (file_exists('Plugins/Movie_plugin/api-key.json')) { |
|
39 | 39 | //Create your own api key and put it in api-key.json |
40 | 40 | $json_config = json_decode(file_get_contents('Plugins/Movie_plugin/api-key.json')); |
41 | 41 | $_THEMOVIEDB_API_KEY = $json_config->themoviedb_key; |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | |
47 | 47 | $result = $client->getSearchApi()->searchMovies($movie_title, ['language'=>_LANGUAGE, 'page'=>1]); |
48 | 48 | |
49 | - if(count($result['results'])>0) { |
|
50 | - $answer = ($result['results'][0]['overview']) ? ($result['results'][0]['overview']) : JarvisLanguage::translate('no_results',get_called_class()); |
|
49 | + if (count($result['results']) > 0) { |
|
50 | + $answer = ($result['results'][0]['overview']) ? ($result['results'][0]['overview']) : JarvisLanguage::translate('no_results', get_called_class()); |
|
51 | 51 | } else { |
52 | 52 | //No results |
53 | - $answer = JarvisLanguage::translate('no_results',get_called_class()); |
|
53 | + $answer = JarvisLanguage::translate('no_results', get_called_class()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | JarvisTTS::speak($answer); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return boolean |
73 | 73 | */ |
74 | 74 | function isLikely($command) { |
75 | - return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command); |
|
75 | + return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |