My mirror of the Barnard terminal client for Mumble.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

113 lignes
3.0 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. 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 verification 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. }