|
- package barnard
-
- import (
- "fmt"
-
- "github.com/layeh/gumble/gumble"
- )
-
- func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
- b.Ui.SetActive(uiViewInput)
- b.UiTree.Rebuild()
- b.Ui.Refresh()
-
- if b.Client.AudioEncoder().Bitrate() > e.MaximumBitrate {
- b.Client.AudioEncoder().SetBitrate(e.MaximumBitrate / 3)
- }
-
- b.UpdateInputStatus(fmt.Sprintf("To: %s", e.Client.Self().Channel().Name()))
- b.AddOutputLine(fmt.Sprintf("Connected to %s", b.Client.Conn().RemoteAddr()))
- if e.WelcomeMessage != "" {
- b.AddOutputLine(fmt.Sprintf("Welcome message: %s", esc(e.WelcomeMessage)))
- }
- }
-
- func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
- var reason string
- switch e.Type {
- case gumble.DisconnectError:
- reason = "connection error"
- case gumble.DisconnectOther:
- reason = e.String
- case gumble.DisconnectVersion:
- reason = "invalid version number"
- case gumble.DisconnectUserName:
- reason = "invalid user name"
- case gumble.DisconnectUserCredentials:
- reason = "incorrect user password/certificate"
- case gumble.DisconnectServerPassword:
- reason = "incorrect server password"
- case gumble.DisconnectUsernameInUse:
- reason = "user name in use"
- case gumble.DisconnectServerFull:
- reason = "server full"
- case gumble.DisconnectNoCertificate:
- reason = "missing certificate"
- case gumble.DisconnectAuthenticatorFail:
- reason = "authenticator verification failed"
- }
- if reason == "" {
- b.AddOutputLine("Disconnected")
- } else {
- b.AddOutputLine("Disconnected: " + reason)
- }
- b.UiTree.Rebuild()
- b.Ui.Refresh()
- }
-
- func (b *Barnard) OnTextMessage(e *gumble.TextMessageEvent) {
- b.AddOutputMessage(e.Sender, e.Message)
- }
-
- func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
- if e.Type.Has(gumble.UserChangeChannel) && e.User == b.Client.Self() {
- b.UpdateInputStatus(fmt.Sprintf("To: %s", e.User.Channel().Name()))
- }
- b.UiTree.Rebuild()
- b.Ui.Refresh()
- }
-
- func (b *Barnard) OnChannelChange(e *gumble.ChannelChangeEvent) {
- b.UiTree.Rebuild()
- b.Ui.Refresh()
- }
-
- func (b *Barnard) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
- var info string
- switch e.Type {
- case gumble.PermissionDeniedOther:
- info = e.String
- case gumble.PermissionDeniedPermission:
- info = "insufficient permissions"
- case gumble.PermissionDeniedSuperUser:
- info = "cannot modify SuperUser"
- case gumble.PermissionDeniedInvalidChannelName:
- info = "invalid channel name"
- case gumble.PermissionDeniedTextTooLong:
- info = "text too long"
- case gumble.PermissionDeniedTemporaryChannel:
- info = "temporary channel"
- case gumble.PermissionDeniedMissingCertificate:
- info = "missing certificate"
- case gumble.PermissionDeniedInvalidUserName:
- info = "invalid user name"
- case gumble.PermissionDeniedChannelFull:
- info = "channel full"
- case gumble.PermissionDeniedNestingLimit:
- info = "nesting limit"
- }
- b.AddOutputLine(fmt.Sprintf("Permission denied: %s", info))
- }
-
- func (b *Barnard) OnUserList(e *gumble.UserListEvent) {
- }
-
- func (b *Barnard) OnACL(e *gumble.ACLEvent) {
- }
-
- func (b *Barnard) OnBanList(e *gumble.BanListEvent) {
- }
-
- func (b *Barnard) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
- }
|