summaryrefslogtreecommitdiffstats
path: root/internal/formatter/telegram.go
blob: b1b7b7c5d957d5ed70e8c98717bb7cf7559dbb64 (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
46
47
48
49
50
package formatter

import (
	"fmt"
	"strings"
	"git.db.org.ai/dborg/internal/models"
	"git.db.org.ai/dborg/internal/utils"
)

func FormatTelegramResults(response *models.TelegramPhoneResponse, asJSON bool) error {
	if asJSON {
		return utils.PrintJSON(response)
	}

	PrintSection("📱 Telegram Phone Lookup")

	fmt.Printf("%s: %s\n", Cyan("Identifier"), response.Identifier)

	if response.TelegramID != "" {
		fmt.Printf("%s: %s\n", Cyan("Telegram ID"), response.TelegramID)
	}

	if response.PhoneNumber != "" {
		fmt.Printf("%s: %s\n", Cyan("Phone Number"), Green(response.PhoneNumber))
	} else {
		fmt.Printf("%s: %s\n", Cyan("Phone Number"), Red("Not found"))
	}

	if len(response.Contacts) > 0 {
		fmt.Printf("%s: %s\n", Cyan("Contacts"), strings.Join(response.Contacts, ", "))
	}

	if len(response.Groups) > 0 {
		fmt.Printf("%s:\n", Cyan("Groups"))
		for _, g := range response.Groups {
			fmt.Printf("  • %s\n", g)
		}
	}

	fmt.Println()
	PrintDivider()
	fmt.Printf("%s: ", Cyan("Credits Remaining"))
	if response.Credits.Unlimited {
		fmt.Printf("%s\n", Green("Unlimited"))
	} else {
		fmt.Printf("%s\n", FormatCredits(int64(response.Credits.Remaining)))
	}

	return nil
}