mirror of
				https://github.com/fabianonline/telegram_backup.git
				synced 2025-10-28 14:40:04 +00:00 
			
		
		
		
	Added command line switch --list-channels to list channels and supergroups with their ID to add them to black- and whitelists in config.ini
				
					
				
			This commit is contained in:
		| @@ -135,6 +135,31 @@ class CommandLineController { | ||||
| 			} | ||||
| 			logger.info("Initializing Download Manager") | ||||
| 			val d = DownloadManager(client, CommandLineDownloadProgress()) | ||||
| 			 | ||||
| 			if (CommandLineOptions.cmd_list_channels) { | ||||
| 				val chats = d.getChats() | ||||
| 				val print_header = {download: Boolean -> println("%-15s %-40s %s".format("ID", "Title", if (download) "Download" else "")); println("-".repeat(65)) } | ||||
| 				val format = {c: DownloadManager.Channel, download: Boolean -> "%-15s %-40s %s".format(c.id.toString().anonymize(), c.title.anonymize(), if (download) (if(c.download) "YES" else "no") else "")} | ||||
| 				var download: Boolean | ||||
|  | ||||
| 				println("Channels:") | ||||
| 				download = IniSettings.download_channels | ||||
| 				if (!download) println("Download of channels is disabled - see download_channels in config.ini") | ||||
| 				print_header(download) | ||||
| 				for (c in chats.channels) { | ||||
| 					println(format(c, download)) | ||||
| 				} | ||||
| 				println() | ||||
| 				println("Supergroups:") | ||||
| 				download = IniSettings.download_supergroups | ||||
| 				if (!download) println("Download of supergroups is disabled - see download_supergroups in config.ini") | ||||
| 				print_header(download) | ||||
| 				for (c in chats.supergroups) { | ||||
| 					println(format(c, download)) | ||||
| 				} | ||||
| 				System.exit(0) | ||||
| 			} | ||||
| 			 | ||||
| 			logger.debug("Calling DownloadManager.downloadMessages with limit {}", CommandLineOptions.val_limit_messages) | ||||
| 			d.downloadMessages(CommandLineOptions.val_limit_messages) | ||||
| 			logger.debug("IniSettings.download_media: {}", IniSettings.download_media) | ||||
| @@ -283,6 +308,7 @@ class CommandLineController { | ||||
| 		println(" --license             Displays the license of this program.") | ||||
| 		println(" --anonymize           (Try to) Remove all sensitive information from output. Useful for requesting support.") | ||||
| 		println(" --stats               Print some usage statistics.") | ||||
| 		println(" --list-channels       Lists all channels together with their ID") | ||||
| 	} | ||||
|  | ||||
| 	private fun list_accounts() { | ||||
|   | ||||
| @@ -28,6 +28,7 @@ internal object CommandLineOptions { | ||||
| 	var cmd_daemon = false | ||||
| 	var cmd_anonymize = false | ||||
| 	var cmd_stats = false | ||||
| 	var cmd_list_channels = false | ||||
| 	var val_account: String? = null | ||||
| 	var val_limit_messages: Int? = null | ||||
| 	var val_target: String? = null | ||||
| @@ -85,6 +86,7 @@ internal object CommandLineOptions { | ||||
| 				} | ||||
| 				"--anonymize" -> cmd_anonymize = true | ||||
| 				"--stats" -> cmd_stats = true | ||||
| 				"--list-channels" -> cmd_list_channels = true | ||||
| 				else -> throw RuntimeException("Unknown command " + arg) | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user