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.

ModeProcessor.kt 993B

1234567891011121314151617181920212223
  1. package com.dmdirc.ktirc.messages.processors
  2. import com.dmdirc.ktirc.events.ModeChanged
  3. import com.dmdirc.ktirc.messages.RPL_CHANNELMODEIS
  4. import com.dmdirc.ktirc.messages.RPL_UMODEIS
  5. import com.dmdirc.ktirc.model.IrcMessage
  6. internal class ModeProcessor : MessageProcessor {
  7. override val commands = arrayOf(RPL_CHANNELMODEIS, RPL_UMODEIS, "MODE")
  8. override fun process(message: IrcMessage): List<ModeChanged> {
  9. val isDiscovery = message.command == RPL_CHANNELMODEIS || message.command == RPL_UMODEIS
  10. val paramOffset = if (message.command == RPL_CHANNELMODEIS) 1 else 0
  11. return listOf(ModeChanged(
  12. message.metadata,
  13. target = String(message.params[paramOffset]),
  14. modes = String(message.params[paramOffset + 1]),
  15. arguments = message.params.takeLast(message.params.size - paramOffset - 2).map { String(it) }.toTypedArray(),
  16. discovered = isDiscovery))
  17. }
  18. }