Giter Site home page Giter Site logo

turibot's Introduction

TuriBot

TuriBot is a simple way to communicate with Telegram APIs in PHP

Latest Stable Version Total Downloads License

Requirements

PHP 7.1 or higher with curl extension

Installation

composer require davtur19/turibot

Webhook

Setup recommended: open setupWebhook.php in your browser and follow the setup wizard.

Manual setup: set webhook to the file webhook.php, and as parameter GET "api" set your token.

Example for manual setup:

curl https://api.telegram.org/botTOKEN/setWebhook?url=https://WEBSITE/DIR/webhook.php?api=TOKEN

Alternatively if you don't want to use GET, just change this piece of code.

GetUpdates

Setup Token

Usage

  • Look at the examples (webhook.php and getUpdates.php), it's very simple if you know PHP and OOP
  • All methods have the parameters in the same order as the BotAPIs
  • The reply_markup, permissions, commands, entities and parameters that require arrays, already have a json_encode in the functions, you just need to pass arrays

Security

https://github.com/php-telegram-bot/core/wiki/Securing-&-Hardening-your-Telegram-Bot

Custom endpoint

With the Bot API 5.0 it is now possible to self host your own Bot API, here is an example of how to add your own endpoint

//token, json_payload, endpoint
$client = new Client("1234:AAbbccdd", false, "http://endpoint/bot");

Json payload

Only works with webhooks, for more info: https://core.telegram.org/bots/faq#how-can-i-make-requests-in-response-to-updates

I do not recommend using it as it may need a particular configuration to the webserver for flushing and you cannot get a response from the Bot API

Generator

https://github.com/davtur19/TuriBotGen

Contributors

Old version

I don't recommend its use, but it could be useful for those unfamiliar with OOP and would like to start learning how PHP and Telegram Bot Api work.

https://github.com/davtur19/TuriBot/tree/old

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.