-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,74 @@ | ||
|
||
<?php | ||
/** | ||
* This file is part of the TelegramBot package. | ||
* | ||
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Longman\TelegramBot\Commands\UserCommands; | ||
use Hitmare\UnlockPTB\Unlock; | ||
use Longman\TelegramBot\Commands\Command; | ||
use Longman\TelegramBot\Commands\UserCommand; | ||
use Longman\TelegramBot\Request; | ||
/** | ||
* User "/help" command | ||
*/ | ||
class lockstatusCommand extends UserCommand | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $name = 'unlock'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $description = 'Unlocks the Bot with the given Auth-Key'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $usage = '/unlock <AuthKey>'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $version = '1.0.0'; | ||
/** | ||
* Command execute method | ||
* | ||
* @return \Longman\TelegramBot\Entities\ServerResponse | ||
* @throws \Longman\TelegramBot\Exception\TelegramException | ||
*/ | ||
public function execute() | ||
{ | ||
$message = $this->getMessage(); | ||
$chat_id = $message->getChat()->getId(); | ||
$key = trim($message->getText(true)); | ||
$isUnlocked = Unlock::isUnlocked($chat_id); | ||
if ($key == '') { | ||
$data = [ | ||
'chat_id' => $chat_id, | ||
'text' => 'Please enter the given Key after the command `/unlock <key>`', | ||
]; | ||
return Request::sendMessage($data); | ||
} | ||
|
||
if ($isUnlocked) { | ||
$text='The Bot is allready Unlocked here'; | ||
} | ||
else{ | ||
$unlock = Unlock::unlockChannel($chat_id, $key); | ||
($unlock)?$text = 'Bot succsessfully unlocked':$text = 'Could not unlock the Bot'; | ||
} | ||
|
||
|
||
$data = [ | ||
'chat_id' => $chat_id, | ||
'text' => $text, | ||
]; | ||
return Request::sendMessage($data); | ||
|
||
|
||
|
||
} | ||
} |