hashtags

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListRequest

type ListRequest struct {
	Limit                    uint   `json:"limit"`
	AttachedToUserOnly       bool   `json:"attachedToUserOnly"`
	AttachedToLocalUserOnly  bool   `json:"attachedToLocalUserOnly"`
	AttachedToRemoteUserOnly bool   `json:"attachedToRemoteUserOnly"`
	Sort                     string `json:"sort"`
}

ListRequest represents an List request.

func (ListRequest) Validate

func (r ListRequest) Validate() error

Validate the request.

type SearchRequest

type SearchRequest struct {
	Limit  uint   `json:"limit"`
	Query  string `json:"query"`
	Offset uint64 `json:"offset"`
}

SearchRequest represents an Search request.

func (SearchRequest) Validate

func (r SearchRequest) Validate() error

Validate options.

type Service

type Service struct {
	Call core.RequestHandlerFunc
}

Service is the base for all the endpoints on this service.

func NewService

func NewService(requestHandler core.RequestHandlerFunc) *Service

NewService creates a new Service instance.

func (*Service) List

func (s *Service) List(request ListRequest) ([]models.Hashtag, error)

List endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
client.LogLevel(logrus.DebugLevel)

tags, err := client.Hashtags().List(hashtags.ListRequest{
	Limit: 10,
	Sort:  hashtags.SortTagsByAttachedUsers.Ascending(),
})
if err != nil {
	log.Printf("[Hashtags] Error happened: %s", err)

	return
}

for _, tag := range tags {
	log.Printf(" - %s", tag.Tag)
}
Output:

func (*Service) Search

func (s *Service) Search(request SearchRequest) ([]string, error)

Search endpoint.

The Query parameter is an SQL LIKE query. For example, you are looking for all the hashtags that starts with 'hack', the Query should be 'hack%'.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
client.LogLevel(logrus.DebugLevel)

tags, err := client.Hashtags().Search(hashtags.SearchRequest{
	Limit: 10,
	Query: "hack%",
})
if err != nil {
	log.Printf("[Hashtags] Error happened: %s", err)

	return
}

for _, tag := range tags {
	log.Printf(" - %s", tag)
}
Output:

func (*Service) Show

func (s *Service) Show(tag string) (models.Hashtag, error)

Show endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
client.LogLevel(logrus.DebugLevel)

tag, err := client.Hashtags().Show("hacktoberfest")
if err != nil {
	log.Printf("[Hashtags] Error happened: %s", err)

	return
}

log.Println(tag)
Output:

func (*Service) Trend

func (s *Service) Trend() ([]Trend, error)

Trend endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
client.LogLevel(logrus.DebugLevel)

trend, err := client.Hashtags().Trend()
if err != nil {
	log.Printf("[Hashtags] Error happened: %s", err)

	return
}

for _, tag := range trend {
	log.Println(tag.Tag)
}
Output:

func (*Service) Users

func (s *Service) Users(request UsersRequest) ([]models.User, error)

Users endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
client.LogLevel(logrus.DebugLevel)

users, err := client.Hashtags().Users(hashtags.UsersRequest{
	Tag:    "vim",
	Limit:  20,
	State:  hashtags.DefaultState,
	Origin: models.OriginCombined,
	Sort:   hashtags.SortUsersByFollowers.Descending(),
})
if err != nil {
	log.Printf("[Hashtags] Error happened: %s", err)

	return
}

for _, user := range users {
	log.Println(user.Name)
}
Output:

type ShowRequest

type ShowRequest struct {
	Tag string `json:"tag"`
}

ShowRequest represents an Show request.

func (ShowRequest) Validate

func (r ShowRequest) Validate() error

Validate the request.

type SortFlag

type SortFlag string

SortFlag is used for sorting on the List and Users endpoint. Here, there are two functions on it, Ascending and Descending. They specify how the tags or users should be sorted.

In the background, the endpoint expects a string with a + or - sign.

const (
	// SortTagsByMentionedUsers sorts hashtags by user mentions.
	SortTagsByMentionedUsers SortFlag = "mentionedUsers"
	// SortTagsByMentionedLocalUsers sorts hashtags by local only user mentions.
	SortTagsByMentionedLocalUsers SortFlag = "mentionedLocalUsers"
	// SortTagsByMentionedRemoteUsers sorts hashtags by remote only user mentions.
	SortTagsByMentionedRemoteUsers SortFlag = "mentionedRemoteUsers"
	// SortTagsByAttachedUsers sorts hashtags by user attachment.
	SortTagsByAttachedUsers SortFlag = "attachedUsers"
	// SortTagsByAttachedLocalUsers sorts hashtags by local only user attachment.
	SortTagsByAttachedLocalUsers SortFlag = "attachedLocalUsers"
	// SortTagsByAttachedRemoteUsers sorts hashtags by remote only user attachment.
	SortTagsByAttachedRemoteUsers SortFlag = "attachedRemoteUsers"

	// SortUsersByFollowers sorts users by the number of their followers.
	SortUsersByFollowers SortFlag = "follower"
	// SortUsersByCreatedAt sorts users based on creation time.
	SortUsersByCreatedAt SortFlag = "createdAt"
	// SortUsersByUpdatedAt sorts users based on last update time.
	SortUsersByUpdatedAt SortFlag = "updatedAt"
)

func (SortFlag) Ascending

func (s SortFlag) Ascending() string

Ascending order.

func (SortFlag) Descending

func (s SortFlag) Descending() string

Descending order.

type Trend

type Trend struct {
	Tag        string   `json:"tag"`
	Chart      []uint64 `json:"chart"`
	UsersCount uint64   `json:"usersCount"`
}

Trend represents one item in the response of the Trend response.

type TrendRequest

type TrendRequest struct{}

TrendRequest represents an Trend request.

func (TrendRequest) Validate

func (r TrendRequest) Validate() error

Validate the request.

type UserState

type UserState string

UserState of user.

const (
	// StateAll for all users.
	StateAll UserState = "all"
	// StateAlive for only alive users.
	StateAlive UserState = "alive"

	// DefaultState is the default state.
	DefaultState UserState = StateAll
	// DefaultOrigin is the default origin.
	DefaultOrigin models.UserOrigin = models.OriginLocal
)

type UsersRequest

type UsersRequest struct {
	Tag    string            `json:"tag"`
	Limit  uint              `json:"limit"`
	Sort   string            `json:"sort"`
	State  UserState         `json:"state"`
	Origin models.UserOrigin `json:"origin"`
}

UsersRequest represents an Users request.

func (UsersRequest) Validate

func (r UsersRequest) Validate() error

Validate options.

Jump to

Keyboard shortcuts

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