goplurk

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 13 Imported by: 0

README

goplurk

A golang wrapper of Plurk API 2.0

Getting started

With Go module support, simply add the following import

import "github.com/kinabcd/goplurk"

Basic usage

package main

import (
	"github.com/kinabcd/goplurk"
)

var consumerToken = "..."
var consumerSecret = "..."
var accessToken = "..."
var accessSecret = "..."

func main() {
	client, _ := goplurk.NewClient(consumerToken, consumerSecret, accessToken, accessSecret)
	client.Timeline.PlurkAdd("says", "somecontent")
}

Advenced usage

see example/ for more usages

Author

Kin Lo :: kinabcd@gmail.com :: @kinabcd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIAlerts added in v0.2.0

type APIAlerts struct {
	// contains filtered or unexported fields
}

func (*APIAlerts) AddAllAsFan added in v0.2.0

func (a *APIAlerts) AddAllAsFan() error

func (*APIAlerts) AddAsFan added in v0.2.0

func (a *APIAlerts) AddAsFan(userId int64) error

func (*APIAlerts) AddAsFriend added in v0.2.0

func (a *APIAlerts) AddAsFriend(userId int64) error

func (*APIAlerts) DenyAsFriend added in v0.2.0

func (a *APIAlerts) DenyAsFriend(userId int64) error

func (*APIAlerts) GetActive added in v0.2.0

func (a *APIAlerts) GetActive() ([]any, error)

func (*APIAlerts) GetHistory added in v0.2.0

func (a *APIAlerts) GetHistory() ([]any, error)

func (*APIAlerts) RemoveNotification added in v0.2.0

func (a *APIAlerts) RemoveNotification(userId int64) error

type APIPolling added in v0.1.3

type APIPolling struct {
	// contains filtered or unexported fields
}

func (*APIPolling) GetPlurks added in v0.1.3

func (u *APIPolling) GetPlurks(optionSets ...Options) (*Plurks, error)

Return plurks newer than offset You must set offset in GetPlurksOptions or you will get nothing.

func (*APIPolling) GetUnreadCount added in v0.1.3

func (u *APIPolling) GetUnreadCount() (*UnreadCount, error)

type APIProfile

type APIProfile struct {
	// contains filtered or unexported fields
}

func (*APIProfile) GetOwnProfile

func (u *APIProfile) GetOwnProfile() (*Profile, error)

func (*APIProfile) GetPublicProfile

func (u *APIProfile) GetPublicProfile(userId int64) (*Profile, error)

type APIRealtime added in v0.1.3

type APIRealtime struct {
	// contains filtered or unexported fields
}

func (*APIRealtime) GetUserChannel added in v0.1.3

func (u *APIRealtime) GetUserChannel() (*UserChannel, error)

func (*APIRealtime) Listen added in v0.1.3

func (u *APIRealtime) Listen(ctx context.Context, listener *UserChannelListener)

type APIResponses

type APIResponses struct {
	// contains filtered or unexported fields
}

func (*APIResponses) Get

func (u *APIResponses) Get(plurkId int64, fromResoponse int64, count int64) (*Responses, error)

func (*APIResponses) GetById added in v0.2.1

func (u *APIResponses) GetById(plurkId int64, fromResoponseId int64, count int64) (*Responses, error)

func (*APIResponses) ResponseAdd

func (u *APIResponses) ResponseAdd(plurkId int64, qualifier string, content string) (*Response, error)

func (*APIResponses) ResponseDelete

func (u *APIResponses) ResponseDelete(responseId int64, plurkId int64) error

type APITimeline

type APITimeline struct {
	// contains filtered or unexported fields
}

func (*APITimeline) FavoritePlurks

func (u *APITimeline) FavoritePlurks(plurkIds []int64) error

func (*APITimeline) GetPlurk

func (u *APITimeline) GetPlurk(plurkId int64) (*Plurk, error)

func (*APITimeline) GetPlurkCountsInfo added in v0.1.3

func (u *APITimeline) GetPlurkCountsInfo(plurkId int64) (*PlurkCountsInfo, error)

func (*APITimeline) GetPlurks added in v0.1.3

func (u *APITimeline) GetPlurks(optionSets ...Options) (*Plurks, error)

