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 880B

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