diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-22 09:23:32 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-22 09:23:32 +0300 |
commit | 8525833a2b577921949cf20b079f5639b8f6627e (patch) | |
tree | bf1fb6085be964235b0446c34d957f388978c371 | |
parent | 8612cfde1dc43b7bed026735eb056617211d16b1 (diff) |
Add Telegram CLI configuration dialogue
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r-- | lib/Command/Configure.php | 10 | ||||
-rw-r--r-- | lib/Service/Gateway/Telegram/GatewayConfig.php | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/Command/Configure.php b/lib/Command/Configure.php index db1005b..0d1d2b0 100644 --- a/lib/Command/Configure.php +++ b/lib/Command/Configure.php @@ -31,6 +31,7 @@ use OCA\TwoFactorGateway\Service\Gateway\SMS\GatewayConfig as SMSConfig; use OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\PlaySMSConfig; use OCA\TwoFactorGateway\Service\Gateway\SMS\Provider\WebSmsConfig; use OCA\TwoFactorGateway\Service\Gateway\Telegram\Gateway as TelegramGateway; +use OCA\TwoFactorGateway\Service\Gateway\Telegram\GatewayConfig as TelegramConfig; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -143,6 +144,15 @@ class Configure extends Command { } private function configureTelegram(InputInterface $input, OutputInterface $output) { + $helper = $this->getHelper('question'); + $tokenQuestion = new Question('Please enter your Telegram bot token: '); + $token = $helper->ask($input, $output, $tokenQuestion); + $output->writeln("Using $token."); + + /** @var TelegramConfig $config */ + $config = $this->telegramGateway->getConfig(); + + $config->setBotToken($token); } }
\ No newline at end of file diff --git a/lib/Service/Gateway/Telegram/GatewayConfig.php b/lib/Service/Gateway/Telegram/GatewayConfig.php index d75bbbe..222d406 100644 --- a/lib/Service/Gateway/Telegram/GatewayConfig.php +++ b/lib/Service/Gateway/Telegram/GatewayConfig.php @@ -51,6 +51,10 @@ class GatewayConfig implements IGatewayConfig { return $this->getOrFail('telegram_bot_token'); } + public function setBotToken(string $token) { + $this->config->setAppValue(Application::APP_NAME, 'telegram_bot_token', $token); + } + public function isComplete(): bool { $set = $this->config->getAppKeys(Application::APP_NAME); $expected = [ @@ -59,4 +63,5 @@ class GatewayConfig implements IGatewayConfig { return count(array_intersect($set, $expected)) === count($expected); } + }
\ No newline at end of file |