diff options
author | Alexander NeonXP Kiryukhin <frei@neonxp.info> | 2016-05-27 16:08:37 +0300 |
---|---|---|
committer | Alexander NeonXP Kiryukhin <frei@neonxp.info> | 2016-05-27 16:08:37 +0300 |
commit | b0ce9633e6f33fd0b68ac3c2104447ec729d7369 (patch) | |
tree | ff530a564fa1711759511a82c4266da103697de2 /src | |
parent | 7dc916517ba8574eff45e095b071ae10e8394617 (diff) |
Added DB search 2
Diffstat (limited to 'src')
-rw-r--r-- | src/NeonXP/BotScript.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/NeonXP/BotScript.php b/src/NeonXP/BotScript.php index 6dfeb9e..ac01681 100644 --- a/src/NeonXP/BotScript.php +++ b/src/NeonXP/BotScript.php @@ -83,13 +83,26 @@ class BotScript '33' => ['Я', 'А', ' ', ' ', ' ', ' ', '100001', '. - . -'], ]; $result = 'Непонятно :('; - if (is_numeric($text) && (isset($db[$text]))) { + if ($text == '$') { + $result = ''; + foreach ($db as $key => $value) { + $result .= sprintf('*%d* АлфЁ *%s* Алф *%s* ОбрЁ *%s* Обр *%s* Alph *%s* RvrsAlph *%s* Двоич *%s* Морз *%s*', + $key, $value[0],$value[1],$value[2],$value[3], $value[4],$value[5], $value[6],$value[7] + ) . PHP_EOL; + } + } elseif (is_numeric($text) && (isset($db[$text]))) { $result = sprintf('*%d* АлфЁ *%s* Алф *%s* ОбрЁ *%s* Обр *%s* Alph *%s* RvrsAlph *%s* Двоич *%s* Морз *%s*', $text, $db[$text][0],$db[$text][1],$db[$text][2],$db[$text][3], $db[$text][4],$db[$text][5], $db[$text][6],$db[$text][7] ); } else { foreach ($db as $key => $value) { - if ($value[0] == $text) { + if (mb_strtolower($value[0], 'utf8') == mb_strtolower($text)) { + $result = sprintf('*%d* АлфЁ *%s* Алф *%s* ОбрЁ *%s* Обр *%s* Alph *%s* RvrsAlph *%s* Двоич *%s* Морз *%s*', + $key, $value[0],$value[1],$value[2],$value[3], $value[4],$value[5], $value[6],$value[7] + ); + } + + if (strtolower($value[4]) == strtolower($text)) { $result = sprintf('*%d* АлфЁ *%s* Алф *%s* ОбрЁ *%s* Обр *%s* Alph *%s* RvrsAlph *%s* Двоич *%s* Морз *%s*', $key, $value[0],$value[1],$value[2],$value[3], $value[4],$value[5], $value[6],$value[7] ); @@ -97,7 +110,7 @@ class BotScript } } if ($result) { - $telegram->getMethods()->sendMessage($message->getChat(), $result, true); + $telegram->getMethods()->sendMessage($message->getChat(), '```' . PHP_EOL . $result . PHP_EOL . '```', true); } return State::INITIAL; //Set initial state |