addons

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTweetID

func ExtractTweetID(tweetLink string, username string, logger utils.Logger) (string, error)

ExtractTweetID extracts the numeric tweet ID from a tweet URL or ID string.

Parameters:

  • tweetLink: can be a full tweet URL or just the ID
  • username: account username for logging purposes
  • logger: logger instance for error reporting

Returns:

  • string: the extracted tweet ID
  • error: any error that occurred during extraction

Example:

// Extract from URL
id, err := ExtractTweetID("https://twitter.com/user/status/1234567890", username, logger)

// Extract from ID string
id, err := ExtractTweetID("1234567890", username, logger)

func GetTwitterUsername

func GetTwitterUsername(httpClient tlsClient.HttpClient, cookieClient *utils.CookieClient, config *models.Config, logger utils.Logger, csrfToken string) (string, string, error, models.ActionStatus)

GetTwitterUsername retrieves the username of a Twitter account.

Parameters:

  • httpClient: the HTTP client to make requests with
  • cookieClient: manages cookies for the request
  • config: contains Twitter API configuration and constants
  • logger: handles logging of operations
  • csrfToken: CSRF token for request authentication

Returns:

  • string: the account's username (empty if error)
  • string: new CSRF token from response
  • error: any error that occurred, including account status errors
  • models.ActionStatus: the status of the account

func SetAuthCookies

func SetAuthCookies(accountIndex int, cookieClient *utils.CookieClient, twitterAuth string) (string, string, error)

SetAuthCookies sets authentication cookies for a Twitter client. Supports both JSON cookie format and simple auth token.

Parameters:

  • accountIndex: index of the account for logging purposes
  • cookieClient: client's cookie manager
  • twitterAuth: either JSON cookies or auth token string

Returns:

  • string: auth token
  • string: CSRF token
  • error: any error that occurred

Example:

// Using auth token
authToken, csrfToken, err := SetAuthCookies(0, cookieClient, "auth_token_here")

// Using JSON cookies
authToken, csrfToken, err := SetAuthCookies(0, cookieClient, "[{\"name\":\"auth_token\",\"value\":\"token\"}]")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL