leocata/m1-bot 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

leocata/m1-bot

Composer 安装命令:

composer require leocata/m1-bot

包简介

PHP API M1

README 文档

README

Build Status Scrutinizer Code Quality Maintainability

Install Gearman server

apt-get install gearman software-properties-common
add-apt-repository ppa:gearman-developers/ppa
add-apt-repository ppa:ondrej/pkg-gearman
apt-get update
apt-get install php-gearman

Install Application

composer require leocata/m1-bot

Usage

Create bot

ExampleBot.php

<?php

use leocata\m1Bot\Bot\BaseBot;

class ExampleBot extends BaseBot
{
    public $pass = 'password';
    public $username = 'username';

    public function contactRequested(\GearmanJob $job)
    {
        $message = json_decode($job->workload());
        $this->getApiWrapper()->contactAccept($message->userid, '', 1);
        $job->sendComplete(true);
    }

    public function message(\GearmanJob $job)
    {
        $this->getApiWrapper()->messageDelivered($message->sessionid, $message->id);
        $this->getApiWrapper()->messageTyped($message->sessionid, $message->orig);
        $job->sendComplete(true);
    }
}

Start Example Bot

Start WebSocket client

vendor/bin/mbot-cli websocket --bot ExampleBot

Start Gearman workers

vendor/bin/mbot-cli gearman --bot ExampleBot

Use supervisor

Add file /etc/supervisor/conf.d/websocket_client_exampleBot.conf

[program:websocket_client_exampleBot]
command                 = vendor/bin/mbot-cli websocket --bot ExampleBot
process_name            = websocket_client
numprocs                = 1
autostart               = true
autorestart             = true
user                    = mbot
stdout_logfile          = /var/logs/exampleBot-websocket-info.log
stdout_logfile_maxbytes = 1MB
stderr_logfile          = /var/logs/exampleBot-websocket-error.log

Add file /etc/supervisor/conf.d/gearman_worker_exampleBot.conf

[program:gearman_worker_exampleBot]
command                 = vendor/bin/mbot-cli gearman --bot ExampleBot
process_name            = websocket_client
numprocs                = 1
autostart               = true
autorestart             = true
user                    = mbot
stdout_logfile          = /var/logs/exampleBot-gearman-info.log
stdout_logfile_maxbytes = 1MB
stderr_logfile          = /var/logs/exampleBot-gearman-error.log

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-16