Refactor TelegramHelper#addNewMessage
This commit is contained in:
parent
36cfa5d42d
commit
4ca99c10ee
1 changed files with 6 additions and 5 deletions
|
@ -481,13 +481,14 @@ class TelegramHelper private constructor() {
|
||||||
|
|
||||||
private fun addNewMessage(message: TdApi.Message) {
|
private fun addNewMessage(message: TdApi.Message) {
|
||||||
if (message.isAppropriate()) {
|
if (message.isAppropriate()) {
|
||||||
|
val fromBot = isOsmAndBot(message.senderUserId)
|
||||||
|
val viaBot = isOsmAndBot(message.viaBotUserId)
|
||||||
val oldContent = message.content
|
val oldContent = message.content
|
||||||
if (oldContent is TdApi.MessageText) {
|
if (oldContent is TdApi.MessageText) {
|
||||||
val messageOsmAndBotLocation = parseOsmAndBotLocation(oldContent.text.text)
|
message.content = parseOsmAndBotLocation(oldContent.text.text).apply {
|
||||||
messageOsmAndBotLocation.created = message.date
|
created = message.date
|
||||||
message.content = messageOsmAndBotLocation
|
}
|
||||||
} else if (oldContent is TdApi.MessageLocation &&
|
} else if (oldContent is TdApi.MessageLocation && (fromBot || viaBot)) {
|
||||||
(isOsmAndBot(message.senderUserId) || isOsmAndBot(message.viaBotUserId))) {
|
|
||||||
message.content = parseOsmAndBotLocation(message)
|
message.content = parseOsmAndBotLocation(message)
|
||||||
}
|
}
|
||||||
removeOldMessages(message.senderUserId, message.chatId)
|
removeOldMessages(message.senderUserId, message.chatId)
|
||||||
|
|
Loading…
Reference in a new issue