imafaz / neili
neili 是一个用于管理和创建 Telegram API 机器人自动化的轻量级库
1.0.0
2023-10-28 13:19 UTC
Requires
- php-64bit: >=7.0
- imafaz/easylog: ^1
README
neili 是一个用于管理和创建 Telegram API 机器人自动化的轻量级库。
要求
此库支持 PHP 版本 7.0 或更高版本
neili 使用 EasyLog 版本 ^1
安装
安装此扩展的首选方式是通过 Composer。
要安装 Neili,只需
$ composer require imafaz/Neili
快速开始
使用 Composer 使用此库
require __DIR__ . '/vendor/autoload.php'; use TelegramBot\Neili;
用法
创建 Neili 实例
$bot = new Neili('token');
发送一条简单消息
$chatId = '1826312667'; $message = 'hello this message sended with neili!'; $bot->sendMessage($chatId, $message);
可用方法
- __construct
// $bot = new Neili(string $accessToken); // example: $accessToken = 'xxxxx'; $bot = new Neili($accessToken);
返回 (void)
如果您找不到您需要的方法,您可以使用以下方法
- 方法: TELEGRAM 文档
- 示例: tests/customMethod.php
- 自定义方法
// $bot->methodName(array $parameters); //example: $chatId = '1826312667'; $bot->sendPhoto([ 'chat_id' => $chatId, 'photo' => new CURLFile('test.jpg') ]);
返回 (array)
- handleUpdate
// $bot->handleUpdate(string $secretToken = null); // example: // secure $secret = 'xxxxx'; $bot->handleUpdate($secret); // not secure $bot->handleUpdate();
返回 (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]);
返回 (array)
- keyboard
// Neili::keyboard(array $buttons, int $raw = 2, bool $resize = true); // example: $buttons = ['button1','button2','button3','button4','button5']; Neili::keyboard($buttons);
返回 (json)
- inlineKeyboard
// Neili::inlineKeyboard(array $buttons, int $raw = 2); // example: $buttons = ['button1'=>'customdata','button2'=>'customdata','button3'=>'customdata']; Neili::inlineKeyboard($buttons);
返回 (json)
许可证
- 此脚本遵循 MIT 许可证。