Git Product home page Git Product logo

telegran's Introduction

Telegran

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.

Table of Content

  1. Pre-Requirements
  2. Quich Start
  3. Variables
  4. Telegram Class Methods
  5. Template structure

Pre-Requirements

  1. PHP Hosting
  2. SSL Certificate (If you don't have it, you can use Cloudflare)
  3. CURL IS NOT REQUIRED

Quick Start

  1. Clone template to your website
  2. Create bot via BotFather
  3. Open var.php and edit this:
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
);
  1. Set Webhook
  2. The End!

Variables

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 ";"

Telegram Class Methods

Using:

$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

Template structure

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

telegran's People

Contributors

naziks avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.