You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

theater.go 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Copyright (c) 2012-2014 Jeremy Latt
  2. // Copyright (c) 2014-2015 Edmund Huber
  3. // released under the MIT license
  4. package irc
  5. type TheaterClient Name
  6. func (c TheaterClient) Id() Name {
  7. return Name(c)
  8. }
  9. func (c TheaterClient) Nick() Name {
  10. return Name(c)
  11. }
  12. /*
  13. func (m *TheaterIdentifyCommand) LoadPassword(s *Server) {
  14. m.hash = s.theaters[m.channel]
  15. }
  16. if upperSubCmd := strings.ToUpper(args[0]); upperSubCmd == "IDENTIFY" && len(args) == 3 {
  17. return &TheaterIdentifyCommand{
  18. channel: NewName(args[1]),
  19. PassCommand: PassCommand{password: []byte(args[2])},
  20. }, nil
  21. } else if upperSubCmd == "PRIVMSG" && len(args) == 4 {
  22. return &TheaterPrivMsgCommand{
  23. channel: NewName(args[1]),
  24. asNick: NewName(args[2]),
  25. message: NewText(args[3]),
  26. }, nil
  27. } else if upperSubCmd == "ACTION" && len(args) == 4 {
  28. return &TheaterActionCommand{
  29. channel: NewName(args[1]),
  30. asNick: NewName(args[2]),
  31. action: NewCTCPText(args[3]),
  32. }, nil
  33. } else {
  34. return nil, ErrParseCommand
  35. }
  36. func (m *TheaterIdentifyCommand) HandleServer(s *Server) {
  37. client := m.Client()
  38. if !m.channel.IsChannel() {
  39. client.ErrNoSuchChannel(m.channel)
  40. return
  41. }
  42. channel := s.channels.Get(m.channel)
  43. if channel == nil {
  44. client.ErrNoSuchChannel(m.channel)
  45. return
  46. }
  47. if (m.hash == nil) || (m.err != nil) {
  48. client.ErrPasswdMismatch()
  49. return
  50. }
  51. if channel.members.AnyHasMode(Theater) {
  52. client.Reply(RplNotice(s, client, "someone else is +T in this channel"))
  53. return
  54. }
  55. channel.members[client][Theater] = true
  56. }
  57. type TheaterPrivMsgCommand struct {
  58. BaseCommand
  59. channel Name
  60. asNick Name
  61. message Text
  62. }
  63. func (m *TheaterPrivMsgCommand) HandleServer(s *Server) {
  64. client := m.Client()
  65. if !m.channel.IsChannel() {
  66. client.ErrNoSuchChannel(m.channel)
  67. return
  68. }
  69. channel := s.channels.Get(m.channel)
  70. if channel == nil {
  71. client.ErrNoSuchChannel(m.channel)
  72. return
  73. }
  74. if !channel.members.HasMode(client, Theater) {
  75. client.Reply(RplNotice(s, client, "you are not +T"))
  76. return
  77. }
  78. reply := RplPrivMsg(TheaterClient(m.asNick), channel, m.message)
  79. for member := range channel.members {
  80. member.Reply(reply)
  81. }
  82. }
  83. type TheaterActionCommand struct {
  84. BaseCommand
  85. channel Name
  86. asNick Name
  87. action CTCPText
  88. }
  89. func (m *TheaterActionCommand) HandleServer(s *Server) {
  90. client := m.Client()
  91. if !m.channel.IsChannel() {
  92. client.ErrNoSuchChannel(m.channel)
  93. return
  94. }
  95. channel := s.channels.Get(m.channel)
  96. if channel == nil {
  97. client.ErrNoSuchChannel(m.channel)
  98. return
  99. }
  100. if !channel.members.HasMode(client, Theater) {
  101. client.Reply(RplNotice(s, client, "you are not +T"))
  102. return
  103. }
  104. reply := RplCTCPAction(TheaterClient(m.asNick), channel, m.action)
  105. for member := range channel.members {
  106. member.Reply(reply)
  107. }
  108. }
  109. */