Return plurks older than offset see GetPlurksOptions

func (*APITimeline) GetPublicPlurks added in v0.1.3

func (u *APITimeline) GetPublicPlurks(optionSets ...Options) (*Plurks, error)

Return public plurks older than offset see GetPlurksOptions

func (*APITimeline) GetUnreadPlurks added in v0.1.3

func (u *APITimeline) GetUnreadPlurks(optionSets ...Options) (*Plurks, error)

Return unread plurks older than offset see GetPlurksOptions

func (*APITimeline) MarkAsRead

func (u *APITimeline) MarkAsRead(plurkIds []int64) error

func (*APITimeline) MutePlurks

func (u *APITimeline) MutePlurks(plurkIds []int64) error

func (*APITimeline) PlurkAdd

func (u *APITimeline) PlurkAdd(qualifier string, content string, optionSets ...Options) (*Plurk, error)

func (*APITimeline) PlurkDelete

func (u *APITimeline) PlurkDelete(plurkId int64) error

func (*APITimeline) Replurk

func (u *APITimeline) Replurk(plurkIds []int64) error

func (*APITimeline) UnfavoritePlurks

func (u *APITimeline) UnfavoritePlurks(plurkIds []int64) error

func (*APITimeline) UnmutePlurks

func (u *APITimeline) UnmutePlurks(plurkIds []int64) error

func (*APITimeline) Unreplurk

func (u *APITimeline) Unreplurk(plurkIds []int64) error

type APIUsers

type APIUsers struct {
	// contains filtered or unexported fields
}

func (*APIUsers) GetKarmaStats added in v0.2.1

func (u *APIUsers) GetKarmaStats() (*KarmaStates, error)

func (*APIUsers) Me

func (u *APIUsers) Me() (*User, error)

type AlertsEvent added in v0.2.0

type AlertsEvent struct {
	Type   string `json:"type"`
	Posted string `json:"posted"`
}

type AlertsFriendshipAcceptedEvent added in v0.2.0

type AlertsFriendshipAcceptedEvent struct {
	AlertsEvent
	FriendInfo User `json:"friend_info"`
}

Friendship accepted notification

type AlertsFriendshipPendingEvent added in v0.2.0

type AlertsFriendshipPendingEvent struct {
	AlertsEvent
	FromUser User `json:"to_user"`
}

requires action from the user

type AlertsFriendshipRequestEvent added in v0.2.0

type AlertsFriendshipRequestEvent struct {
	AlertsEvent
	FromUser User `json:"from_user"`
}

requires action from the user

type AlertsMentionedEvent added in v0.2.0

type AlertsMentionedEvent struct {
	AlertsEvent
	FromUser  User  `json:"from_user"`
	PlurkId   int64 `json:"plurk_id"`
	NumOthers int64 `json:"num_others"`
	// response_id may be null if user was mentioned in the plurk and not in a response.
	ResponseId *int64 `json:"response_id"`
}

User got mentioned in a plurk

type AlertsMyRespondedEvent added in v0.2.0

type AlertsMyRespondedEvent struct {
	AlertsEvent
	FromUser   User  `json:"from_user"`
	PlurkId    int64 `json:"plurk_id"`
	NumOthers  int64 `json:"num_others"`
	ResponseId int64 `json:"response_id"`
}

User's own plurk got responded

type AlertsNewFanEvent added in v0.2.0

type AlertsNewFanEvent struct {
	AlertsEvent
	NewFan User `json:"new_fan"`
}

type AlertsNewFriendEvent added in v0.2.0

type AlertsNewFriendEvent struct {
	AlertsEvent
	NewFriend User `json:"new_friend"`
}

New friend notification

type AlertsPlurkLikedEvent added in v0.2.0

type AlertsPlurkLikedEvent struct {
	AlertsEvent
	FromUser  User  `json:"from_user"`
	PlurkId   int64 `json:"plurk_id"`
	NumOthers int64 `json:"num_others"`
}

User's plurk got liked

type AlertsPlurkReplurkedEvent added in v0.2.0

