My mirror of the Barnard terminal client for Mumble.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

109 řádky
2.9 KiB

  1. package barnard
  2. import (
  3. "fmt"
  4. "github.com/layeh/gumble/gumble"
  5. )
  6. func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
  7. b.Ui.SetActive(uiViewInput)
  8. b.UiTree.Rebuild()
  9. b.Ui.Refresh()
  10. b.UpdateInputStatus(fmt.Sprintf("To: %s", e.Client.Self.Channel.Name))
  11. b.AddOutputLine(fmt.Sprintf("Connected to %s", b.Client.Conn.RemoteAddr()))
  12. if e.WelcomeMessage != "" {
  13. b.AddOutputLine(fmt.Sprintf("Welcome message: %s", esc(e.WelcomeMessage)))
  14. }
  15. }
  16. func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
  17. var reason string
  18. switch e.Type {
  19. case gumble.DisconnectError:
  20. reason = "connection error"
  21. case gumble.DisconnectOther:
  22. reason = e.String
  23. case gumble.DisconnectVersion:
  24. reason = "invalid version number"
  25. case gumble.DisconnectUserName:
  26. reason = "invalid user name"
  27. case gumble.DisconnectUserCredentials:
  28. reason = "incorrect user password/certificate"
  29. case gumble.DisconnectServerPassword:
  30. reason = "incorrect server password"
  31. case gumble.DisconnectUsernameInUse:
  32. reason = "user name in use"
  33. case gumble.DisconnectServerFull:
  34. reason = "server full"
  35. case gumble.DisconnectNoCertificate:
  36. reason = "missing certificate"
  37. case gumble.DisconnectAuthenticatorFail:
  38. reason = "authenticator verification failed"
  39. }
  40. if reason == "" {
  41. b.AddOutputLine("Disconnected")
  42. } else {
  43. b.AddOutputLine("Disconnected: " + reason)
  44. }
  45. b.UiTree.Rebuild()
  46. b.Ui.Refresh()
  47. }
  48. func (b *Barnard) OnTextMessage(e *gumble.TextMessageEvent) {
  49. b.AddOutputMessage(e.Sender, e.Message)
  50. }
  51. func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
  52. if e.Type.Has(gumble.UserChangeChannel) && e.User == b.Client.Self {
  53. b.UpdateInputStatus(fmt.Sprintf("To: %s", e.User.Channel.Name))
  54. }
  55. b.UiTree.Rebuild()
  56. b.Ui.Refresh()
  57. }
  58. func (b *Barnard) OnChannelChange(e *gumble.ChannelChangeEvent) {
  59. b.UiTree.Rebuild()
  60. b.Ui.Refresh()
  61. }
  62. func (b *Barnard) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
  63. var info string
  64. switch e.Type {
  65. case gumble.PermissionDeniedOther:
  66. info = e.String
  67. case gumble.PermissionDeniedPermission:
  68. info = "insufficient permissions"
  69. case gumble.PermissionDeniedSuperUser:
  70. info = "cannot modify SuperUser"
  71. case gumble.PermissionDeniedInvalidChannelName:
  72. info = "invalid channel name"
  73. case gumble.PermissionDeniedTextTooLong:
  74. info = "text too long"
  75. case gumble.PermissionDeniedTemporaryChannel:
  76. info = "temporary channel"
  77. case gumble.PermissionDeniedMissingCertificate:
  78. info = "missing certificate"
  79. case gumble.PermissionDeniedInvalidUserName:
  80. info = "invalid user name"
  81. case gumble.PermissionDeniedChannelFull:
  82. info = "channel full"
  83. case gumble.PermissionDeniedNestingLimit:
  84. info = "nesting limit"
  85. }
  86. b.AddOutputLine(fmt.Sprintf("Permission denied: %s", info))
  87. }
  88. func (b *Barnard) OnUserList(e *gumble.UserListEvent) {
  89. }
  90. func (b *Barnard) OnACL(e *gumble.ACLEvent) {
  91. }
  92. func (b *Barnard) OnBanList(e *gumble.BanListEvent) {
  93. }
  94. func (b *Barnard) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
  95. }