uziins/laravel-telegram-bot

将PHP Telegram Bot集成到Laravel中。

dev-main 2023-01-13 12:13 UTC

This package is auto-updated.

Last update: 2024-09-13 19:19:23 UTC


README

Latest Version on Packagist Total Downloads

安装

通过Composer安装此包。在你的项目终端运行此命令

composer require uziins/laravel-telegram-bot

用法

对于此Laravel包的进一步基本配置,您不需要创建任何配置文件。

数据库迁移

php artisan migrate

发布配置文件

php artisan vendor:publish --tag="telegram-config"

发布路由文件

php artisan vendor:publish --tag="telegram-routes"

用于Webhook使用的Artisan终端命令(记住,您需要HTTPS服务器才能使用它)

# Use this method to specify a url and receive incoming updates via an outgoing webhook
php artisan telegram:set-webhook
# List of available options: 
# --d|drop-pending-updates : Drop all pending updates
# --a|all-update-types : Explicitly allow all updates (including "chat_member")
# --allowed-updates= : Define allowed updates (comma-seperated)

# Use this method to remove webhook integration if you decide to switch back to getUpdates
php artisan telegram:delete-webhook
# List of available options:
# --d|drop-pending-updates : Pass to drop all pending updates

用于Telegram getUpdates方法的Artisan终端命令

# Fetches Telegram updates periodically
php artisan telegram:fetch 
# List of available options:
# --a|all-update-types : Explicitly allow all updates (including "chat_member")
# --allowed-updates= : Define allowed updates (comma-seperated)

用于Telegram Server注销的Artisan终端命令

# Sends a logout to the currently registered Telegram Server
php artisan telegram:logout

用于关闭Telegram Server的Artisan终端命令

# Sends a close to the currently registered Telegram Server
php artisan telegram:close

用于在您的项目中发布Telegram命令文件夹结构的Artisan终端命令

# Publishes folder structure for Telegram Commands
# Default StartCommand class will be created
php artisan telegram:publish

用于在您的项目中创建新的Telegram命令类的Artisan终端命令

# Create a new Telegram Bot Command class
# e.g. php artisan make:telegram-command Menu --> will make User command class MenuCommand 
# e.g. php artisan make:telegram-command Genericmessage --system --> will make System command class GenericmessageCommand
php artisan make:telegram-command
# List of available options:
# name : Name of the Telegram Command
# --a|admin : Generate a AdminCommand
# --s|system : Generate a SystemCommand
# Without admin or system option default User command will be created

鸣谢

许可证

有关更多信息,请参阅许可证文件