Modern Telegram bot template. Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats. These accounts serve as an interface for code running somewhere on your server.
- PHP Hosting
- SSL Certificate (If you don't have it, you can use Cloudflare)
- CURL IS NOT REQUIRED
define("TOKEN", "BOT_TOKEN"); // (REQUIRED) BOT_TOKEN
define('ADMIN_ID', 'YOUR_ID'); // (OPTIONAL) YOUR ID
$_FEATURES = Array(
"debug" => false, // (OPTIONAL) YOUR_ID OR FALSE
"db_enabled" => false // (OPTIONAL) TRUE OR FALSE
);
$_DATABASE_CONFIG = Array(
"host" => "localhost", // DATABASE HOST
"username" => "username", // DATABASE USER
"password" => "password", // DATABASE USER PASSWORD
"database_name" => "db_name" // DATABASE NAME
);
- Set Webhook
- The End!
Location | Variable | Description |
---|---|---|
GLOBAL | $tg | Telegram Object |
GLOBAL | $db | Database Object |
GLOBAL | $_DATA | Webhook Income Data |
~GLOBAL | $_M | Message Object |
SIMPLE_MESSAGE | $_T | Message Text exploded by space |
~GLOBAL | $_CID | Telegram Message Chat Id |
INLINE_BUTTON | $_QID | Callback Query ID |
INLINE_BUTTON | $_QDATA | Callback Query DATA exploded by ";" |
$tg->METHOD_NAME($PARAM_1, $PARAM_2, ..., $PARAM_N)
Name | PARAMS | Return |
---|---|---|
sendRequest | (String) Method, (Array) Params | Array Telegram API Response |
buildInlineButton | Inline Button | Array |
buildReplyButton | Reply Button | Array |
buildInlineKeyboard | (Array) of InlineButtons | String JSON |
buildReplyKeyboard | (Array) of ReplyButtons, Array of params | String JSON |
buildForceReply | (Array) of params | String JSON |
removeReplyKeyboard | (Array) of params | String JSON |
buildInlineLine | (Array) of params | Array |
buildInlineQueryResult | (Array) of params | String JSON |
ROOT:
├── classes
│ ├── tg.class.php // Telegram API class
│ └── db.class.php // Database class
├── query_type
│ ├── inline_button.php // Message type inline button
│ ├── inline_message.php // Message type inline query
│ └── simple_message.php // Message type simple message
├── lang.php // language file
├── bot.php // Main file, requested by WebHook
├── var.php // Main variables of bot
└── lang.php // language file