SecretService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Services;
  3. use Telegram\Bot\Api;
  4. use Telegram\Bot\Exceptions\TelegramSDKException;
  5. class SecretService
  6. {
  7. /**
  8. * @param Api $telegram
  9. * @param $data
  10. * @param $chatId
  11. * @param $firstName
  12. * @param $messageId
  13. * @throws TelegramSDKException
  14. */
  15. public static function init(Api $telegram, $data, $chatId, $firstName, $messageId): void
  16. {
  17. if ($data === "secret@@index") {
  18. $res = SecretService::index($chatId, $messageId);
  19. $telegram->editMessageText($res);
  20. }
  21. }
  22. private static function index($chatId, $messageId): array
  23. {
  24. $keyboard = [
  25. [
  26. ['text' => '查看秘钥', 'callback_data' => 'secret@@view'],
  27. ['text' => '找回账号', 'callback_data' => 'secret@@retrieve'],
  28. ],
  29. [
  30. ['text' => '返回', 'callback_data' => 'topUp@@home'],
  31. ]
  32. ];
  33. $text = "秘钥管理\n";
  34. $text .= "请选择业务类型";
  35. return [
  36. 'chat_id' => $chatId,
  37. 'text' => $text,
  38. 'message_id' => $messageId,
  39. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  40. ];
  41. }
  42. }