mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
Split --with-channels-and-supergroups into seperate switches --with-channels and --with-supergroups.
This commit is contained in:
parent
b8d9e2a1b6
commit
99574c6e6e
@ -298,8 +298,8 @@ public class CommandLineController {
|
|||||||
System.out.println(" -d, --daemon Keep running and automatically save new messages.");
|
System.out.println(" -d, --daemon Keep running and automatically save new messages.");
|
||||||
System.out.println(" --anonymize (Try to) Remove all sensitive information from output. Useful for requesting support.");
|
System.out.println(" --anonymize (Try to) Remove all sensitive information from output. Useful for requesting support.");
|
||||||
System.out.println(" --stats Print some usage statistics.");
|
System.out.println(" --stats Print some usage statistics.");
|
||||||
System.out.println(" --with-channels-and-supergroups");
|
System.out.println(" --with-channels Backup channels as well.");
|
||||||
System.out.println(" Backup channels and supergroups as well.");
|
System.out.println(" --with-supergroups Backup supergroups as well.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list_accounts() {
|
private void list_accounts() {
|
||||||
|
@ -30,7 +30,8 @@ class CommandLineOptions {
|
|||||||
public static boolean cmd_no_media = false;
|
public static boolean cmd_no_media = false;
|
||||||
public static boolean cmd_anonymize = false;
|
public static boolean cmd_anonymize = false;
|
||||||
public static boolean cmd_stats = false;
|
public static boolean cmd_stats = false;
|
||||||
public static boolean cmd_channels_and_supergroups = false;
|
public static boolean cmd_channels = false;
|
||||||
|
public static boolean cmd_supergroups = false;
|
||||||
|
|
||||||
public static String val_account = null;
|
public static String val_account = null;
|
||||||
public static Integer val_limit_messages = null;
|
public static Integer val_limit_messages = null;
|
||||||
@ -118,8 +119,11 @@ class CommandLineOptions {
|
|||||||
case "--stats":
|
case "--stats":
|
||||||
cmd_stats = true; break;
|
cmd_stats = true; break;
|
||||||
|
|
||||||
case "--with-channels-and-supergroups":
|
case "--with-channels":
|
||||||
cmd_channels_and_supergroups = true; break;
|
cmd_channels = true; break;
|
||||||
|
|
||||||
|
case "--with-supergroups":
|
||||||
|
cmd_supergroups = true; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unknown command " + arg);
|
throw new RuntimeException("Unknown command " + arg);
|
||||||
|
@ -169,11 +169,14 @@ public class DownloadManager {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (CommandLineOptions.cmd_channels_and_supergroups) {
|
if (CommandLineOptions.cmd_channels || CommandLineOptions.cmd_supergroups) {
|
||||||
System.out.println("Processing channels and supergroups...");
|
System.out.println("Processing channels and/or supergroups...");
|
||||||
|
System.out.println("Please note that only channels/supergroups in the last 100 active chats are processed.");
|
||||||
|
|
||||||
HashMap<Integer, Long> channel_access_hashes = new HashMap<Integer, Long>();
|
HashMap<Integer, Long> channel_access_hashes = new HashMap<Integer, Long>();
|
||||||
HashMap<Integer, String> channel_names = new HashMap<Integer, String>();
|
HashMap<Integer, String> channel_names = new HashMap<Integer, String>();
|
||||||
|
LinkedList<Integer> channels = new LinkedList<Integer>();
|
||||||
|
LinkedList<Integer> supergroups = new LinkedList<Integer>();
|
||||||
|
|
||||||
// TODO Add chat title (and other stuff?) to the database
|
// TODO Add chat title (and other stuff?) to the database
|
||||||
for (TLAbsChat c : dialogs.getChats()) {
|
for (TLAbsChat c : dialogs.getChats()) {
|
||||||
@ -181,6 +184,11 @@ public class DownloadManager {
|
|||||||
TLChannel ch = (TLChannel)c;
|
TLChannel ch = (TLChannel)c;
|
||||||
channel_access_hashes.put(c.getId(), ch.getAccessHash());
|
channel_access_hashes.put(c.getId(), ch.getAccessHash());
|
||||||
channel_names.put(c.getId(), ch.getTitle());
|
channel_names.put(c.getId(), ch.getTitle());
|
||||||
|
if (ch.getMegagroup()) {
|
||||||
|
supergroups.add(c.getId());
|
||||||
|
} else {
|
||||||
|
channels.add(c.getId());
|
||||||
|
}
|
||||||
// Channel: TLChannel
|
// Channel: TLChannel
|
||||||
// Supergroup: getMegagroup()==true
|
// Supergroup: getMegagroup()==true
|
||||||
}
|
}
|
||||||
@ -191,6 +199,14 @@ public class DownloadManager {
|
|||||||
for (TLDialog d : dialogs.getDialogs()) {
|
for (TLDialog d : dialogs.getDialogs()) {
|
||||||
if (d.getPeer() instanceof TLPeerChannel) {
|
if (d.getPeer() instanceof TLPeerChannel) {
|
||||||
int channel_id = ((TLPeerChannel)d.getPeer()).getChannelId();
|
int channel_id = ((TLPeerChannel)d.getPeer()).getChannelId();
|
||||||
|
|
||||||
|
// If this is a channel and we don't want to download channels OR
|
||||||
|
// it is a supergroups and we don't want to download supergroups, then
|
||||||
|
if ((channels.contains(channel_id) && !CommandLineOptions.cmd_channels) ||
|
||||||
|
(supergroups.contains(channel_id) && !CommandLineOptions.cmd_supergroups)) {
|
||||||
|
// Skip this chat.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int max_known_id = db.getTopMessageIDForChannel(channel_id);
|
int max_known_id = db.getTopMessageIDForChannel(channel_id);
|
||||||
if (d.getTopMessage() > max_known_id) {
|
if (d.getTopMessage() > max_known_id) {
|
||||||
List<Integer> ids = makeIdList(max_known_id+1, d.getTopMessage());
|
List<Integer> ids = makeIdList(max_known_id+1, d.getTopMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user