承接 pulpa/laravel-telegram-bot 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

pulpa/laravel-telegram-bot

Composer 安装命令:

composer require pulpa/laravel-telegram-bot

包简介

Framework to build Telegram bots

README 文档

README

This is a work in progress, feel free to watch this repo to stay tuned.

Requirements

  • Laravel 5.4+

Installation

Install the package with composer:

composer require pulpa/laravel-telegram-bot

Add this service provider to your config/app.php file:

Pulpa\Telegram\Bot\Providers\ServiceProvider::class

Create a configuration file in config/bot.php and a controller in app\Http\Controllers\BotController.php by running the vendor:publish artisan command:

php artisan vendor:publish --provider="Pulpa\Telegram\Bot\Providers\ServiceProvider"

Open config/bot.php and set up your bot's name and token.

Once you finish your configuration, your bot's webhook URL will be available at:

yourdomain.com/<BotToken>

Where <BotToken> is obviously the bot token, duh! Open the URL in your web browser and you should see a friendly message.

Usage

The method catchAll() within your BotController class will receive all the updates coming from Telegram to your webhook, it will receive a parameter of type Pulpa\Telegram\Bot\Update that is just a simple wrapper of the original update object coming from Telegram.

use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // Log the text message
        \Log::info($update->message->text);
    }
}

Define methods in your BotController that will handle the incoming bot commands, for example, method myBotCommand will be called when the webhook recieves a command named my_bot_command.

use App\Chat;
use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // ...
    }

    public function start(Update $update)
    {
        // Register a new chat when command "start" is received.
        Chat::register($update->message->chat->id);
    }
}

If no method is defined for a command then the method catchAll() will be called instead.

More documentation is in progress

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固