Documentation
¶
Overview ¶
Package mastodon provides functions and structs for accessing the mastodon API.
Index ¶
- func AuthorizeFollowRequest(account *Account) error
- func Base64Encode(file *os.File) (string, error)
- func Base64EncodeFileName(filename string) (string, error)
- func ClearNotifications() error
- func GetInstancePeers() ([]string, error)
- func Initialize(config *Config)
- func RejectFollowRequest(account *Account) error
- func RemovePushSubscription() error
- func StreamingDirect() (chan Event, error)
- func StreamingHashtag(tag string, isLocal bool) (chan Event, error)
- func StreamingPublic(isLocal bool) (chan Event, error)
- func StreamingUser() (chan Event, error)
- func String(v string) *string
- type Account
- func FollowRemoteUser(uri string) (*Account, error)
- func GetAccount(id ID) (*Account, error)
- func GetBlockList(pg *Pagination) ([]*Account, error)
- func GetCurrentAccount() (*Account, error)
- func GetFollowRequests(pg *Pagination) ([]*Account, error)
- func GetMuteList(pg *Pagination) ([]*Account, error)
- func LookupAccount(username string) (*Account, error)
- func SearchAccounts(q string, limit int64) ([]*Account, error)
- func UpdateCurrentAccount(profile *Profile) (*Account, error)
- func (a *Account) GetContainingLists() ([]*List, error)
- func (a *Account) GetFollowers(pg *Pagination) ([]*Account, error)
- func (a *Account) GetFollowing(pg *Pagination) ([]*Account, error)
- func (a *Account) GetID() string
- func (a *Account) GetPinnedStatuses() ([]*Status, error)
- func (a *Account) GetStatuses(excludeBoosts bool, pg *Pagination) ([]*Status, error)
- func (a *Account) Report(statuses []*Status, comment string) (*Report, error)
- type AccountSource
- type AppConfig
- type Application
- type ApplicationVerification
- type Attachment
- type AttachmentMeta
- type AttachmentSize
- type Card
- type Client
- type Config
- type Context
- type Conversation
- type DeleteEvent
- type Emoji
- type ErrorEvent
- type Event
- type Field
- type Filter
- type History
- type ID
- type Instance
- type InstanceStats
- type List
- type Media
- type Mention
- type Notification
- type NotificationEvent
- type Pagination
- type Poll
- type PollOption
- type Profile
- type PushAlerts
- type PushSubscription
- type Relationship
- func Block(account *Account) (*Relationship, error)
- func Follow(account *Account) (*Relationship, error)
- func GetRelationships(accounts []*Account) ([]*Relationship, error)
- func Mute(account *Account) (*Relationship, error)
- func Unblock(account *Account) (*Relationship, error)
- func Unfollow(account *Account) (*Relationship, error)
- func Unmute(account *Account) (*Relationship, error)
- type Report
- type Results
- type Sbool
- type Status
- func GetBookmarks(pg *Pagination) ([]*Status, error)
- func GetDirectTimeline(pg *Pagination) ([]*Status, error)
- func GetFavourites(pg *Pagination) ([]*Status, error)
- func GetHomeTimeline(pg *Pagination) ([]*Status, error)
- func GetListTimeline(id ID, pg *Pagination) ([]*Status, error)
- func GetMediaTimeline(isLocal bool, pg *Pagination) ([]*Status, error)
- func GetPublicTimeline(isLocal bool, pg *Pagination) ([]*Status, error)
- func GetStatus(id ID) (*Status, error)
- func GetTaggedTimeline(tag string, isLocal bool, pg *Pagination) ([]*Status, error)
- func PostStatus(toot *Toot) (*Status, error)
- func (s *Status) Bookmark() (*Status, error)
- func (s *Status) Delete() error
- func (s *Status) DoReblog() (*Status, error)
- func (s *Status) Favourite() (*Status, error)
- func (s *Status) GetCard() (*Card, error)
- func (s *Status) GetContext() (*Context, error)
- func (s *Status) GetFavouritedBy(pg *Pagination) ([]*Account, error)
- func (s *Status) GetID() string
- func (s *Status) GetRebloggedBy(pg *Pagination) ([]*Account, error)
- func (s *Status) Unbookmark() (*Status, error)
- func (s *Status) Unfavourite() (*Status, error)
- func (s *Status) Unreblog() (*Status, error)
- type Tag
- type Toot
- type TootPoll
- type Unixtime
- type UpdateEvent
- type Visibility
- type WeeklyActivity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Encode ¶
Base64Encode returns the base64 data URI format string of the file.
func Base64EncodeFileName ¶
Base64EncodeFileName returns the base64 data URI format string of the file with the file name.
func StreamingDirect ¶
StreamingDirect returns a channel to read events on a direct messages.
func StreamingHashtag ¶
StreamingHashtag returns a channel to read events on tagged timeline.
func StreamingPublic ¶
StreamingPublic returns a channel to read events on public.
func StreamingUser ¶
StreamingUser returns a channel to read events on home.
Types ¶
type Account ¶
type Account struct { ID ID `json:"id"` Username string `json:"username"` Acct string `json:"acct"` DisplayName string `json:"display_name"` Locked bool `json:"locked"` CreatedAt time.Time `json:"created_at"` FollowersCount int64 `json:"followers_count"` FollowingCount int64 `json:"following_count"` StatusesCount int64 `json:"statuses_count"` Note string `json:"note"` URL string `json:"url"` Avatar string `json:"avatar"` AvatarStatic string `json:"avatar_static"` Header string `json:"header"` HeaderStatic string `json:"header_static"` Emojis []Emoji `json:"emojis"` Moved *Account `json:"moved"` Fields []Field `json:"fields"` Bot bool `json:"bot"` Discoverable bool `json:"discoverable"` Source *AccountSource `json:"source"` }
func FollowRemoteUser ¶
uri: username@domain of the person you want to follow
func GetBlockList ¶
func GetBlockList(pg *Pagination) ([]*Account, error)
func GetFollowRequests ¶
func GetFollowRequests(pg *Pagination) ([]*Account, error)
func GetMuteList ¶
func GetMuteList(pg *Pagination) ([]*Account, error)
func (*Account) GetFollowers ¶
func (a *Account) GetFollowers(pg *Pagination) ([]*Account, error)
func (*Account) GetFollowing ¶
func (a *Account) GetFollowing(pg *Pagination) ([]*Account, error)
type AccountSource ¶
type AppConfig ¶
type AppConfig struct { http.Client Server string ClientName string // Where the user should be redirected after authorization (for no redirect, use urn:ietf:wg:oauth:2.0:oob) RedirectURIs string // This can be a space-separated list of items listed on the /settings/applications/new page of any Mastodon // instance. "read", "write", and "follow" are top-level scopes that include all the permissions of the more // specific scopes like "read:favourites", "write:statuses", and "write:follows". Scopes string // Optional. Website string }
type Application ¶
type Application struct { ID ID `json:"id"` RedirectURI string `json:"redirect_uri"` ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` // AuthURI is not part of the Mastodon API; it is generated by go-mastodon. AuthURI string `json:"auth_uri,omitempty"` }
func RegisterApp ¶
func RegisterApp(appConfig *AppConfig) (*Application, error)
type ApplicationVerification ¶
type ApplicationVerification struct { Name string `json:"name"` Website string `json:"website"` VapidKey string `json:"vapid_key"` }
func GetAppCredentials ¶
func GetAppCredentials() (*ApplicationVerification, error)
type Attachment ¶
type Attachment struct { ID ID `json:"id"` Type string `json:"type"` URL string `json:"url"` RemoteURL string `json:"remote_url"` PreviewURL string `json:"preview_url"` TextURL string `json:"text_url"` Description string `json:"description"` Meta AttachmentMeta `json:"meta"` }
func UploadMedia ¶
func UploadMedia(file string) (*Attachment, error)
func UploadMediaFromBytes ¶
func UploadMediaFromBytes(b []byte) (*Attachment, error)
func UploadMediaFromMedia ¶
func UploadMediaFromMedia(media *Media) (*Attachment, error)
func UploadMediaFromReader ¶
func UploadMediaFromReader(reader io.Reader) (*Attachment, error)
type AttachmentMeta ¶
type AttachmentMeta struct { Original AttachmentSize `json:"original"` Small AttachmentSize `json:"small"` }
type AttachmentSize ¶
type Card ¶
type Card struct { URL string `json:"url"` Title string `json:"title"` Description string `json:"description"` Image string `json:"image"` Type string `json:"type"` AuthorName string `json:"author_name"` AuthorURL string `json:"author_url"` ProviderName string `json:"provider_name"` ProviderURL string `json:"provider_url"` HTML string `json:"html"` Width int64 `json:"width"` Height int64 `json:"height"` }
type Config ¶
type Context ¶
type Conversation ¶
type Conversation struct { ID ID `json:"id"` Accounts []*Account `json:"accounts"` Unread bool `json:"unread"` LastStatus *Status `json:"last_status"` }
func GetConversations ¶
func GetConversations(pg *Pagination) ([]*Conversation, error)
func (*Conversation) Delete ¶
func (c *Conversation) Delete() error
func (*Conversation) GetID ¶
func (c *Conversation) GetID() string
func (*Conversation) MarkAsRead ¶
func (c *Conversation) MarkAsRead() error
type Emoji ¶
type ErrorEvent ¶
type ErrorEvent struct {
// contains filtered or unexported fields
}
func (*ErrorEvent) Error ¶
func (e *ErrorEvent) Error() string
type Event ¶
type Event interface {
// contains filtered or unexported methods
}
type Field ¶
type Field struct { Name string `json:"name"` Value string `json:"value"` VerifiedAt time.Time `json:"verified_at"` }
Field is a Mastodon account profile field.
type Filter ¶
type History ¶
type Instance ¶
type Instance struct { URI string `json:"uri"` Title string `json:"title"` Description string `json:"description"` EMail string `json:"email"` Version string `json:"version,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` URLs map[string]string `json:"urls,omitempty"` Stats *InstanceStats `json:"stats,omitempty"` Languages []string `json:"languages"` ContactAccount *Account `json:"contact_account"` }
type InstanceStats ¶
type Media ¶
type Mention ¶
type Notification ¶
type Notification struct { ID ID `json:"id"` Type string `json:"type"` CreatedAt time.Time `json:"created_at"` Account Account `json:"account"` Status *Status `json:"status"` }
func GetNotification ¶
func GetNotification(id ID) (*Notification, error)
func GetNotifications ¶
func GetNotifications(pg *Pagination) ([]*Notification, error)
func (*Notification) Dismiss ¶
func (n *Notification) Dismiss() error
func (*Notification) GetID ¶
func (n *Notification) GetID() string
type NotificationEvent ¶
type NotificationEvent struct {
Notification *Notification `json:"notification"`
}
type Pagination ¶
Pagination is a struct for specifying the get range.
type Poll ¶
type Poll struct { ID ID `json:"id"` ExpiresAt time.Time `json:"expires_at"` Expired bool `json:"expired"` Multiple bool `json:"multiple"` VotesCount int64 `json:"votes_count"` VotersCount int64 `json:"voters_count"` Options []PollOption `json:"options"` Voted bool `json:"voted"` OwnVotes []int `json:"own_votes"` Emojis []Emoji `json:"emojis"` }
type PollOption ¶
type Profile ¶
type PushAlerts ¶
type PushSubscription ¶
type PushSubscription struct { ID ID `json:"id"` Endpoint string `json:"endpoint"` ServerKey string `json:"server_key"` Alerts *PushAlerts `json:"alerts"` }
func AddPushSubscription ¶
func AddPushSubscription(endpoint string, public ecdsa.PublicKey, shared []byte, alerts PushAlerts) (*PushSubscription, error)
func GetPushSubscription ¶
func GetPushSubscription() (*PushSubscription, error)
func UpdatePushSubscription ¶
func UpdatePushSubscription(alerts *PushAlerts) (*PushSubscription, error)
UpdatePushSubscription updates which type of notifications are sent for the active push subscription.
type Relationship ¶
type Relationship struct { ID ID `json:"id"` Following bool `json:"following"` FollowedBy bool `json:"followed_by"` Blocking bool `json:"blocking"` Muting bool `json:"muting"` MutingNotifications bool `json:"muting_notifications"` Requested bool `json:"requested"` DomainBlocking bool `json:"domain_blocking"` ShowingReblogs bool `json:"showing_reblogs"` Endorsed bool `json:"endorsed"` }
func Block ¶
func Block(account *Account) (*Relationship, error)
func Follow ¶
func Follow(account *Account) (*Relationship, error)
func GetRelationships ¶
func GetRelationships(accounts []*Account) ([]*Relationship, error)
func Mute ¶
func Mute(account *Account) (*Relationship, error)
func Unblock ¶
func Unblock(account *Account) (*Relationship, error)
func Unfollow ¶
func Unfollow(account *Account) (*Relationship, error)
func Unmute ¶
func Unmute(account *Account) (*Relationship, error)
type Report ¶
type Results ¶
type Status ¶
type Status struct { ID ID `json:"id"` URI string `json:"uri"` URL string `json:"url"` Account Account `json:"account"` InReplyToID interface{} `json:"in_reply_to_id"` InReplyToAccountID interface{} `json:"in_reply_to_account_id"` Reblog *Status `json:"reblog"` Content string `json:"content"` CreatedAt time.Time `json:"created_at"` Emojis []Emoji `json:"emojis"` RepliesCount int64 `json:"replies_count"` ReblogsCount int64 `json:"reblogs_count"` FavouritesCount int64 `json:"favourites_count"` Reblogged interface{} `json:"reblogged"` Favourited interface{} `json:"favourited"` Bookmarked interface{} `json:"bookmarked"` Muted interface{} `json:"muted"` Sensitive bool `json:"sensitive"` SpoilerText string `json:"spoiler_text"` Visibility string `json:"visibility"` MediaAttachments []Attachment `json:"media_attachments"` Mentions []Mention `json:"mentions"` Tags []Tag `json:"tags"` Card *Card `json:"card"` Poll *Poll `json:"poll"` Application Application `json:"application"` Language string `json:"language"` Pinned interface{} `json:"pinned"` }
func GetBookmarks ¶
func GetBookmarks(pg *Pagination) ([]*Status, error)
func GetDirectTimeline ¶
func GetDirectTimeline(pg *Pagination) ([]*Status, error)
func GetFavourites ¶
func GetFavourites(pg *Pagination) ([]*Status, error)
func GetHomeTimeline ¶
func GetHomeTimeline(pg *Pagination) ([]*Status, error)
func GetListTimeline ¶
func GetListTimeline(id ID, pg *Pagination) ([]*Status, error)
func GetMediaTimeline ¶
func GetMediaTimeline(isLocal bool, pg *Pagination) ([]*Status, error)
GetTimelineMedia return statuses from media timeline. NOTE: This is an experimental feature of pawoo.net.
func GetPublicTimeline ¶
func GetPublicTimeline(isLocal bool, pg *Pagination) ([]*Status, error)
func GetTaggedTimeline ¶
func GetTaggedTimeline(tag string, isLocal bool, pg *Pagination) ([]*Status, error)
func (*Status) GetFavouritedBy ¶
func (s *Status) GetFavouritedBy(pg *Pagination) ([]*Account, error)
func (*Status) GetRebloggedBy ¶
func (s *Status) GetRebloggedBy(pg *Pagination) ([]*Account, error)
type Tag ¶
type Toot ¶
type Toot struct { Status string `json:"status"` InReplyToID ID `json:"in_reply_to_id"` MediaIDs []ID `json:"media_ids"` Sensitive bool `json:"sensitive"` SpoilerText string `json:"spoiler_text"` Visibility string `json:"visibility"` Language string `json:"language"` ScheduledAt *time.Time `json:"scheduled_at,omitempty"` Poll *TootPoll `json:"poll"` }
type TootPoll ¶
type Unixtime ¶
type Visibility ¶
type Visibility string
const ( Public Visibility = "public" Unlisted Visibility = "unlisted" FollowersOnly Visibility = "private" DirectMessage Visibility = "direct" )