mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
Rewrote Utils.anonymize(String) to String.anonymize().
This commit is contained in:
parent
9bee01698f
commit
ab6a30c48e
@ -88,7 +88,7 @@ class CommandLineController {
|
||||
}
|
||||
if (account != null && user.loggedIn) {
|
||||
if (account != "+" + user.user!!.getPhone()) {
|
||||
logger.error("Account: {}, user.user!!.getPhone(): +{}", Utils.anonymize(account), Utils.anonymize(user.user!!.getPhone()))
|
||||
logger.error("Account: {}, user.user!!.getPhone(): +{}", account.anonymize(), user.user!!.getPhone().anonymize())
|
||||
throw RuntimeException("Account / User mismatch")
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ class CommandLineController {
|
||||
}
|
||||
}
|
||||
if (user.loggedIn) {
|
||||
System.out.println("You are logged in as " + Utils.anonymize(user.userString))
|
||||
System.out.println("You are logged in as ${user.userString.anonymize()}")
|
||||
} else {
|
||||
println("You are not logged in.")
|
||||
System.exit(1)
|
||||
@ -164,12 +164,12 @@ class CommandLineController {
|
||||
}
|
||||
|
||||
private fun setupFileBase() {
|
||||
logger.debug("Target dir at startup: {}", Utils.anonymize(Config.FILE_BASE))
|
||||
logger.debug("Target dir at startup: {}", Config.FILE_BASE.anonymize())
|
||||
if (CommandLineOptions.val_target != null) {
|
||||
Config.FILE_BASE = CommandLineOptions.val_target!!
|
||||
}
|
||||
logger.debug("Target dir after options: {}", Utils.anonymize(Config.FILE_BASE))
|
||||
System.out.println("Base directory for files: " + Utils.anonymize(Config.FILE_BASE))
|
||||
logger.debug("Target dir after options: {}", Config.FILE_BASE.anonymize())
|
||||
System.out.println("Base directory for files: " + Config.FILE_BASE.anonymize())
|
||||
}
|
||||
|
||||
private fun selectAccount(): String? {
|
||||
@ -179,11 +179,11 @@ class CommandLineController {
|
||||
logger.debug("Login requested, doing nothing.")
|
||||
// do nothing
|
||||
} else if (CommandLineOptions.val_account != null) {
|
||||
logger.debug("Account requested: {}", Utils.anonymize(CommandLineOptions.val_account!!))
|
||||
logger.debug("Account requested: {}", CommandLineOptions.val_account!!.anonymize())
|
||||
logger.trace("Checking accounts for match.")
|
||||
var found = false
|
||||
for (acc in accounts) {
|
||||
logger.trace("Checking {}", Utils.anonymize(acc))
|
||||
logger.trace("Checking {}", acc.anonymize())
|
||||
if (acc == CommandLineOptions.val_account) {
|
||||
found = true
|
||||
logger.trace("Matches.")
|
||||
@ -191,7 +191,7 @@ class CommandLineController {
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
show_error("Couldn't find account '" + Utils.anonymize(CommandLineOptions.val_account!!) + "'. Maybe you want to use '--login' first?")
|
||||
show_error("Couldn't find account '" + CommandLineOptions.val_account!!.anonymize() + "'. Maybe you want to use '--login' first?")
|
||||
}
|
||||
account = CommandLineOptions.val_account!!
|
||||
} else if (accounts.size == 0) {
|
||||
@ -200,7 +200,7 @@ class CommandLineController {
|
||||
return null
|
||||
} else if (accounts.size == 1) {
|
||||
account = accounts.firstElement()
|
||||
System.out.println("Using only available account: " + Utils.anonymize(account))
|
||||
System.out.println("Using only available account: " + account.anonymize())
|
||||
} else {
|
||||
show_error(("You didn't specify which account to use.\n" +
|
||||
"Use '--account <x>' to use account <x>.\n" +
|
||||
@ -208,7 +208,7 @@ class CommandLineController {
|
||||
System.exit(1)
|
||||
}
|
||||
logger.debug("accounts.size: {}", accounts.size)
|
||||
logger.debug("account: {}", Utils.anonymize(account))
|
||||
logger.debug("account: {}", account.anonymize())
|
||||
return account
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ class CommandLineController {
|
||||
user.verifyPassword(pw)
|
||||
}
|
||||
storage.setPrefix("+" + user.user!!.getPhone())
|
||||
System.out.println("Everything seems fine. Please run this tool again with '--account +" + Utils.anonymize(user.user!!.getPhone()) + " to use this account.")
|
||||
System.out.println("Everything seems fine. Please run this tool again with '--account +" + user.user!!.getPhone().anonymize() + " to use this account.")
|
||||
}
|
||||
|
||||
private fun show_help() {
|
||||
@ -284,7 +284,7 @@ class CommandLineController {
|
||||
val accounts = Utils.getAccounts()
|
||||
if (accounts.size > 0) {
|
||||
for (str in accounts) {
|
||||
System.out.println(" " + Utils.anonymize(str))
|
||||
System.out.println(" " + str.anonymize())
|
||||
}
|
||||
println("Use '--account <x>' to use one of those accounts.")
|
||||
} else {
|
||||
|
@ -18,6 +18,7 @@ package de.fabianonline.telegram_backup
|
||||
|
||||
import de.fabianonline.telegram_backup.DownloadProgressInterface
|
||||
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager
|
||||
import de.fabianonline.telegram_backup.Utils
|
||||
|
||||
internal class CommandLineDownloadProgress : DownloadProgressInterface {
|
||||
private var mediaCount = 0
|
||||
@ -28,7 +29,7 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
|
||||
if (source == null) {
|
||||
System.out.println("Downloading $count messages.")
|
||||
} else {
|
||||
System.out.println("Downloading " + count + " messages from " + Utils.anonymize(source))
|
||||
System.out.println("Downloading " + count + " messages from " + source.anonymize())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,8 @@ object Utils {
|
||||
logger.debug("We couldn't find a real difference, so we're assuming the versions are equal-ish.")
|
||||
return VERSIONS_EQUAL
|
||||
}
|
||||
|
||||
fun anonymize(str: String): String {
|
||||
return if (!CommandLineOptions.cmd_anonymize) str else str.replace("[0-9]".toRegex(), "1").replace("[A-Z]".toRegex(), "A").replace("[a-z]".toRegex(), "a") + " (ANONYMIZED)"
|
||||
}
|
||||
}
|
||||
|
||||
fun String.anonymize(): String {
|
||||
return if (!CommandLineOptions.cmd_anonymize) this else this.replace(Regex("[0-9]"), "1").replace(Regex("[A-Z]"), "A").replace(Regex("[a-z]"), "a") + " (ANONYMIZED)"
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package de.fabianonline.telegram_backup.exporter
|
||||
|
||||
import de.fabianonline.telegram_backup.UserManager
|
||||
import de.fabianonline.telegram_backup.Database
|
||||
import de.fabianonline.telegram_backup.Utils
|
||||
import de.fabianonline.telegram_backup.anonymize
|
||||
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
@ -100,7 +100,7 @@ class HTMLExporter {
|
||||
println("Generating ${dialogs.size} dialog pages...")
|
||||
for (d in dialogs) {
|
||||
i++
|
||||
logger.trace("Dialog {}/{}: {}", i, dialogs.size, Utils.anonymize("" + d.id))
|
||||
logger.trace("Dialog {}/{}: {}", i, dialogs.size, d.id.toString().anonymize())
|
||||
val messages = db.getMessagesForExport(d)
|
||||
scope.clear()
|
||||
scope.put("user", user)
|
||||
@ -126,7 +126,7 @@ class HTMLExporter {
|
||||
println("Generating ${chats.size} chat pages...")
|
||||
for (c in chats) {
|
||||
i++
|
||||
logger.trace("Chat {}/{}: {}", i, chats.size, Utils.anonymize("" + c.id))
|
||||
logger.trace("Chat {}/{}: {}", i, chats.size, c.id.toString().anonymize())
|
||||
val messages = db.getMessagesForExport(c)
|
||||
scope.clear()
|
||||
scope.put("user", user)
|
||||
@ -164,7 +164,7 @@ class HTMLExporter {
|
||||
|
||||
@Throws(FileNotFoundException::class)
|
||||
private fun getWriter(filename: String): OutputStreamWriter {
|
||||
logger.trace("Creating writer for file {}", Utils.anonymize(filename))
|
||||
logger.trace("Creating writer for file {}", filename.anonymize())
|
||||
return OutputStreamWriter(FileOutputStream(filename), Charset.forName("UTF-8").newEncoder())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user