/addon-manager

Addon Manager for Telegram Bot SDK

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Addon Manager for Telegram Bot SDK

Join PHP Chat Chat on Telegram Build Status Latest Version Total Downloads

Addon Manager to add, remove, manage and load addons into Telegram Bot SDK.

If you want to develop addons for Telegram Bot SDK, please make sure to require this package in your composer file.

Install

$ composer require telegram-bot-sdk/addon-manager

Usage

Create An Addon

<?php

namespace Acme\Addons;

use Telegram\Bot\Addon\Addon;
use Telegram\Bot\Events\UpdateEvent;

class AcmeAddon extends Addon
{
    public function register()
    {
        $this->bot->onUpdate(function (UpdateEvent $event) {
            $bot = $event->bot;
            $update = $event->update;

            // Do something with the inbound update received.
        });
    }
}

Register Addon

Auto-Discovery

The Addon Manager supports auto-discovery which registers the addons automatically.

Simply create a discovery.json file in your project root.

{
  "telegram/addon-config": [
    "config/acme.php"
  ],
  "telegram/addon": [
    "Acme\\Addons\\AcmeAddon"
  ]
}

Manually Register

use Acme\Addons\AcmeAddon;
use Telegram\Bot\Addon\AddonManager;

// Make sure to register before initializing bot manager.
AddonManager::register(AcmeAddon::class);

Remove Addon

AddonManager::remove(AcmeAddon::class);

Get Addons

$addons = AddonManager::getAddons();

Auto-Discover & Register Addons

AddonManager::discover();

Are You Using Telegram Bot SDK?

If you're using Telegram Bot SDK build your Telegram Bots or have a project that's relevant to the SDK, We'd love to know and share it with the world.

Head over to Awesome Telegram Bots to share, discover, and learn more.

Contributing

Thank you for considering contributing to the project. Please read the contributing guide before creating an issue or sending in a pull request.

Code of Conduct

Please read our Code of Conduct before contributing or engaging in discussions.

Security

If you discover a security vulnerability within this project, please email Syed at syed at lukonet.com. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

Credits

License

This project is open-sourced software licensed under the BSD 3-Clause license.