All Projects → danyspin97 → PhpBotFramework

danyspin97 / PhpBotFramework

Licence: LGPL-3.0 license
A framework for Telegram Bot API written in PHP.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to PhpBotFramework

laravel-dingtalk
✨基于laravel5.5开发的钉钉机器人、支持多个钉钉群
Stars: ✭ 18 (-67.86%)
Mutual labels:  composer, webhook
The-PHP-Workshop
A New, Interactive Approach to Learning PHP
Stars: ✭ 30 (-46.43%)
Mutual labels:  composer, guzzle
mastodon-api-php
PHP wrapper for the Mastodon API.
Stars: ✭ 12 (-78.57%)
Mutual labels:  composer, guzzle
Satis Server
🐳 Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.
Stars: ✭ 96 (+71.43%)
Mutual labels:  composer, webhook
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+8.93%)
Mutual labels:  composer, guzzle
Packages
Enhances Composer Satis with webhook integrations to GitHub and GitLab
Stars: ✭ 157 (+180.36%)
Mutual labels:  composer, webhook
composer-normalize-action
+ 🎵 Provides a GitHub action for running ergebnis/composer-normalize.
Stars: ✭ 25 (-55.36%)
Mutual labels:  composer
deployserver
Deploy your project automatically when git branch was updated.
Stars: ✭ 24 (-57.14%)
Mutual labels:  webhook
selene
A opinionated Wordpress base theme based on Sage.
Stars: ✭ 31 (-44.64%)
Mutual labels:  composer
guzzle-oauth2-subscriber
OAuth 2.0 Client for Guzzle 4, 5, 6 and 7 with PHP 5.4 - PHP 8.0 - no more dependency hell!
Stars: ✭ 112 (+100%)
Mutual labels:  guzzle
gh-auto-updater
Automatic Updater with GitHub API for WordPress Plugin
Stars: ✭ 42 (-25%)
Mutual labels:  composer
acme2
Another PHP client for acme protocal (version 2) implementation, used for generating letsencrypt's free ssl certificates.
Stars: ✭ 45 (-19.64%)
Mutual labels:  composer
routing
Aplus Framework Routing Library
Stars: ✭ 186 (+232.14%)
Mutual labels:  composer
pagination
Aplus Framework Pagination Library
Stars: ✭ 167 (+198.21%)
Mutual labels:  composer
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (-69.64%)
Mutual labels:  guzzle
behat-3-kickstart
Behat 3/Mink and Guzzle for API testing. Code follows PageObjects approach. Saucelabs integration.
Stars: ✭ 13 (-76.79%)
Mutual labels:  guzzle
packagist
🐳 Dockette out-of-box Packagist (Nginx / Solr 6 / PHP 7.1+FPM)
Stars: ✭ 32 (-42.86%)
Mutual labels:  composer
cygnite-application
Cygnite PHP Framework- Skeleton Application
Stars: ✭ 26 (-53.57%)
Mutual labels:  composer
ubiquity-devtools
Command line tools for Ubiquity framework
Stars: ✭ 12 (-78.57%)
Mutual labels:  composer
composer-file-loader
Tool to load namespaces and classes from composer.json file without composer
Stars: ✭ 64 (+14.29%)
Mutual labels:  composer

Php Bot Framework

Total Downloads Latest Stable Version Build Status Codacy Badge Scrutinizer Code Quality Code Coverage PHPStan License

PhpBotFramework is a reliable and complete framework for Telegram Bot API with support to Payments APIs.

Designed to be fast and easy to use, it provides all the features a user need in order to start developing Telegram bots.

Usage

<?php

// Include the framework
require './vendor/autoload.php';

// Create a bot
$bot = new PhpBotFramework\Bot("token");

// Create a command that will be triggered everytime the user send `/start`
$start_command = new PhpBotFramework\Commands\MessageCommand("start",
    function($bot, $message) {
        // Reply with a message
        $bot->sendMessage("Hello, folks!");
    }
);

$bot->addCommand($start_command);

// A shortcut for message commands.

$bot->addMessageCommand('about', function($bot, $message) {
  $bot->sendMessage('Powered by PhpBotFramework');
});

// Receive updates from Telegram using getUpdates
$bot->run(GETUPDATES);

Features

  • Modular: take only what you need
  • Flexible HTTP requests with Guzzle
  • Designed to be fast and easy to use
  • Support for local updates and webhooks
  • Support for the most important API methods
  • Command-handle system for messages and callback queries
  • Update type based processing
  • Easy inline keyboard creation
  • Inline query results' handler
  • Database support and facilities
  • Redis support
  • Support for multilanguage bots
  • Support for bot states
  • Upload local files
  • Highly-documented

Requisites

  • PHP >= 7.0
  • php-mbstring
  • Composer (to install this package and the required ones)
  • Web server: required for webhook (we recommend nginx)
  • SSL certificate: required for webhook (follow these steps to make a self-signed certificate or use Let's Encrypt)

Installation

You can install PhpBotFramework using Composer.

Go to your project's folder and type:

composer require danyspin97/php-bot-framework
composer install --no-dev

Documentation

Check the documentation for learning more about PhpBotFramework.

FAQ

  • Why we don't implement asynchronous requests?

    We use Guzzle in order to fire HTTP requests to Telegram Bot API.

    Unfortunately it doesn't implement real asynchronous requests but a sort of.

    Take a look to this issue for more information.

  • Why there isn't a chat_id parameter to pass for API methods?

    PhpBotFramework is "smart" enough to set it as the current user, group or channel ID. Most of the frameworks out there requires you to specify the chat ID for every method's call but PhpBotFramework does it for you calling most API methods on the current chat.

Examples

You can find a list of examples bot right in examples/ folder.

All examples listed here are fully functional: you only need a valid Telegram bot token.

Made with PhpBotFramework

Testing

PhpBotFramework comes with a test suite you can run using PHPUnit.

You need to set MOCK_SERVER_PORT environment variable which tells PhpBotFramework on which port run the mock server that allows the tests to be executed.

export MOCK_SERVER_PORT=9696

Now you can run the run the mock server:

./start_mock_server.sh

And run the test suite:

php vendor/bin/phpunit

Author

This framework is developed and mantained by Danilo Spinella and Dom Corvasce.

License

PhpBotFramework is released under GNU Lesser General Public License v3.

You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications) can only be redistributed under LGPL-3, but applications that use the framework don't have to be.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].