Documentation ¶
Index ¶
- type ListRequest
- type SearchRequest
- type Service
- func (s *Service) List(request ListRequest) ([]models.Hashtag, error)
- func (s *Service) Search(request SearchRequest) ([]string, error)
- func (s *Service) Show(tag string) (models.Hashtag, error)
- func (s *Service) Trend() ([]Trend, error)
- func (s *Service) Users(request UsersRequest) ([]models.User, error)
- type ShowRequest
- type SortFlag
- type Trend
- type TrendRequest
- type UserState
- type UsersRequest
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.
type SearchRequest ¶
type SearchRequest struct { Limit uint `json:"limit"` Query string `json:"query"` Offset uint64 `json:"offset"` }
SearchRequest represents an Search request.
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 ¶
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 ¶
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.
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" )
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 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.