services

package
v0.0.0-...-58c2bd7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultServices = Services{
	{
		Name: "Instagram",
		UserExistsFunc: func(data UserServiceDataToCheck) (bool, error) {
			return data.PatternUrlMatchUserExists("user?username={{.Username}}")
		},
		InfoFunc:            InstagramInfo,
		Domain:              "www.instagram.com",
		UserHtmlUrlTemplate: "{{.Domain}}/{{.Username}}/",
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "greg2q1412fdwkdfns",
		},
	},
	{
		Name:                "GitHub",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            GitHubInfo,
		Domain:              "github.com",
		UserHtmlUrlTemplate: "{{.Domain}}/{{.Username}}",
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "greg2q1412fdwkdfns",
		},
	},

	{
		Name:                "YouTube",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            YouTubeInfo,
		Domain:              "youtube.com",
		UserHtmlUrlTemplate: "{{.Domain}}/@{{.Username}}",
		UrlTemplates: map[string]string{
			"bio": "{{.Domain}}/@{{.Username}}/about",
		},
		TestData: TestData{
			ExistingUser:    "mrbeast",
			NotExistingUser: "gregdoesnotexsist",
		},
	},
	{
		Name:                "TikTok",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            TikTokInfo,
		Domain:              "tiktok.com",
		UserHtmlUrlTemplate: "{{.Domain}}/@{{.Username}}",
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "gregdoesnotexsist",
		},
	},

	{
		Name:                "Npm",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            EmptyInfo,
		Domain:              "npmjs.com",
		UserHtmlUrlTemplate: "{{.Domain}}/~{{.Username}}",
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "gregdoesnotexsist",
		},
	},
	{
		Name:                "chess.com",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            ChessComInfo,
		Domain:              "api.chess.com",
		UserHtmlUrlTemplate: "{{.Domain}}/pub/player/{{.Username}}",
		BlocksTor:           true,
		TestData: TestData{
			ExistingUser:    "danielnaroditsky",
			NotExistingUser: "gregdoesnotexsist",
		},
	},
	{
		Name:                "Asciinema",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            AsciinemaInfo,
		Domain:              "asciinema.org",
		UserHtmlUrlTemplate: "{{.Domain}}/~{{.Username}}",
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "gregdoesnotexsist",
		},
	},

	{
		Name:                "Lichess",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		Domain:              "lichess.org",
		UserHtmlUrlTemplate: "{{.Domain}}/api/user/{{.Username}}",
		BlocksTor:           true,
		TestData: TestData{
			ExistingUser:    "starwars",
			NotExistingUser: "gregdoesnotexsist",
		},
	},

	{
		Name:                "Snapchat",
		UserExistsFunc:      StatusCodeUserExistsFunc,
		InfoFunc:            SnapchatInfo,
		Domain:              "snapchat.com",
		UserHtmlUrlTemplate: "{{.Domain}}/add/{{.Username}}",
		BlocksTor:           true,
		TestData: TestData{
			ExistingUser:    "greg",
			NotExistingUser: "gregdoesnotexsistdsada",
		},
	},
}

Functions

func RemoveExtension

func RemoveExtension(input, extension string) string

func ScrapeBioTwitterTag

func ScrapeBioTwitterTag(response http.Response) (string, error)

func ScrapeImageTwitterTag

func ScrapeImageTwitterTag(response http.Response) (string, error)

func ServicesCheckWorker

func ServicesCheckWorker(s <-chan UserServiceDataToCheck, res chan<- ServiceCheckResult, wg *sync.WaitGroup)

func SetProtocolURL

func SetProtocolURL(rawURL, protocol string) (string, error)

func StatusCodeUserExistsFunc

func StatusCodeUserExistsFunc(data UserServiceDataToCheck) (bool, error)

Types

type AccountInfo

type AccountInfo struct {
	Url            string                 `json:"url"`
	ProfilePicture history.History[Image] `json:"profile_picture" ts_type:"{ latest: { data: string } } "`
	Bio            history.History[Bio]   `json:"bio" ts_type:"{ latest: { data: {bio: string} } }"`
}

func AsciinemaInfo

func AsciinemaInfo(data UserServiceDataToCheck) (AccountInfo, error)

func ChessComInfo

func ChessComInfo(data UserServiceDataToCheck) (AccountInfo, error)

func EmptyInfo

func EmptyInfo(data UserServiceDataToCheck) (AccountInfo, error)

func GitHubInfo

func GitHubInfo(data UserServiceDataToCheck) (AccountInfo, error)

func InstagramInfo

func InstagramInfo(data UserServiceDataToCheck) (AccountInfo, error)

func SnapchatInfo

func SnapchatInfo(data UserServiceDataToCheck) (AccountInfo, error)

func TikTokInfo

func TikTokInfo(data UserServiceDataToCheck) (AccountInfo, error)

func YouTubeInfo

func YouTubeInfo(data UserServiceDataToCheck) (AccountInfo, error)

func (*AccountInfo) GetProfilePicture

func (info *AccountInfo) GetProfilePicture(url string) error

type Accounts

type Accounts struct {
	Existing MapServiceCheckResult `json:"existing"`
	Failed   MapServiceCheckResult `json:"failed"`
}

type Bio

type Bio struct {
	Bio      string             `json:"bio"`
	Language map[string]float64 `json:"language"`
}

func NewBio

func NewBio(bio string) Bio

type DataToCheck

type DataToCheck []UserServiceDataToCheck

func (DataToCheck) Scan

func (services DataToCheck) Scan(workers int) ServiceCheckResults