type AlertsPlurkReplurkedEvent struct {
	AlertsEvent
	FromUser  User  `json:"from_user"`
	PlurkId   int64 `json:"plurk_id"`
	NumOthers int64 `json:"num_others"`
}

User's plurk got replurked

type AlertsPrivatePlurkEvent added in v0.2.0

type AlertsPrivatePlurkEvent struct {
	AlertsEvent
	Owner   User  `json:"owner"`
	PlurkId int64 `json:"plurk_id"`
}

New private plurk

type AlertsUnhandledEvent added in v0.2.0

type AlertsUnhandledEvent struct {
	AlertsEvent
	RawMessage json.RawMessage
}

type Birthday

type Birthday struct {
	Year  int64 `json:"year"`
	Month int64 `json:"month"`
	Day   int64 `json:"day"`
}

type Client

type Client struct {
	Users     *APIUsers
	Timeline  *APITimeline
	Responses *APIResponses
	Profile   *APIProfile
	Polling   *APIPolling
	Realtime  *APIRealtime
	Alerts    *APIAlerts
	Engine    Engine
}

func NewClient

func NewClient(consumerToken string, consumerSecret string, accessToken string, accessSecret string) (*Client, error)

type Engine

type Engine interface {
	CallAPI(_url string, opt map[string]string) ([]byte, error)
	CallAPIUnmarshal(_url string, opt map[string]string, v any) error
}

type EngineImpl

type EngineImpl struct {
	Credentials *oauth.Credentials
	// contains filtered or unexported fields
}

func (*EngineImpl) CallAPI

func (c *EngineImpl) CallAPI(_url string, opt map[string]string) ([]byte, error)

func (*EngineImpl) CallAPIUnmarshal added in v0.1.3

func (c *EngineImpl) CallAPIUnmarshal(_url string, opt map[string]string, v any) error

type GetPlurksOptions added in v0.1.3

type GetPlurksOptions struct {
	// contains filtered or unexported fields
}

func NewGetPlurksOptions added in v0.1.3

func NewGetPlurksOptions() *GetPlurksOptions

func (*GetPlurksOptions) FilterFavorite added in v0.1.3

func (o *GetPlurksOptions) FilterFavorite() *GetPlurksOptions

Limit the favorite plurks returned

func (*GetPlurksOptions) FilterMentioned added in v0.1.3

func (o *GetPlurksOptions) FilterMentioned() *GetPlurksOptions

Limit the mentioned plurks returned

func (*GetPlurksOptions) FilterMy added in v0.1.3

func (o *GetPlurksOptions) FilterMy() *GetPlurksOptions

Limit the my plurks returned

func (*GetPlurksOptions) FilterPrivate added in v0.1.3

func (o *GetPlurksOptions) FilterPrivate() *GetPlurksOptions

Limit the private plurks returned

func (*GetPlurksOptions) FilterReplurked added in v0.1.3

func (o *GetPlurksOptions) FilterReplurked() *GetPlurksOptions

Limit the replurked plurks returned

func (*GetPlurksOptions) FilterResponded added in v0.1.3

func (o *GetPlurksOptions) FilterResponded() *GetPlurksOptions

Limit the responded plurks returned

func (*GetPlurksOptions) Get added in v0.1.3

func (o *GetPlurksOptions) Get() map[string]string

func (*GetPlurksOptions) Limit added in v0.1.3

func (o *GetPlurksOptions) Limit(limit int64) *GetPlurksOptions

Limit the number of plurks returned

func (*GetPlurksOptions) Offset added in v0.1.3

func (o *GetPlurksOptions) Offset(offset time.Time) *GetPlurksOptions

type KarmaStates added in v0.2.1

type KarmaStates struct {
	CurrentKarma    float64  `json:"current_karma"`
	KarmaFallReason string   `json:"karma_fall_reason"`
	KarmaGraph      string   `json:"karma_graph"`
	KarmaTrendRaw   []string `json:"karma_trend"`
	KarmaTrend      []KarmaTrendNode
}

type KarmaTrendNode added in v0.2.1

type KarmaTrendNode struct {
	Time  time.Time
	Karma float64
}

type NewPlurkEvent added in v0.1.3

type NewPlurkEvent struct {
	Plurk
}

Realtime event "new_plurk"

