Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Api\Telegram;
- use App\Models\Country;
- use App\Models\Translate;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use TelegramBot\Api\Exception;
- use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
- class InfoController extends Controller
- {
- public function info($bot, $message) {
- try {
- $text = $message->getText();
- $text = str_replace('/info','', $text);
- $data = Translate::where('name', 'LIKE', "%$text%")
- ->where('language', '=', 'ru')
- ->orWhere('alias', 'LIKE', "%$text%")
- ->first();
- if(empty($data)) {
- $keyboard = new InlineKeyboardMarkup(
- [
- [
- ['text' => 'Перейти на сайт', 'url' => 'http://xxxxxxx.xxx' . route('xxxxxxx', null, false)],
- ]
- ]
- );
- $bot->sendMessage($message->getChat()->getId(), "К сожалению ничего не найдено. Уточните поиск или посетите наш сайт\n", false, false, null, $keyboard);
- return;
- }
- $detail = Country::where('information_id', '=', $data->information_id)
- ->where('country', '=', 'ru')
- ->first();
- $buttons = array([
- ['text' => 'Отзывы', 'url' => 'http://xxxxxxx.xxx' . route('site.comments', ['xxxxxxx' => $data->alias], false)],
- ['text' => 'Читать обзор', 'url' => 'http://xxxxxxx.xxx' . route('info.show', ['alias' => $data->alias], false)],
- ]);
- $link = "";
- if (!empty($detail)) {
- $buttons[0][] = ['text' => 'Перейти на сайт', 'url' => $detail->url_play];
- $link = "<a href='$detail->url_play'>Перейти на сайт</a>\n";
- }
- $keyboard = new InlineKeyboardMarkup(
- $buttons
- );
- $textMessage = "<b>" . $data->name . "</b>\n". $link . $data->description;
- $bot->sendMessage($message->getChat()->getId(), $textMessage, 'HTML', true, null, $keyboard);
- } catch (Exception $e) {
- $e->getMessage();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement