imafaz/neili

neili is a lightweight library for managing and creating automation for telegram api bots

1.0.0 2023-10-28 13:19 UTC

This package is auto-updated.

Last update: 2024-09-28 15:23:51 UTC


README

neili is a lightweight library for managing and creating automation for telegram api bots.

Requirements

This library is supported by PHP versions 7.0 or higher
neili uses the EasyLog version ^1

Installation

The preferred way to install this extension is through Composer.

To install Neili, simply:

$ composer require imafaz/Neili

Quick Start

To use this library with Composer:

require __DIR__ . '/vendor/autoload.php';

use TelegramBot\Neili;

Usage

Create an instance of Neili

$bot = new Neili('token');

Send a simple message:

$chatId = '1826312667'; 
$message = 'hello  this message sended with neili!';
$bot->sendMessage($chatId, $message);

Available Method

- __construct

// $bot = new Neili(string $accessToken);

// example:

$accessToken = 'xxxxx'; 
$bot = new Neili($accessToken);

# Return (void)

If you don't find the method you need, you can use below:

- custom method

// $bot->methodName(array $parameters);

//example:

$chatId = '1826312667';
$bot->sendPhoto([
    'chat_id' => $chatId,
    'photo' => new CURLFile('test.jpg')
]);

# Return (array)

- handleUpdate

// $bot->handleUpdate(string $secretToken = null);

// example:

// secure
$secret = 'xxxxx';
$bot->handleUpdate($secret);
// not secure
$bot->handleUpdate();

# Return (array)

- sendMessage

// $bot->sendMessage($chatId, $message,$keyboard,$params);

// example:

$chatId = '1826312667'; 
$message = 'hello  this message sended with neili!';

// basic
$bot->sendMessage($chatId, $message);
// advance
$bot->sendMessage($chatId, $message,null,['parse_mode'=>'html','disable_web_page_preview'=>true]);

# Return (array)

- keyboard

// Neili::keyboard(array $buttons, int $raw = 2, bool $resize = true);

// example:

$buttons = ['button1','button2','button3','button4','button5'];
Neili::keyboard($buttons);

# Return (json)

- inlineKeyboard

// Neili::inlineKeyboard(array $buttons, int $raw = 2);

// example:

$buttons = ['button1'=>'customdata','button2'=>'customdata','button3'=>'customdata'];
Neili::inlineKeyboard($buttons);

# Return (json)

License