type NewResponseEvent added in v0.1.3

type NewResponseEvent struct {
	PlurkId       int64    `json:"plurk_id"`
	Plurk         Plurk    `json:"plurk"`
	ResponseCount int64    `json:"response_count"`
	Response      Response `json:"response"`
	User          map[string]User
}

Realtime event "new_response"

type OAuthRequest

type OAuthRequest struct {
	Url string
	// contains filtered or unexported fields
}

func NewOAuthRequest

func NewOAuthRequest(consumerToken string, consumerSecret string) (*OAuthRequest, error)

func (*OAuthRequest) SendPin

func (c *OAuthRequest) SendPin(pin string) (*Client, string, string, error)

type Options

type Options interface {
	Get() map[string]string
}

type Plurk

type Plurk struct {
	PlurkId             int64   `json:"plurk_id"`
	Qualifier           string  `json:"qualifier"`
	QualifierTranslated string  `json:"qualifier_translated"`
	IsUnread            int64   `json:"is_unread"`
	PlurkType           int64   `json:"plurk_type"`
	UserId              int64   `json:"user_id"`
	OwnerId             int64   `json:"owner_id"`
	Posted              string  `json:"posted"`
	NoComments          int64   `json:"no_comments"`
	Content             string  `json:"content"`
	ContentRaw          string  `json:"content_raw"`
	ResponseCount       int64   `json:"response_count"`
	ResponseSeen        int64   `json:"responses_seen"`
	LimitedTo           string  `json:"limited_to"`
	Favorite            bool    `json:"favorite"`
	FavoriteCount       int64   `json:"favorite_count"`
	Favorers            []int64 `json:"favorers"`
	Replurkable         bool    `json:"replurkable"`
	Replurked           bool    `json:"replurked"`
	ReplurkerId         int64   `json:"replurker_id"`
	ReplurkerCount      int64   `json:"replurkers_count"`
	Replurkers          []int64 `json:"replurkers"`
}

type PlurkAddOptions

type PlurkAddOptions struct {
	// contains filtered or unexported fields
}

func NewPlurkAddOptions

func NewPlurkAddOptions() *PlurkAddOptions

func (*PlurkAddOptions) FriendsOnlyComments

func (o *PlurkAddOptions) FriendsOnlyComments() *PlurkAddOptions

func (*PlurkAddOptions) Get

func (o *PlurkAddOptions) Get() map[string]string

func (*PlurkAddOptions) Lang

func (o *PlurkAddOptions) Lang(lang string) *PlurkAddOptions

func (*PlurkAddOptions) LimitedTo

func (o *PlurkAddOptions) LimitedTo(ids ...int64) *PlurkAddOptions

func (*PlurkAddOptions) NoComments

func (o *PlurkAddOptions) NoComments() *PlurkAddOptions

type PlurkCountsInfo added in v0.1.3

type PlurkCountsInfo struct {
	ResponseCount  int64 `json:"response_count"`
	FavoriteCount  int64 `json:"favorite_count"`
	ReplurkerCount int64 `json:"replurkers_count"`
}

type Plurks

type Plurks struct {
	Plurks     []Plurk         `json:"plurks"`
	PlurkUsers map[string]User `json:"plurk_users"`
}

type Profile

type Profile struct {
	FriendsCount int64 `json:"friends_count"`
	FansCount    int64 `json:"fans_count"`

	UserInfo User   `json:"user_info"`
	Privacy  string `json:"privacy"`

	Plurks []Plurk `json:"plurks"`

	// OwnProfileOnly
	UnreadCount *int64          `json:"unread_count"`
	PlurksUsers map[string]User `json:"plurks_users"`

	// PublicProfileOnly
	AreFriends        *bool `json:"are_friends"`
	IsFan             *bool `json:"is_fan"`
	IsFollowing       *bool `json:"is_following"`
	HasReadPermission *bool `json:"has_read_permission"`
}

type RealtimeEventHandler added in v0.2.0

type RealtimeEventHandler func(eventType string, btyes json.RawMessage) error

func NewPlurkHandler added in v0.2.0

func NewPlurkHandler(handler func(*NewPlurkEvent)) RealtimeEventHandler

func NewResponseHandler added in v0.2.0

