Skip to content

Instantly share code, notes, and snippets.

@Fayozjon
Created August 22, 2018 19:55
Show Gist options
  • Save Fayozjon/c8b42be488a95c71f77e9ea8f021fdc4 to your computer and use it in GitHub Desktop.
Save Fayozjon/c8b42be488a95c71f77e9ea8f021fdc4 to your computer and use it in GitHub Desktop.
Controller with extending Telegram Bot php Library for Codeigniter
<?php defined('BASEPATH') OR exit('No direct script access allowed');
date_default_timezone_set('Asia/Tashkent');
use Longman\TelegramBot\Entities\InlineKeyboard;
use Longman\TelegramBot\Entities\Keyboard;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram;
use Longman\TelegramBot\TelegramLog;
use Longman\TelegramBot\DB;
class CITelegram extends Telegram{
public $ci;
public function __construct($api_key, $bot_username = '')
{
if (empty($api_key)) {
throw new TelegramException('API KEY not defined!');
}
preg_match('/(\d+)\:[\w\-]+/', $api_key, $matches);
if (!isset($matches[1])) {
throw new TelegramException('Invalid API KEY defined!');
}
$this->bot_id = $matches[1];
$this->api_key = $api_key;
if (!empty($bot_username)) {
$this->bot_username = $bot_username;
}
//Add default system commands path
$this->addCommandsPath(TB_BASE_COMMANDS_PATH . '/SystemCommands');
$this->ci = &get_instance();
Request::initialize($this);
}
}
class Welcome extends CI_Controller
{
@reactmore
Copy link

Hey do you have example implementation this library bot to codeigniter ? I try it but bot no respon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment