simple code

This commit is contained in:
Benoit Marty 2019-08-05 16:17:38 +02:00
parent 99f4196388
commit 652ac81fa1

View File

@ -302,31 +302,19 @@ data class Event(




fun Event.isTextMessage(): Boolean { fun Event.isTextMessage(): Boolean {
if (this.getClearType() == EventType.MESSAGE) { return getClearType() == EventType.MESSAGE
return getClearContent()?.toModel<MessageContent>()?.let { && when (getClearContent()?.toModel<MessageContent>()?.type) {
when (it.type) { MessageType.MSGTYPE_TEXT,
MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_EMOTE,
MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_NOTICE -> true
MessageType.MSGTYPE_NOTICE -> { else -> false
true
}
else -> false
}
} ?: false
} }
return false
} }


fun Event.isImageMessage(): Boolean { fun Event.isImageMessage(): Boolean {
if (this.getClearType() == EventType.MESSAGE) { return getClearType() == EventType.MESSAGE
return getClearContent()?.toModel<MessageContent>()?.let { && when (getClearContent()?.toModel<MessageContent>()?.type) {
when (it.type) { MessageType.MSGTYPE_IMAGE -> true
MessageType.MSGTYPE_IMAGE -> { else -> false
true
}
else -> false
}
} ?: false
} }
return false
} }