Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

New console command and update readme #77

Merged
merged 2 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
- Выполните `composer install`
- Сконфигурируйте бота
- Параметр `GITTER_TOKEN` в файле `.env` (если такого нету,
создайте из `.env.example`)
создайте из `.env.example`). Токен можно узнать по этой [ссылке](https://developer.gitter.im/apps).
- Прочие параметры находятся в файле `config/gitter.php`
- Выполните миграции `php artisan migrate`
- Введите `php artisan gitter:listen $room`, где
$room - идентификатор комнаты или его алиас.
- Введите `php artisan gitter:listen $roomId`, где `$roomId` - идентификатор комнаты или его алиас.
Самый простой вариант получения `$roomId` выполнить artisan команду `php artisan gitter:get-room-id room/Name`,
либо выполнить get запрос `https://api.gitter.im/v1/rooms?access_token=GITTER_TOKEN`


### Многопроцессовый режим

Expand Down
49 changes: 49 additions & 0 deletions app/Interfaces/Console/Commands/GetGitterRoomId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* This file is part of GitterBot package.
*
* @author butschster <butschster@gmail.com>
* @date 20.07.2016 14:44
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Interfaces\Console\Commands;

use Gitter\Client;
use Illuminate\Console\Command;

/**
* Class StartGitterBot
*/
class GetGitterRoomId extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'gitter:get-room-id {room}';


/**
* The console command description.
*
* @var string
*/
protected $description = 'Get gitter room id by name.';

public function handle()
{
$client = new Client(\Config::get('gitter.token'));

try {
$result = $client->http->getRoomByUri($this->argument('room'))->wait();
$this->info("Room ID: {$result->id}");
} catch (\Exception $e) {
$this->info('Room not found');
}
}
}
2 changes: 1 addition & 1 deletion app/Interfaces/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace Interfaces\Console;

use Carbon\Carbon;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

Expand All @@ -18,6 +17,7 @@ class Kernel extends ConsoleKernel
protected $commands = [
\Interfaces\Console\Commands\StartGitterPool::class,
\Interfaces\Console\Commands\StartGitterBot::class,
\Interfaces\Console\Commands\GetGitterRoomId::class
];

/**
Expand Down