@@ -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 |
@@ -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); |
@@ -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); |
@@ -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); |
@@ -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(); |
@@ -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 | } |
@@ -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); |
@@ -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); |
@@ -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); |
@@ -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? |
@@ -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); |