定制 yooznet/chatgenius 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yooznet/chatgenius

最新稳定版本:1.0.0

Composer 安装命令:

composer require yooznet/chatgenius

包简介

A PHP library for interacting with the Telegram API.

README 文档

README

ChatGenius is a PHP package for interacting with the Telegram API. This README provides instructions for installing, configuring, and using the package to send messages, reply to users, and create custom keyboards.

Installation

To install the package, use Composer:

composer require yooznet/chatgenius:^1.0.0

Setup

First, include the necessary classes in your project:

use ChatGenius\TelegramAction;
use App\Classes\user\Handler;

Create a new instance of TelegramAction with your bot token:

$telegram = new TelegramAction('Your_Token_Here');
$update = new HandleUpdate();

Sending Messages

To send a message, use the following code:

$telegram->ChatID($update->chat_id)
         ->Text('Welcome to our world!')
         ->sendMessage();

Replying to User Messages

To reply to a user's message, first check if there is a message_id, and then use the Reply class:

use ChatGenius\Reply;

$reply = $update->message_id ? new Reply(message_id: $update->message_id) : null;

$telegram->ChatID($update->chat_id)
         ->Reply($reply)
         ->Text('Welcome to our world!')
         ->sendMessage();

Creating Buttons

Inline Keyboard

To create an inline keyboard with buttons:

use ChatGenius\Keyboard;

$keyboard = new Keyboard(
    type: 'InlineKeyboardMarkup',
    inlineKeyboard: [
        [
            ['text' => 'test', 'callback_data' => 'test'],
            ['text' => 'test2', 'callback_data' => 'test2'],
        ],
    ]
);

Reply Keyboard

To create a regular reply keyboard:

$keyboard = new Keyboard(
    type: 'ReplyKeyboardMarkup',
    keyboard: [
        ['test']
    ],
    resizeKeyboard: true,
    oneTimeKeyboard: true
);

Removing Keyboard

To remove the keyboard:

$keyboard = new Keyboard(
    type: 'ReplyKeyboardRemove',
    removeKeyboard: true
);

Sending Messages with Keyboard

To send a message with a custom keyboard:

$telegram->ChatID($update->chat_id)
         ->Text('Welcome to our world!')
         ->ReplyMarkup($keyboard)
         ->sendMessage();

Contributing Feel free to contribute to this project by submitting issues or pull requests.

License This project is licensed under the MIT License. See the LICENSE file for more details.

Contact For any questions or feedback, please reach out to mail@yooznet.online.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固