type Errors

type Errors struct {
	Exists error `json:"exists"`
	Info   error `json:"info"`
}

type Image

type Image struct {
	Img  image.Image
	Url  string
	Date time.Time
}

func GetImage

func GetImage(url string) (Image, error)

func (*Image) MarshalJSON

func (img *Image) MarshalJSON() ([]byte, error)

func (*Image) UnmarshalJSON

func (img *Image) UnmarshalJSON(data []byte) error

type InfoFunc

type InfoFunc func(UserServiceDataToCheck) (AccountInfo, error)

type InputData

type InputData struct {
	User    User    `json:"user"`
	Service Service `json:"service"`
}

type MapServiceCheckResult

type MapServiceCheckResult map[string]ServiceCheckResult

func (MapServiceCheckResult) Scan

func (results MapServiceCheckResult) Scan(defaultServices Services, workers int) MapServiceCheckResult

basically scanning for the services

type Player

type Player struct {
	Avatar     string `json:"avatar"`
	PlayerID   int    `json:"player_id"`
	ID         string `json:"@id"`
	Url        string `json:"url"`
	Name       string `json:"name"`
	Username   string `json:"username"`
	Followers  int    `json:"followers"`
	Country    string `json:"country"`
	Location   string `json:"location"`
	LastOnline int64  `json:"last_online"`
	Joined     int64  `json:"joined"`
	Status     string `json:"status"`
	IsStreamer bool   `json:"is_streamer"`
	Verified   bool   `json:"verified"`
}

type Service

type Service struct {
	Name                string            `json:"name"`
	UserExistsFunc      UserExistsFunc    `json:"-"`
	InfoFunc            InfoFunc          `json:"-"`
	UserHtmlUrlTemplate string            `json:"-"`
	UrlTemplates        map[string]string `json:"-"`
	Domain              string            `json:"domain"`
	Protocol            string            `json:"-"`
	TestData            TestData          `json:"-"`
	BlocksTor           bool              `json:"-"`
}

func (*Service) Parse

func (service *Service) Parse()

func (Service) TestUserServiceData

func (service Service) TestUserServiceData() UserServiceDataToCheck

func (Service) TestUserServiceData2

func (service Service) TestUserServiceData2() UserServiceDataToCheck

type ServiceCheckResult

type ServiceCheckResult struct {
	InputData InputData   `json:"input_data"`
	Exists    bool        `json:"exists"`
	Info      AccountInfo `json:"info"`
	Errors    Errors      `json:"errors"`
}

func (*ServiceCheckResult) GetInfo

func (result *ServiceCheckResult) GetInfo(data UserServiceDataToCheck)

func (ServiceCheckResult) GetMapName

func (result ServiceCheckResult) GetMapName() string

func (*ServiceCheckResult) Merge

func (s1 *ServiceCheckResult) Merge(s2 ServiceCheckResult)

func (ServiceCheckResult) String

func (result ServiceCheckResult) String() string

type ServiceCheckResults

type ServiceCheckResults []ServiceCheckResult

func (ServiceCheckResults) GetExisting

func (results ServiceCheckResults) GetExisting() Services

func (ServiceCheckResults) GetExistingAndFailed

func (results ServiceCheckResults) GetExistingAndFailed() Services

func (ServiceCheckResults) GetFailed

func (results ServiceCheckResults) GetFailed() Services

func (ServiceCheckResults) String

func (results ServiceCheckResults) String() string

func (ServiceCheckResults) ToMap

func (ServiceCheckResults) ToMapExisting

func (results ServiceCheckResults) ToMapExisting() MapServiceCheckResult

type Services

type Services []Service

func (Services) GetServiceByName

func (services Services) GetServiceByName(name string) (Service, error)

func (Services) List

func (services Services) List() []string

type Template

type Template struct {
	User
	Service
}

type TestData

type TestData struct {
	ExistingUser    string
	NotExistingUser string
}

type User

type User struct {
	Username string
}

func (User) GetServices

func (user User) GetServices() DataToCheck

func (User) GetServices2

func (user User) GetServices2(defaultServices Services) DataToCheck

func (User) Scan

func (user User) Scan(workers int) ServiceCheckResults

func (User) String

func (user User) String() string

type UserExistsFunc

type UserExistsFunc func(UserServiceDataToCheck) (bool, error)

type UserServiceDataToCheck

type UserServiceDataToCheck struct {
	User    User    `json:"user"`
	Service Service `json:"service"`
}

func (UserServiceDataToCheck) GetImage

func (data UserServiceDataToCheck) GetImage() (Image, error)

func (UserServiceDataToCheck) GetImagelUrl

func (data UserServiceDataToCheck) GetImagelUrl() (string, error)

func (UserServiceDataToCheck) GetTemplate

func (data UserServiceDataToCheck) GetTemplate(templateString string) (string, error)

func (UserServiceDataToCheck) GetUserHtmlUrl

func (data UserServiceDataToCheck) GetUserHtmlUrl() (string, error)

func (UserServiceDataToCheck) PatternUrlMatchUserExists

func (data UserServiceDataToCheck) PatternUrlMatchUserExists(patternTemplate string) (bool, error)

func (UserServiceDataToCheck) StatusCodeUserExistsFunc

func (data UserServiceDataToCheck) StatusCodeUserExistsFunc() (bool, error)

func (UserServiceDataToCheck) UserExistsFunction

func (data UserServiceDataToCheck) UserExistsFunction() ServiceCheckResult

Jump to

Keyboard shortcuts

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