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.

BatchProcessor.kt 752B

12345678910111213141516171819202122
  1. package com.dmdirc.ktirc.messages
  2. import com.dmdirc.ktirc.events.BatchFinished
  3. import com.dmdirc.ktirc.events.BatchStarted
  4. import com.dmdirc.ktirc.events.IrcEvent
  5. import com.dmdirc.ktirc.model.IrcMessage
  6. internal class BatchProcessor : MessageProcessor {
  7. override val commands = arrayOf("BATCH")
  8. override fun process(message: IrcMessage): List<IrcEvent> {
  9. val args = message.params.map { String(it) }
  10. val id = args[0]
  11. return when (id[0]) {
  12. '+' -> listOf(BatchStarted(message.metadata, id.substring(1), args[1], args.subList(2, args.size).toTypedArray()))
  13. '-' -> listOf(BatchFinished(message.metadata, id.substring(1)))
  14. else -> emptyList()
  15. }
  16. }
  17. }