mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
updated telegram schema and fixed bugs with unused methods
This commit is contained in:
parent
223a0fdde3
commit
5161df17eb
@ -31,7 +31,7 @@ compileKotlin {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
|
compile('com.github.badoualy:kotlogram:e3c26c69c2896b6bf3fce539ba0c46debc884e0f') {
|
||||||
exclude module: 'slf4j-simple'
|
exclude module: 'slf4j-simple'
|
||||||
}
|
}
|
||||||
compile 'org.xerial:sqlite-jdbc:3.16.1'
|
compile 'org.xerial:sqlite-jdbc:3.16.1'
|
||||||
@ -41,6 +41,7 @@ dependencies {
|
|||||||
compile 'com.google.code.gson:gson:2.8.0'
|
compile 'com.google.code.gson:gson:2.8.0'
|
||||||
compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
||||||
compile 'com.github.kittinunf.fuel:fuel:1.12.0'
|
compile 'com.github.kittinunf.fuel:fuel:1.12.0'
|
||||||
|
compile 'commons-io:commons-io:2.5'
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class CommandLineController(val options: CommandLineOptions) {
|
|||||||
storage = ApiStorage(file_base)
|
storage = ApiStorage(file_base)
|
||||||
|
|
||||||
logger.info("Creating Client")
|
logger.info("Creating Client")
|
||||||
client = Kotlogram.getDefaultClient(app, storage, Kotlogram.PROD_DC4, null)
|
client = Kotlogram.getDefaultClient(app, storage, null, Kotlogram.PROD_DC4)
|
||||||
|
|
||||||
// From now on we have a new catch-all-block that will terminate it's TelegramClient when an exception happens.
|
// From now on we have a new catch-all-block that will terminate it's TelegramClient when an exception happens.
|
||||||
try {
|
try {
|
||||||
@ -184,7 +184,7 @@ class CommandLineController(val options: CommandLineOptions) {
|
|||||||
handler = TelegramUpdateHandler(user_manager, database, file_base, settings)
|
handler = TelegramUpdateHandler(user_manager, database, file_base, settings)
|
||||||
client.close()
|
client.close()
|
||||||
logger.info("Creating new client")
|
logger.info("Creating new client")
|
||||||
client = Kotlogram.getDefaultClient(app, storage, Kotlogram.PROD_DC4, handler)
|
client = Kotlogram.getDefaultClient(app, storage, handler, Kotlogram.PROD_DC4)
|
||||||
println("DAEMON mode requested - keeping running.")
|
println("DAEMON mode requested - keeping running.")
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
|
@ -269,10 +269,12 @@ class DownloadManager(val client: TelegramClient, val prog: DownloadProgressInte
|
|||||||
if (result) {
|
if (result) {
|
||||||
prog.onMediaDownloaded(m)
|
prog.onMediaDownloaded(m)
|
||||||
} else {
|
} else {
|
||||||
|
logger.trace("onMediaFailed")
|
||||||
prog.onMediaFailed()
|
prog.onMediaFailed()
|
||||||
}
|
}
|
||||||
} catch (e: TimeoutException) {
|
} catch (e: TimeoutException) {
|
||||||
// do nothing - skip this file
|
// do nothing - skip this file
|
||||||
|
logger.trace("TimeoutException onMedia")
|
||||||
prog.onMediaFailed()
|
prog.onMediaFailed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +302,7 @@ class DownloadManager(val client: TelegramClient, val prog: DownloadProgressInte
|
|||||||
var temp: TLAbsDialogs? = null
|
var temp: TLAbsDialogs? = null
|
||||||
logger.trace("Calling messagesGetDialogs with offset {}", offset)
|
logger.trace("Calling messagesGetDialogs with offset {}", offset)
|
||||||
Utils.obeyFloodWait {
|
Utils.obeyFloodWait {
|
||||||
temp = client.messagesGetDialogs(offset, 0, TLInputPeerEmpty(), limit)
|
temp = client.messagesGetDialogs(false, offset, 0, TLInputPeerEmpty(), limit)
|
||||||
}
|
}
|
||||||
val dialogs = temp!!
|
val dialogs = temp!!
|
||||||
val last_message = dialogs.messages.filter{ it is TLMessage || it is TLMessageService }.last()
|
val last_message = dialogs.messages.filter{ it is TLMessage || it is TLMessageService }.last()
|
||||||
@ -369,8 +371,9 @@ class DownloadManager(val client: TelegramClient, val prog: DownloadProgressInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
||||||
fun downloadFile(targetFilename: String, size: Int, dcId: Int, id: Long, accessHash: Long, prog: DownloadProgressInterface?) {
|
fun downloadFile(targetFilename: String, size: Int, dcId: Int, id: Long, accessHash: Long, version: Int = 0, prog: DownloadProgressInterface?) {
|
||||||
val loc = TLInputDocumentFileLocation(id, accessHash)
|
val loc = TLInputDocumentFileLocation(id, accessHash, version)
|
||||||
|
logger.trace("TLInputDocumentFileLocation: {}", loc)
|
||||||
downloadFileFromDc(targetFilename, loc, dcId, size, prog)
|
downloadFileFromDc(targetFilename, loc, dcId, size, prog)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,14 +400,17 @@ class DownloadManager(val client: TelegramClient, val prog: DownloadProgressInte
|
|||||||
if (prog != null) prog.onMediaFileDownloadStarted()
|
if (prog != null) prog.onMediaFileDownloadStarted()
|
||||||
do {
|
do {
|
||||||
logger.trace("offset: {} block_size: {} size: {}", offset, size, size)
|
logger.trace("offset: {} block_size: {} size: {}", offset, size, size)
|
||||||
val req = TLRequestUploadGetFile(loc, offset, size)
|
val req = TLRequestUploadGetFile(loc, offset, 1024*1024)
|
||||||
var resp: TLFile? = null
|
var resp: TLFile? = null
|
||||||
try {
|
try {
|
||||||
Utils.obeyFloodWait() {
|
Utils.obeyFloodWait() {
|
||||||
resp = download_client!!.executeRpcQuery(req, dcID) as TLFile
|
resp = download_client!!.executeRpcQuery(req, dcID) as TLFile
|
||||||
}
|
}
|
||||||
} catch (e: RpcErrorException) {
|
} catch (e: RpcErrorException) {
|
||||||
|
logger.trace("RpcErrorException")
|
||||||
|
logger.trace("{}", e.localizedMessage)
|
||||||
if (e.getCode() == 400) {
|
if (e.getCode() == 400) {
|
||||||
|
logger.trace("code 400")
|
||||||
// Somehow this file is broken. No idea why. Let's skip it for now.
|
// Somehow this file is broken. No idea why. Let's skip it for now.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class LoginManager(val app: TelegramApp, val target_dir: String, val phoneToUse:
|
|||||||
|
|
||||||
// We now have an account, so we can create an ApiStorage and TelegramClient.
|
// We now have an account, so we can create an ApiStorage and TelegramClient.
|
||||||
val storage = ApiStorage(file_base)
|
val storage = ApiStorage(file_base)
|
||||||
val client = Kotlogram.getDefaultClient(app, storage, Kotlogram.PROD_DC4, null)
|
val client = Kotlogram.getDefaultClient(app, storage, null, Kotlogram.PROD_DC4)
|
||||||
|
|
||||||
val sent_code = send_code_to_phone_number(client, phone)
|
val sent_code = send_code_to_phone_number(client, phone)
|
||||||
println("Telegram sent you a code. Please enter it here.")
|
println("Telegram sent you a code. Please enter it here.")
|
||||||
|
@ -75,7 +75,8 @@ open class DocumentFileManager(message: JsonObject, file_base: String) : Abstrac
|
|||||||
|
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
||||||
override fun download(prog: DownloadProgressInterface?): Boolean {
|
override fun download(prog: DownloadProgressInterface?): Boolean {
|
||||||
DownloadManager.downloadFile(targetPathAndFilename, size, json["dcId"].int, json["id"].long, json["accessHash"].long, prog)
|
var version: Int = if (json.contains("version")) json["version"].int else 0
|
||||||
|
DownloadManager.downloadFile(targetPathAndFilename, size, json["dcId"].int, json["id"].long, json["accessHash"].long, version , prog)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ object FileManagerFactory {
|
|||||||
return UnsupportedFileManager(message, file_base, "contact")
|
return UnsupportedFileManager(message, file_base, "contact")
|
||||||
} else if (media.isA("messageMediaVenue")) {
|
} else if (media.isA("messageMediaVenue")) {
|
||||||
return UnsupportedFileManager(message, file_base, "venue")
|
return UnsupportedFileManager(message, file_base, "venue")
|
||||||
|
} else if (media.isA("messageMediaGame")) {
|
||||||
|
return UnsupportedFileManager(message, file_base, "game")
|
||||||
} else {
|
} else {
|
||||||
AbstractMediaFileManager.throwUnexpectedObjectError(media["_constructor"].string)
|
AbstractMediaFileManager.throwUnexpectedObjectError(media["_constructor"].string)
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,10 @@ class StickerFileManager(message: JsonObject, file_base: String) : DocumentFileM
|
|||||||
|
|
||||||
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 set = sticker["stickerset"].obj.get("shortName").nullString ?:
|
||||||
val hash = sticker["alt"].string.hashCode()
|
val hash = sticker["alt"].string.hashCode()
|
||||||
return "${set}_${hash}"
|
//return "${set}_${hash}"
|
||||||
|
return "_${hash}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val targetFilename: String
|
override val targetFilename: String
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{{/is_new_date}}
|
{{/is_new_date}}
|
||||||
<li class="message {{#from_me}}from-me{{/from_me}} {{odd_even}} {{#same_user}}same-user{{/same_user}}" data-message-id="{{message_id}}" data-media="{{media_type}}">
|
<li class="message {{#from_me}}from-me{{/from_me}} {{odd_even}} {{#same_user}}same-user{{/same_user}}" data-message-id="{{message_id}}" data-media="{{media_type}}">
|
||||||
<span class="time">{{formatted_time}}</span>
|
<span class="time">{{formatted_time}}</span>
|
||||||
<span class="sender">{{user_first_name}}</span>
|
<span class="sender">{{user_first_name}} {{#user_last_name}}{{user_last_name}}{{/user_last_name}}</span>
|
||||||
{{#text}}<span class="text">{{text}}</span>{{/text}}
|
{{#text}}<span class="text">{{text}}</span>{{/text}}
|
||||||
{{#media_sticker}}<span class="sticker"><img src="../stickers/{{media_file}}" /></span>{{/media_sticker}}
|
{{#media_sticker}}<span class="sticker"><img src="../stickers/{{media_file}}" /></span>{{/media_sticker}}
|
||||||
{{#media_photo}}<span class="photo"><img src="../{{media_file}}" /></span>{{/media_photo}}
|
{{#media_photo}}<span class="photo"><img src="../{{media_file}}" /></span>{{/media_photo}}
|
||||||
|
Loading…
Reference in New Issue
Block a user