summaryrefslogtreecommitdiffstats
path: root/cmd/x.go
diff options
context:
space:
mode:
authors <[email protected]>2025-11-06 22:15:13 -0500
committers <[email protected]>2025-11-06 22:15:13 -0500
commiteab6a1b6899413154f855abbd200ac775b22be75 (patch)
treed2671b1609ff38f3f5c60944017ac063088aa162 /cmd/x.go
parent27add8c96a7df242618e1ebcb8c7271661e21688 (diff)
downloaddborg-eab6a1b6899413154f855abbd200ac775b22be75.tar.gz
dborg-eab6a1b6899413154f855abbd200ac775b22be75.zip
refactor: split x command into history and tweets subcommands with streaming support
Diffstat (limited to 'cmd/x.go')
-rw-r--r--cmd/x.go42
1 files changed, 39 insertions, 3 deletions
diff --git a/cmd/x.go b/cmd/x.go
index eeac07f..b933e3d 100644
--- a/cmd/x.go
+++ b/cmd/x.go
@@ -10,18 +10,34 @@ import (
)
var xCmd = &cobra.Command{
- Use: "x [username]",
+ Use: "x",
+ Short: "Twitter/X tools and searches",
+ Long: `Tools for searching Twitter/X username history and scraping tweets`,
+}
+
+var xHistoryCmd = &cobra.Command{
+ Use: "history [username]",
Short: "Search Twitter/X username history",
Long: `Search for Twitter/X username history and previous usernames`,
Args: cobra.ExactArgs(1),
- RunE: runXSearch,
+ RunE: runXHistorySearch,
+}
+
+var xTweetsCmd = &cobra.Command{
+ Use: "tweets [username]",
+ Short: "Scrape tweets by username (Free OSINT)",
+ Long: `Discovers tweet IDs from Internet Archive and fetches tweet content. Free and unauthenticated endpoint.`,
+ Args: cobra.ExactArgs(1),
+ RunE: runXTweetsSearch,
}
func init() {
rootCmd.AddCommand(xCmd)
+ xCmd.AddCommand(xHistoryCmd)
+ xCmd.AddCommand(xTweetsCmd)
}
-func runXSearch(cmd *cobra.Command, args []string) error {
+func runXHistorySearch(cmd *cobra.Command, args []string) error {
apiKey, _ := cmd.Flags().GetString("api-key")
cfg := config.New().WithAPIKey(apiKey)
@@ -59,3 +75,23 @@ func runXSearch(cmd *cobra.Command, args []string) error {
return nil
}
+
+func runXTweetsSearch(cmd *cobra.Command, args []string) error {
+ cfg := config.New()
+
+ c, err := client.New(cfg)
+ if err != nil {
+ return err
+ }
+
+ err = c.FetchTweetsStream(args[0], func(result json.RawMessage) error {
+ fmt.Println(string(result))
+ return nil
+ })
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}