My mirror of the Barnard terminal client for Mumble.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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