Documentation ¶
Overview ¶
Package nicolive provides access way to NicoNama API, corresponding structures and other features.
Index ¶
- func CommentOwner(broadID string, method string, commreq *CommentOwnerRequest, ac *Account) error
- func Is184UserID(id string) bool
- type Account
- type Antenna
- type AntennaItem
- type Comment
- type CommentConnection
- type CommentOwnerRequest
- type ErrNum
- type Error
- type Event
- type EventReceiver
- type EventTypeNum
- type HeartbeatValue
- type LiveWaku
- type PublishStatusItem
- type User
- type UserDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentOwner ¶ added in v0.0.4
func CommentOwner(broadID string, method string, commreq *CommentOwnerRequest, ac *Account) error
CommentOwner sends a comment as the owner.
func Is184UserID ¶ added in v0.0.5
Is184UserID returns whether the ID is 184
Types ¶
type Account ¶
type Account struct { Mail string `yaml:"mail"` Pass string `yaml:"pass"` Usersession string `yaml:"usersession"` // contains filtered or unexported fields }
An Account is a niconico account. It is used to access APIs in this library.
func AccountLoad ¶ added in v0.0.4
AccountLoad reads from a file and return new Account.
func NewAccount ¶ added in v0.0.4
NewAccount makes new account with a http client.
func (*Account) UpdateClient ¶ added in v0.0.4
func (a *Account) UpdateClient()
UpdateClient updates Client with its Usersession. If the Usersession of the account is empty string, clear the cookies jar.
type Antenna ¶ added in v0.0.2
type Antenna struct { Following []string // contains filtered or unexported fields }
Antenna manages starting broadcast antenna connection.
func ConnectAntenna ¶ added in v0.0.2
ConnectAntenna connects to antenna and return new Antenna.
func (*Antenna) Connect ¶ added in v0.0.2
func (a *Antenna) Connect(ctx context.Context, ev EventReceiver) (err error)
Connect connects to antenna
func (*Antenna) Disconnect ¶ added in v0.0.2
Disconnect quit all routines and disconnect.
type AntennaItem ¶ added in v0.0.2
type AntennaItem struct {
BroadID, CommunityID, UserID string
}
An AntennaItem is a started live broadcast. It's send as a content of an EventTypeAntennaGot event.
type Comment ¶
type Comment struct { No int Date time.Time UserID string IsPremium bool IsCommand bool IsStaff bool IsAnonymity bool Comment string Mail string Locale string Score int }
A Comment is a received comment. It's send as a content of an EventTypeGot event.
type CommentConnection ¶
type CommentConnection struct { ConnectedTm time.Time // The time when this connection started // contains filtered or unexported fields }
CommentConnection is a struct to manage sending/receiving comments. This struct automatically Keeping alive and get the PostKey, which is necessary for sending comments.
func CommentConnect ¶ added in v0.0.2
func CommentConnect(ctx context.Context, lv LiveWaku, ev EventReceiver) (*CommentConnection, error)
CommentConnect connects to nicolive and start receiving comment. liveWaku should have connection information which is able to get by fetchInformation()
func (*CommentConnection) Disconnect ¶
func (cc *CommentConnection) Disconnect() error
Disconnect quit all routines and disconnect.
func (*CommentConnection) FetchPostKey ¶
func (cc *CommentConnection) FetchPostKey() (postkey string, err error)
FetchPostKey gets postkey using getpostkey API This function is safe for concurrent use.
func (*CommentConnection) SendComment ¶
func (cc *CommentConnection) SendComment(text string, iyayo bool)
SendComment sends comment to current comment connection
type CommentOwnerRequest ¶ added in v0.0.4
type CommentOwnerRequest struct { Text string `json:"text"` IsPermanent bool `json:"isPermanent"` Color string `json:"color"` UserName string `json:"userName,omitempty"` }
CommentOwnerRequest is a request of an owner comment.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error struct in nicolive
func ErrFromStdErr ¶
ErrFromStdErr returns Error converted from standard error.
func (Error) Type ¶ added in v0.0.4
Type returns errorNum for identifying by application. (ie. select messages to the user)
func (Error) TypeString ¶ added in v0.0.2
TypeString returns name of the error type.
type EventReceiver ¶
type EventReceiver interface {
ProceedNicoEvent(*Event)
}
EventReceiver receive events and proceed
type EventTypeNum ¶
type EventTypeNum int
EventTypeNum is an Enum to represent Event.Type
const ( EventTypeCommentErr EventTypeNum = iota EventTypeCommentGot EventTypeCommentSend EventTypeCommentOpen EventTypeCommentClose EventTypeWakuEnd EventTypeHeartBeatGot EventTypeAntennaOpen EventTypeAntennaClose EventTypeAntennaGot EventTypeAntennaErr )
EventType
type HeartbeatValue ¶
HeartbeatValue is struct to hold result of heartbeat API
type LiveWaku ¶
type LiveWaku struct { Account *Account BroadID string Stream struct { Title string Description string CommunityID string OwnerID string OwnerName string OpenTime time.Time StartTime time.Time EndTime time.Time BroadcastToken string } User struct { UserID string Name string IsPremium bool } CommentServer struct { Addr string Port string Thread string } OwnerBroad bool OwnerCommentToken string }
LiveWaku is a live broadcast(Waku) of Niconama
func (*LiveWaku) FetchHeartBeat ¶
func (l *LiveWaku) FetchHeartBeat() (heartBeatValue *HeartbeatValue, waitTime int, err error)
FetchHeartBeat gets watcher and comment count using heartbeat API This function is safe for concurrent use.
func (*LiveWaku) FetchInformation ¶
FetchInformation gets information using getplayerstatus API
func (*LiveWaku) IsUserOwner ¶
IsUserOwner returns whether the user own this broad
type PublishStatusItem ¶ added in v0.0.4
type PublishStatusItem struct { Token string `json:"token"` URL string `json:"url"` Stream string `json:"stream"` Ticket string `json:"ticket"` Bitrate string `json:"bitrate"` }
PublishStatusItem is the response of PublishStatus API
func PublishStatus ¶ added in v0.0.4
func PublishStatus(broadID string, a *Account) (*PublishStatusItem, error)
PublishStatus gets a token to comment as owner. This function is safe for concurrent use.
type User ¶ added in v0.0.2
type User struct { ID string `json:"id"` Name string `json:"name"` CreateTime time.Time `json:"create_time"` Is184 bool `json:"is184"` ThumbnailURL string `json:"thumbnail_url"` }
User is a niconico user.
func CreateUser ¶ added in v0.0.4
CreateUser gather the user infomation of the given user id and returns pointer to new User struct.
func FetchUserInfo ¶ added in v0.0.2
FetchUserInfo fetches user name and Thumbnail URL from niconico. This function is safe for concurrent use.
type UserDB ¶ added in v0.0.2
type UserDB struct {
// contains filtered or unexported fields
}
UserDB is database of Users.