Install, (*1)
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., (*2)
Put your endpoint to the main route., (*3)
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/., (*4)
./ngrok http 80
Like example for dev you can use: https://somecode.ngrok.io/api/messages, (*5)
Add you bot to skype. https://join.skype.com/bot/your-code-here, (*6)
Example how to handle messages, (*7)
<?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:, (*8)
.save my_skype_login
Than you can use:, (*9)
php bin/console simply-skype-bot:send-message my_skype_login Hi