summaryrefslogtreecommitdiffstats
path: root/cmd/telegram.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/telegram.go')
-rw-r--r--cmd/telegram.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/cmd/telegram.go b/cmd/telegram.go
new file mode 100644
index 0000000..1c650b7
--- /dev/null
+++ b/cmd/telegram.go
@@ -0,0 +1,45 @@
+package cmd
+
+import (
+ "git.db.org.ai/dborg/internal/formatter"
+ "github.com/spf13/cobra"
+)
+
+var telegramCmd = &cobra.Command{
+ Use: "telegram",
+ Short: "Telegram lookup commands",
+ Long: `Lookup phone numbers associated with Telegram accounts`,
+}
+
+var phoneCmd = &cobra.Command{
+ Use: "phone [identifier]",
+ Short: "Get phone number for Telegram user",
+ Long: `Retrieves the phone number associated with a Telegram username (with @ prefix) or user ID`,
+ Args: cobra.ExactArgs(1),
+ RunE: runTelegramPhone,
+}
+
+func init() {
+ rootCmd.AddCommand(telegramCmd)
+ telegramCmd.AddCommand(phoneCmd)
+}
+
+func runTelegramPhone(cmd *cobra.Command, args []string) error {
+ identifier := args[0]
+
+ c, err := newClient()
+ if err != nil {
+ return err
+ }
+
+ response, err := c.GetTelegramPhone(identifier)
+ if err != nil {
+ return err
+ }
+
+ if err := checkError(response.Error); err != nil {
+ return err
+ }
+
+ return formatter.FormatTelegramResults(response, IsJSONOutput())
+}