func NewResponseHandler(handler func(*NewResponseEvent)) RealtimeEventHandler

func UpdateNotificationHandler added in v0.2.0

func UpdateNotificationHandler(handler func(*UpdateNotificationEvent)) RealtimeEventHandler

type Response

type Response struct {
	Id                  int64   `json:"id"`
	UserId              int64   `json:"user_id"`
	PlurkId             int64   `json:"plurk_id"`
	Content             string  `json:"content"`
	ContentRaw          string  `json:"content_raw"`
	Qualifier           string  `json:"qualifier"`
	QualifierTranslated *string `json:"qualifier_translated"`
	Posted              string  `json:"posted"`
	Lang                string  `json:"lang"`
	LastEdited          *string `json:"last_edited"`
	Coins               *string `json:"coins"`
	Editability         int64   `json:"editability"`
}

type Responses

type Responses struct {
	Responses     []Response      `json:"responses"`
	ResponsesSeen int64           `json:"responses_seen"`
	ResponseCount int64           `json:"response_count"`
	Friends       map[string]User `json:"friends"`
}

type UnreadCount added in v0.1.3

type UnreadCount struct {
	All       int64 `json:"all"`
	My        int64 `json:"my"`
	Private   int64 `json:"private"`
	Responsed int64 `json:"responded"`
}

type UpdateNotificationEvent added in v0.2.0

type UpdateNotificationEvent struct {
	Counts struct {
		Noti int64 `json:"noti"`
		Req  int64 `json:"req"`
	} `json:"counts"`
}

Realtime event "update_notification" {"counts": {"noti": 1, "req": 0}, "type": "update_notification"}

type User

type User struct {
	Id                int64    `json:"id"`
	NickName          string   `json:"nick_name"`
	DisplayName       string   `json:"display_name"`
	FullName          string   `json:"full_name"`
	NameColor         string   `json:"name_color"`
	Premium           bool     `json:"premium"`
	HasProfileImage   int64    `json:"has_profile_image"`
	Avatar            int64    `json:"avatar"`
	ShowLocation      int64    `json:"show_location"`
	Location          string   `json:"location"`
	Timezone          string   `json:"timezone"`
	DefaultLang       string   `json:"default_lang"`
	DateFormat        int64    `json:"dateformat"`
	DateOfBirth       string   `json:"date_of_birth"`
	Birthday          Birthday `json:"birthday"`
	BdayPrivacy       int64    `json:"bday_privacy"`
	Gender            int64    `json:"gender"`
	Karma             float64  `json:"karma"`
	Recruited         int64    `json:"recruited"`
	Relationship      string   `json:"relationship"`
	Status            string   `json:"status"`
	TimelinePrivacy   int64    `json:"timeline_privacy"`
	VerifiedAccount   bool     `json:"verified_account"`
	FriendListPrivacy string   `json:"friend_list_privacy"`
	EmailConfirmed    bool     `json:"email_confirmed"`
	PhoneVerified     *int64   `json:"phone_verified"`
	PinnedPlurkId     *int64   `json:"pinned_plurk_id"`
	BackgroundId      int64    `json:"background_id"`
	ShowAds           bool     `json:"show_ads"`
	Version           string   `json:"_version"`
}

type UserChannel added in v0.1.3

type UserChannel struct {
	ChannelName string `json:"channel_name"`
	CometServer string `json:"comet_server"`
}

type UserChannelListener added in v0.2.0

type UserChannelListener struct {
	LogHandler    func(log string, err error)
	EventHandlers []RealtimeEventHandler
}

func (*UserChannelListener) AddHandler added in v0.2.0

func (l *UserChannelListener) AddHandler(h RealtimeEventHandler)

func (*UserChannelListener) Err added in v0.2.0

func (l *UserChannelListener) Err(s error)

func (*UserChannelListener) Log added in v0.2.0

func (l *UserChannelListener) Log(s string)

Directories

Path Synopsis
Package oauth is consumer interface for OAuth 1.0, OAuth 1.0a and RFC 5849.
Package oauth is consumer interface for OAuth 1.0, OAuth 1.0a and RFC 5849.

Jump to

Keyboard shortcuts

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