Documentation ¶
Index ¶
- Constants
- type CLI
- type CommentViewer
- func (cv *CommentViewer) AddPlugin(p *Plugin)
- func (cv *CommentViewer) AntennaConnect()
- func (cv *CommentViewer) AntennaDisconnect()
- func (cv *CommentViewer) Disconnect()
- func (cv *CommentViewer) EmitEvNewNotification(typ, title, desc string)
- func (cv *CommentViewer) Plugin(n int) (*Plugin, error)
- func (cv *CommentViewer) PluginName(n int) string
- func (cv *CommentViewer) Quit()
- func (cv *CommentViewer) Start()
- func (cv *CommentViewer) Wait()
- type CtAntennaGot
- type CtCommentGot
- type CtDirectNo
- type CtDirectUserGet
- type CtDirectngmAppVersion
- type CtDirectngmPlugList
- type CtDirectngmSettingsAll
- type CtDirectngmSettingsCurrent
- type CtDirectngmUserGet
- type CtNagomeBroadInfo
- type CtNagomeBroadOpen
- type CtNagomeUserUpdate
- type CtQueryAccountSet
- type CtQueryBroadConnect
- type CtQueryBroadSendComment
- type CtQueryLogPrint
- type CtQueryPlugEnable
- type CtQuerySettingsSetAll
- type CtQuerySettingsSetCurrent
- type CtQueryUserDelete
- type CtQueryUserFetch
- type CtQueryUserSet
- type CtQueryUserSetName
- type CtUINotification
- type Message
- type Plugin
- func (pl *Plugin) Close()
- func (pl *Plugin) IsMain() bool
- func (pl *Plugin) IsSubscribe(pln string) bool
- func (pl *Plugin) Load(filePath string) error
- func (pl *Plugin) Open(rwc io.ReadWriteCloser, enable bool) error
- func (pl *Plugin) Save(filePath string) error
- func (pl *Plugin) SetState(enable bool)
- func (pl *Plugin) Write(p []byte) (fail bool)
- func (pl *Plugin) WriteMess(m *Message) (fail bool)
- type ProceedNicoliveEvent
- type SettingsSlot
- type SettingsSlots
Constants ¶
const ( DomainNagome = "nagome" DomainQuery = "nagome_query" DomainComment = "nagome_comment" DomainUI = "nagome_ui" DomainAntenna = "nagome_antenna" DomainDirect = "nagome_direct" // DomainDirect is a special domain (from plugin). DomainDirectngm = "nagome_directngm" // DomainDirectNgm is a domain for direct message from Nagome. // Adding DomainSuffixFilter to the end of domain name in "subscribe" in your plugin.yml enables filtering messages by the plugin. DomainSuffixFilter = "@filter" )
Dimain names
const ( // DomainNagome CommNagomeBroadOpen = "Broad.Open" CommNagomeBroadClose = "Broad.Close" CommNagomeBroadInfo = "Broad.Info" CommNagomeCommentSend = "Comment.Send" CommNagomeAntennaOpen = "Antenna.Open" CommNagomeAntennaClose = "Antenna.Close" CommNagomeUserUpdate = "User.Update" // CommNagomeUserUpdate is Emitted when User info is updated by fetching or setting name etc. // DomainComment // This domain is for only sending comments. CommCommentGot = "Got" // DomainQuery // Query from plugin to Nagome. CommQueryBroadConnect = "Broad.Connect" CommQueryBroadDisconnect = "Broad.Disconnect" CommQueryBroadSendComment = "Broad.SendComment" CommQueryAccountSet = "Account.Set" // Set the given content value as account values. CommQueryAccountLogin = "Account.Login" // Login and set the user session to account. CommQueryAccountLoad = "Account.Load" CommQueryAccountSave = "Account.Save" CommQueryLogPrint = "Log.Print" // Print string using logger of Nagome CommQuerySettingsSetCurrent = "Settings.SetCurrent" // Set settings to current slot. CommQuerySettingsSetAll = "Settings.SetAll" // Set all slots of settings. CommQueryPlugEnable = "Plug.Enable" // Enable or disable a plugin. CommQueryUserSet = "User.Set" // Set user info like name to the DB. CommQueryUserSetName = "User.SetName" // Set user name to the DB. CommQueryUserDelete = "User.Delete" // Delete user info from the DB. CommQueryUserFetch = "User.Fetch" // Fetch user name from web page and update the internal user database. // DomainUI // Event to be processed by UI plugin. CommUINotification = "Notification" CommUIClearComments = "ClearComments" CommUIConfigAccount = "ConfigAccount" // Open the window of account setting or suggest user to configure it. // DomainAntenna // All antenna items (started live). CommAntennaGot = "Got" // from plugin to Nagome CommDirectAppVersion = "App.Version" CommDirectNo = "No" // Tell plugin number to Nagome when the connection started. (TCP at first time only) CommDirectPlugList = "Plug.List" // Request a list of plugins. CommDirectSettingsCurrent = "Settings.Current" // Request current settings message. CommDirectSettingsAll = "Settings.All" // Request all slots of settings message. CommDirectUserGet = "User.Get" // Get user info from the user DB. // from Nagome to plugin CommDirectngmAppVersion = "App.Version" CommDirectngmPlugEnabled = "Plug.Enabled" // Sent when the plugin is enabled. CommDirectngmPlugDisabled = "Plug.Disabled" // Sent when the plugin is disabled. CommDirectngmPlugList = "Plug.List" CommDirectngmSettingsCurrent = "Settings.Current" CommDirectngmSettingsAll = "Settings.All" CommDirectngmUserGet = "User.Get" )
Command names
const ( CtQueryBroadSendCommentTypeGeneral string = "General" CtQueryBroadSendCommentTypeOwner = "Owner" // ignored if the user is not the owner )
type of CtQueryBroadSendComment
const ( CtUINotificationTypeInfo string = "Info" CtUINotificationTypeWarn = "Warn" )
type of CtUINotification
const (
NumFetchInformaionRetry = 3
)
Constant values for processing plugin messages.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI struct { InStream io.ReadCloser OutStream, ErrStream io.WriteCloser SavePath string SettingsSlots SettingsSlots AppName, Version string // contains filtered or unexported fields }
CLI has valuables and settings for a CLI environment.
type CommentViewer ¶
type CommentViewer struct { Ac *nicolive.Account Lw *nicolive.LiveWaku Cmm *nicolive.CommentConnection Antn *nicolive.Antenna Pgns []*Plugin Settings SettingsSlot TCPPort string Evch chan *Message // contains filtered or unexported fields }
A CommentViewer is a pair of an Account and a LiveWaku.
func NewCommentViewer ¶
func NewCommentViewer(tcpPort string, cli *CLI) *CommentViewer
NewCommentViewer makes new CommentViewer
func (*CommentViewer) AddPlugin ¶
func (cv *CommentViewer) AddPlugin(p *Plugin)
AddPlugin adds new plugin to Pgns
func (*CommentViewer) AntennaConnect ¶
func (cv *CommentViewer) AntennaConnect()
AntennaConnect connects Antenna and start processing.
func (*CommentViewer) AntennaDisconnect ¶
func (cv *CommentViewer) AntennaDisconnect()
AntennaDisconnect disconnects current antenna connection if connected.
func (*CommentViewer) Disconnect ¶
func (cv *CommentViewer) Disconnect()
Disconnect disconnects current comment connection if connected.
func (*CommentViewer) EmitEvNewNotification ¶
func (cv *CommentViewer) EmitEvNewNotification(typ, title, desc string)
EmitEvNewNotification emits new event for ask UI to display a notification.
func (*CommentViewer) Plugin ¶
func (cv *CommentViewer) Plugin(n int) (*Plugin, error)
Plugin returns plugin with given No.
func (*CommentViewer) PluginName ¶
func (cv *CommentViewer) PluginName(n int) string
PluginName returns name of the plugin with given No.
func (*CommentViewer) Start ¶
func (cv *CommentViewer) Start()
Start run the CommentViewer and start connecting plugins
type CtAntennaGot ¶
type CtAntennaGot struct { BroadID string `json:"broad_id"` CommunityID string `json:"community_id"` UserID string `json:"user_id"` }
CtAntennaGot is a content of CommAntennaGot
type CtCommentGot ¶
type CtCommentGot struct { No int `json:"no"` Date time.Time `json:"date"` Raw string `json:"raw"` Comment string `json:"comment"` UserID string `json:"user_id"` UserName string `json:"user_name"` UserThumbnailURL string `json:"user_thumbnail_url,omitempty"` Score int `json:"score,omitempty"` IsPremium bool `json:"is_premium"` IsBroadcaster bool `json:"is_broadcaster"` IsStaff bool `json:"is_staff"` IsAnonymity bool `json:"is_anonymity"` }
A CtCommentGot is a content of CommCommentGot
type CtDirectNo ¶
type CtDirectNo struct {
No int `json:"no"`
}
CtDirectNo is a content for CommDirectNo
type CtDirectUserGet ¶
type CtDirectUserGet struct {
ID string `json:"id"`
}
CtDirectUserGet is a content for CommDirectUserGet
type CtDirectngmAppVersion ¶ added in v1.0.0
CtDirectngmAppVersion is a content for CommDirectngmAppVersion
type CtDirectngmPlugList ¶
type CtDirectngmPlugList struct {
Plugins *[]*Plugin `json:"plugins"`
}
CtDirectngmPlugList is a content for CommDirectngmPlugList
type CtDirectngmSettingsAll ¶
type CtDirectngmSettingsAll SettingsSlots
CtDirectngmSettingsAll is a content for CommDirectngmSettingsAll
type CtDirectngmSettingsCurrent ¶
type CtDirectngmSettingsCurrent SettingsSlot
CtDirectngmSettingsCurrent is a content for CommDirectngmSettingsCurrent
type CtDirectngmUserGet ¶
CtDirectngmUserGet is a content for CommDirectngmUserGet
type CtNagomeBroadInfo ¶
type CtNagomeBroadInfo struct { WatchCount string `json:"watch_count"` CommentCount string `json:"comment_count"` }
CtNagomeBroadInfo is a content of CommNagomeBroadInfo
type CtNagomeBroadOpen ¶
type CtNagomeBroadOpen struct { BroadID string `json:"broad_id"` Title string `json:"title"` Description string `json:"description"` CommunityID string `json:"community_id"` OwnerID string `json:"owner_id"` OwnerName string `json:"owner_name"` OwnerBroad bool `json:"owner_broad"` OpenTime time.Time `json:"open_time"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` }
CtNagomeBroadOpen is a content of CommNagomeBroadOpen
type CtNagomeUserUpdate ¶
CtNagomeUserUpdate is a content of CommNagomeUserUpdate
type CtQueryAccountSet ¶
CtQueryAccountSet is a content of CommQueryAccountSet
type CtQueryBroadConnect ¶
type CtQueryBroadConnect struct { BroadID string `json:"broad_id"` RetryN int `json:"retry_n,omitempty"` }
CtQueryBroadConnect is a content of CommQueryBroadConnect
type CtQueryBroadSendComment ¶
type CtQueryBroadSendComment struct { Text string `json:"text"` Iyayo bool `json:"iyayo"` Type string `json:"type,omitempty"` // if omitted, automatically selected depend on the settings }
CtQueryBroadSendComment is a content of CommQueryBroadSendComment
type CtQueryLogPrint ¶
type CtQueryLogPrint struct {
Text string `json:"text"`
}
CtQueryLogPrint is a content of CommQueryLogPrint
type CtQueryPlugEnable ¶
CtQueryPlugEnable is a content of CommQueryPlugEnable
type CtQuerySettingsSetAll ¶
type CtQuerySettingsSetAll SettingsSlots
CtQuerySettingsSetAll is a content of CommQuerySettingsSetAll
type CtQuerySettingsSetCurrent ¶
type CtQuerySettingsSetCurrent SettingsSlot
CtQuerySettingsSetCurrent is a content of CommQuerySettingsSetCurrent
type CtQueryUserDelete ¶
type CtQueryUserDelete struct {
ID string `json:"id"`
}
CtQueryUserDelete is a content for CommQueryUserDelete
type CtQueryUserFetch ¶
type CtQueryUserFetch struct {
ID string `json:"id"`
}
CtQueryUserFetch is a content for CommQueryUserFetch
type CtQueryUserSet ¶
CtQueryUserSet is a content for CommQueryUserSet
type CtQueryUserSetName ¶
CtQueryUserSetName is a content for CommQueryUserSetName
type CtUINotification ¶
type CtUINotification struct { // Select type from below const string Type string `json:"type"` Title string `json:"title"` Description string `json:"description"` }
CtUINotification is a content of CommUINotification
type Message ¶
type Message struct { Domain string `json:"domain"` Command string `json:"command"` Content json.RawMessage `json:"content,omitempty"` // The structure of Content is depend on the Command (and Domain). // contains filtered or unexported fields }
Message is base API struct for plugin
func NewMessage ¶
NewMessage returns new Message with the given values.
func NewMessageMust ¶
NewMessageMust is same as NewMessage but assume no error.
type Plugin ¶
type Plugin struct { Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` Version string `yaml:"version" json:"version"` Author string `yaml:"author" json:"author"` Method string `yaml:"method" json:"method"` Exec []string `yaml:"exec" json:"-"` Nagomever string `yaml:"nagomever" json:"-"` Subscribe []string `yaml:"subscribe" json:"subscribe"` No int `yaml:"-" json:"no"` GetState pluginState `yaml:"-" json:"state"` // Don't change directly // contains filtered or unexported fields }
A Plugin is a Nagome plugin.
func (*Plugin) IsSubscribe ¶
IsSubscribe returns whether the plugin subscribes given Domain.
func (*Plugin) Open ¶
func (pl *Plugin) Open(rwc io.ReadWriteCloser, enable bool) error
Open opens connection and start processing.
type ProceedNicoliveEvent ¶
type ProceedNicoliveEvent struct {
// contains filtered or unexported fields
}
ProceedNicoliveEvent is struct for proceeding nico events from nicolive packeage.
func NewProceedNicoliveEvent ¶
func NewProceedNicoliveEvent(cv *CommentViewer) *ProceedNicoliveEvent
NewProceedNicoliveEvent makes new ProceedNicoliveEvent and returns it.
func (*ProceedNicoliveEvent) CheckIntervalAndCreateUser ¶
func (p *ProceedNicoliveEvent) CheckIntervalAndCreateUser(id string) (*nicolive.User, error)
CheckIntervalAndCreateUser returns a pointer to new struct nicolive.User with fetched user information unless it exceed the limitation of API
func (*ProceedNicoliveEvent) ProceedNicoEvent ¶
func (p *ProceedNicoliveEvent) ProceedNicoEvent(ev *nicolive.Event)
ProceedNicoEvent will receive events and emits it.
type SettingsSlot ¶
type SettingsSlot struct { Name string `yaml:"name" json:"name"` AutoSaveTo0Slot bool `yaml:"auto_save_to0_slot" json:"auto_save_to0_slot"` UserNameGet bool `yaml:"user_name_get" json:"user_name_get"` AutoFollowNextWaku bool `yaml:"auto_follow_next_waku" json:"auto_follow_next_waku"` OwnerComment bool `yaml:"owner_comment" json:"owner_comment"` PluginDisable map[string]bool `yaml:"plugin_disable" json:"plugin_disable"` }
A SettingsSlot represents a settings of Nagome.
func NewSettingsSlot ¶
func NewSettingsSlot() *SettingsSlot
NewSettingsSlot creates new SettingsSlot with default values.
func (*SettingsSlot) Duplicate ¶
func (s *SettingsSlot) Duplicate() SettingsSlot
Duplicate creates new copy.
func (*SettingsSlot) UnmarshalYAML ¶
func (s *SettingsSlot) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is a function for implementing yaml.Unmarshaler.
type SettingsSlots ¶
type SettingsSlots struct {
Config []*SettingsSlot `yaml:"config" json:"config"`
}
SettingsSlots is struct for multiple configs file.
func (*SettingsSlots) Add ¶
func (ss *SettingsSlots) Add(s *SettingsSlot)
Add adds given slot to the list.
func (*SettingsSlots) Load ¶
func (ss *SettingsSlots) Load(path string) error
Load loads from a file.