mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
Fix that old sticker, with an empty sticker set id caused a crash
This commit is contained in:
parent
223a0fdde3
commit
9c1f495782
@ -1,16 +1,16 @@
|
|||||||
/* Telegram_Backup
|
/* Telegram_Backup
|
||||||
* Copyright (C) 2016 Fabian Schlenz
|
* Copyright (C) 2016 Fabian Schlenz
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
@ -56,14 +56,18 @@ import de.fabianonline.telegram_backup.*
|
|||||||
class StickerFileManager(message: JsonObject, file_base: String) : DocumentFileManager(message, file_base) {
|
class StickerFileManager(message: JsonObject, file_base: String) : DocumentFileManager(message, file_base) {
|
||||||
|
|
||||||
override val isSticker = true
|
override val isSticker = true
|
||||||
|
|
||||||
val json = message["media"]["document"].obj
|
val json = message["media"]["document"].obj
|
||||||
val sticker = json["attributes"].array.first{it.obj.isA("documentAttributeSticker")}.obj
|
val sticker = json["attributes"].array.first{it.obj.isA("documentAttributeSticker")}.obj
|
||||||
override var isEmpty = sticker["stickerset"].obj.isA("inputStickerSetEmpty")
|
override var isEmpty = sticker["stickerset"].obj.isA("inputStickerSetEmpty")
|
||||||
|
|
||||||
private val filenameBase: String
|
private val filenameBase: String
|
||||||
get() {
|
get() {
|
||||||
val set = sticker["stickerset"].obj.get("shortName").nullString ?: sticker["stickerset"].obj.get("id").string
|
val stickerSet = sticker["stickerset"].obj
|
||||||
|
val set = stickerSet.get("shortName").nullString
|
||||||
|
?: stickerSet.get("id").nullString
|
||||||
|
?: stickerSet.get("_constructor").nullString
|
||||||
|
?: error("could not get a good name from: ${sticker["stickerset"]}")
|
||||||
val hash = sticker["alt"].string.hashCode()
|
val hash = sticker["alt"].string.hashCode()
|
||||||
return "${set}_${hash}"
|
return "${set}_${hash}"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user