-
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
3 changed files
with
158 additions
and
21 deletions.
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?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\AdminCommands; | ||
use Hitmare\UnlockPTB\Unlock; | ||
use Longman\TelegramBot\Commands\Command; | ||
use Longman\TelegramBot\Commands\AdminCommand; | ||
use Longman\TelegramBot\Request; | ||
/** | ||
* User "/help" command | ||
*/ | ||
class getAuthkeyCommand extends AdminCommand | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $name = 'getAuthkey'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $description = 'Creates a Authkey to unlock the Bot'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $usage = '/getAuthkey <channel-id>'; | ||
/** | ||
* @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); | ||
|
||
|
||
|
||
|
||
$key = Unlock::getAuthkey($chat_id); | ||
$text = 'The Authkey for the Channel ' . $chat_id . ': ' . $key; | ||
|
||
|
||
$data = [ | ||
'chat_id' => $chat_id, | ||
'text' => $text, | ||
]; | ||
return Request::sendMessage($data); | ||
|
||
|
||
|
||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?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 lockCommand extends UserCommand | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $name = 'lock'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $description = 'Locks the Bot'; | ||
/** | ||
* @var string | ||
*/ | ||
protected $usage = '/lock'; | ||
/** | ||
* @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 (!$isUnlocked) { | ||
$text='The Bot is allready Locked here'; | ||
} | ||
else{ | ||
$unlock = Unlock::lockChannel($chat_id); | ||
if (is_bool($unlock)) { | ||
(!$unlock)?$text = 'Bot succsessfully locked':$text = 'Could not lock the Bot'; | ||
} | ||
elseif(is_string($unlock)) { | ||
$text = $unlock; | ||
} | ||
|
||
} | ||
$data = [ | ||
'chat_id' => $chat_id, | ||
'text' => $text, | ||
]; | ||
return Request::sendMessage($data); | ||
|
||
|
||
|
||
} | ||
} |
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