Giter Site home page Giter Site logo

tg-long-req's Introduction

TG LONG REQUEST

What is this?

This is a small help-oriented class for creating tg bots. It helps with the creation and navigation in the menu telegram bot


Это небольшой класс для телеграм ботов. Он помогает в создании меню и дальнейшей навигации в нём.

Abstract exemple

INSTALL

via composer

(add this to section "require" in your composer.json)

{
  "require" : {  
	"s0d3s/tg-long-req": ">=1"   
  }
}

and

include_once('path/to/autoload.php');
use s0d3s\TgLongReq;

manual

Copy the "TgLongReq.php" to the project dir and:

include_once('TgLongReq.php');
use s0d3s\TgLongReq;

Simple use

  1. Create a TgLongReq obj

$tg_req = TgLongReq ( 'user_id', 'req_func list' /optinal/ , 'user_request_dir', tg_api_key, tg_api_result );

Var Type Caption
$user_id STRING Telegram user id
$req_func ARRAY Requests and functions association table
$usr_req_dir STR Path to general request dir **
$tg_api_key SOMETH/* irazasyed/telegram-bot-sdk Api() object*
$tg_api_result SOMETH/* Api()->getWebhookUpdates()

*It could be something else, or be null. **Temporary requests from users will be stored in this folder.


  1. Create request

$tg_req->reqCreate('req_name'); *

*This parameter depends only on you (this name should be in the association table)


  1. Save and restore temprorary data
  • saving

For store (temporary) data, you can use "saveToTemp", the function accepts any data types and saves it as json string

$tg_req->saveToTemp($some_data);

  • restore

.

$some_array = array(); $some_array = $tg_req->getFromTemp($hold_it==false);*

* If needed, you can leave a temporary file until the next used, for this pass to function "true"(bool)


  1. Check the existence of the request

$tg_req->reqCheck(); //return true if exists, else false


  1. Delete user request

$tg_req->reqDel();


  1. Handling request

$tg_req->reqHand(); //This method will call the corresponding function from the association table.


  1. NOTES
  • Association table is array('req_name'=>'func_name')
  • Functions specified in the table may not process passed parameters

Some examples you can find at ./exmp

tg-long-req's People

Contributors

s0d3s 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.