GithubHelp home page GithubHelp logo

tm288 / silbot-webhook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from silveros/silbot-webhook

0.0 0.0 0.0 170 KB

PHP framework for Telegram Bots

Home Page: http://t.me/SilverOSp

PHP 100.00%

silbot-webhook's Introduction

SilBot 1.5

A new version based on OOP programming in PHP 7 with MySQL integration.


Documentation

You can read the full documentation for this framework on https://github.com/SilverOS/Silbot-Webhook/wiki. To easly install this framework you can use the installer.


Webhook

To set the bot's webhook you have to do a setWebhook request to the botAPI using this format: https://api.telegram.org/botTOKEN/setWebhook?url=https://your.server.com/path/index.php?token=TOKEN

You can also use @DevToolsForBot using Set Webhook and writing first the token and next the url to your server in format https://your.server.com/path/index.php?token=TOKEN


How it works

In the file functions/botapi.php there is the botApi class, where there are the functions to make requests to the botapi. In index.php is defined in $bot, so to send a message you can use $bot->sendMessage('Chat_ID','Text');.

Then, there is the file functions/update.php whose purpose is to set variables, sort the update and, if set, save users in the database. The variables are set dinamically, the objects which do this are in functions/objects.php.

In conclusion, index.php make same important variables easier tu write and execute commands.php, where the bot's code should be written.

You can include config.php in an external file to use the framework's functions and objects without elaborating an update


Config

In the config.php file you will find an array, $config, where you can set pre-defined values for some botapi variables if not included in the function, such as disable_notification. You can also set if you want a MySQL database.


MySQL

To use this you have to set database->active on true and insert your credentials in the config. After that are asked the names of two tables:

  • universal_table => Created to work with more than one bot, there will be saved all the users and chats the bot see with Telegram information, even with forwarded messages or reply. The table contains 4 coloumns: chat_id,username,lang,type
  • bot_table => Where the bot's users are saved, by default it only contains two coloumns: chat_id, state. This is made to do stuff with the code.

To install the database you need to do a GET request to the webhook url with the parameter install


Plugins

There are two plugins folders:

  • Plugins in plugins/start will be loaded before commands.php
  • Plugins in plugins/end will be loaded after commands.php To add a plugin just drop it in the needed folder

TO-DO List

  • Finish adding all the botapi methods
  • Add more functions to objects

silbot-webhook's People

Contributors

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