Code Duplication    Length = 11-12 lines in 2 locations

TelegramBot/JarvisPHPTelegramBot.php 2 locations

@@ 62-73 (lines=12) @@
59
							}
60
61
							//"Say" Telegram command
62
							if(preg_match('$^/say (.+)$', $message, $matches)) {
63
								if($matches) {
64
									if(in_array($update->message->chat->id, $allowedClientIdList)) {
65
										//Redirect message to JarvisPhp
66
										$JarvisResponse = GenericCurl::exec(_JARVISPHP_URL.'/say', array('sentence'=>$matches[1]));
67
68
										$response = $JarvisResponse->answer;
69
									} else {
70
										$response = 'You are not allowed to speak with me.';
71
									}
72
								}
73
							}
74
75
							//Encode emoji
76
							$response = preg_replace_callback('/\\\\u([0-9a-fA-F]+)/', function ($match) {
@@ 80-90 (lines=11) @@
77
							    return iconv('UCS-4LE', 'UTF-8', pack('V', hexdec($match[1])));
78
							}, $response);
79
80
						} else {
81
							if(in_array($update->message->chat->id, $allowedClientIdList)) {
82
								//Redirect message to JarvisPhp
83
								$JarvisResponse = GenericCurl::exec(_JARVISPHP_URL.'/answer', array('command'=>$message, 'tts' => 'None_tts'));
84
85
								$response = $JarvisResponse->answer;
86
							} else {
87
								$response = 'You are not allowed to speak with me.';
88
							}
89
90
						}
91
						if($response) {
92
							$bot->apiRequestJson("sendMessage", array('chat_id' => $update->message->chat->id, "text" => $response));
93
						}