定制 tobur/simple-skype-bot 二次开发

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

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

tobur/simple-skype-bot

Composer 安装命令:

composer require tobur/simple-skype-bot

包简介

README 文档

README

Install

composer require tobur/simple-skype-bot
SimpleSkypeBot\SimpleSkypeBotBundle::class => ['all' => true]
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="skype_token")
 */
class SkypeToken extends \SimpleSkypeBot\Model\SkypeToken
{
}
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="skype_user")
 */
class SkypeUser extends \SimpleSkypeBot\Model\SkypeUser
{
}

simple_skype_bot:
  token_class: 'App\Entity\SkypeToken'
  user_class: 'App\Entity\SkypeUser'
  client_id: 'some client id'
  client_secret: 'some secret'

You should create application and bot on https://dev.botframework.com/bots/new.

Put your endpoint to the main route.

skype_endpoint:
    resource: '@SimpleSkypeBotBundle/Resources/config/routing.yaml'
    prefix: /

For your bot you should setup api endpoint. For develop you can use http tunnel with https://ngrok.com/.

./ngrok http 80

Like example for dev you can use: https://somecode.ngrok.io/api/messages

Add you bot to skype. https://join.skype.com/bot/your-code-here

Example how to handle messages

<?php

namespace App\Subscriber;

use SimpleSkypeBot\DTO\MessageDTO;
use SimpleSkypeBot\Event\NewMessageEvent;
use SimpleSkypeBot\Exceptions\SimpleSkypeBotException;
use SimpleSkypeBot\Service\SkypeBotManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class SkypeSubscriber implements EventSubscriberInterface
{
    /**
     * @var SkypeBotManager
     */
    protected $botManager;

    /**
     * @param SkypeBotManager $botManager
     */
    public function __construct(SkypeBotManager $botManager) {
        $this->botManager = $botManager;
    }

    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return [
            NewMessageEvent::NAME => 'handleNewMessage'
        ];
    }

    /**
     * @param NewMessageEvent $event
     * @throws SImpleSkypeBotException
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     * @throws \SimpleSkypeBot\Service\SimpleSkypeBotException
     */
    public function handleNewMessage(NewMessageEvent $event)
    {
        /** @var MessageDTO $messageDTO */
        $messageDTO = $event->getData();
        $messageDTO->setText('Hello man!');
        $this->botManager->sendMessage($messageDTO);
    }
}

Some default skype command, put it to the skype with your bot:

.save my_skype_login

Than you can use:

php bin/console simply-skype-bot:send-message my_skype_login Hi

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固