blob: 1c650b7da2ba2e1569dc7ba400dd6338b66c79cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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())
}
|