telegram-history-dump icon indicating copy to clipboard operation
telegram-history-dump copied to clipboard

ruby problem?

Open rsa4046 opened this issue 7 years ago • 1 comments

Thanks for extending telegram functionality. I have Gentoo/Funtoo Linux build. Ruby info is

$ ruby --version
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

I start telegram-cli in a gnome-terminal window:

$ telegram-cli --json -P 9009
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/home/rolf/.telegram-cli]
>

However, at the command line of a separate gnome-terminal window I only produce an apparent ruby error:

$ ~/build/telegram-history-dump/telegram-history-dump.rb --config=~/build/telegram-history-dump/config.yaml 
/usr/lib64/ruby/2.3.0/psych.rb:474:in `initialize': No such file or directory @ rb_sysopen - ~/build/telegram-history-dump/config.yaml (Errno::ENOENT)
	from /usr/lib64/ruby/2.3.0/psych.rb:474:in `open'
	from /usr/lib64/ruby/2.3.0/psych.rb:474:in `load_file'
	from /home/rolf/build/telegram-history-dump/telegram-history-dump.rb:265:in `<main>'

Can you point to what am doing wrong? Here is config.yaml:

---

  ## Backup targets ##
  #
  # Array of strings for each category
  # Strings can be either a (partial) name or a telegram-cli "peer_id" value
  # An empty array means "everything in this category"
  # An array containing only null means "nothing in this category"

  # Array of user dialogs to backup
  backup_users: [

  ]

  # Array of group dialogs to backup
  backup_groups: [

  ]

  # Array of supergroup dialogs to backup
  backup_supergroups: [
    null
  ]

  # Array of broadcast channels to backup
  # WARNING: using this can cause a crash when a channel has too many messages
  # to fit in a single chunk (see https://github.com/vysheng/tg/issues/947)
  backup_channels: [
    null
  ]

  # By default telegram-cli returns only the first 100 dialogs/channels
  # We increase this to 1000. If you have even more, increase this value
  maximum_dialogs: 10000


  ## Output options ##

  # Formatters export the JSON output to a different format
  # To enable a formatter, uncomment it along with all of its options
  # If no formatters are enabled, only JSON files are produced
  formatters: {
  #  plaintext: {
  #    date_format: '%Y-%m-%d %H:%M:%S'
  #  },
  #  bare: {},
  #  pisg: {},
  #  html: {
  #    paginate: 1500, # messages per page
  #    use_utc_time: false,
  #    timestamps_every: 50, # messages
  #    loop_video: true, # loop and autoplay videos
  #  },
  }

  # Target directory for the backup files
  # If this is a relative path it will be relative to the script's directory
  # Absolute path starts with '/' or '~'
  backup_dir: '~/private/telegram/output'

  # Data file naming style:
  # True for "My_Chat_Name.jsonl", false for "193044.jsonl" (fixed id)
  friendly_data_filenames: true

  # True to rename data files when their name changes
  # For example, "My_Chat_Name.jsonl" is renamed to "WhoChangedTheTitle.jsonl"
  update_data_filenames: true

  # Maximum number of messages to backup for each target (0 means unlimited)
  backlog_limit: 0

  # At the time of writing, telegram-cli does not properly detect audio/video
  # These will be recognized as documents instead
  # Stickers are also considered documents
  download_media: {
    photo: true,
    document: true,
    audio: true,
    video: true,
  }

  # False to reference downloaded files in the telegram-cli cache
  # True to copy downloaded media to a dedicated directory per dialog
  copy_media: true

  # True to delete media files from telegram-cli cache right after downloading
  # Effectively turns copy_media into move_media
  # Beware: this will cause media files to be redownloaded every backup run
  delete_media: false

  # When a user's real name is formatted, include their last name if possible
  display_last_name: true


  ## Technical options ##

  # Use a unix socket to communicate with telegram-cli
  # Should match the path passed to telegram-cli with the -S option
  #
  # NB: Setting tg_sock to some not false value will cause the script
  # to ignore the next options about TCP connection

  # tg_sock: "/var/run/telegram.sock"
  tg_sock: null

  # Address of the machine you are running telegram-cli on
  # If this is not localhost telegram-cli must be invoked with --accept-any-tcp
  tg_host: 'localhost'

  # Should match the port passed to telegram-cli with the -P option
  tg_port: 9009

  # Number of messages to request in one chunk
  chunk_size: 100

  # Time in seconds to wait between requesting chunks
  chunk_delay: 1.0

  # Time in seconds to wait before considering a request stuck (0 = infinite)
  chunk_timeout: 10

  # Number of times to retry getting one chunk
  chunk_retry: 3

  # Time in seconds to wait before considering a download stuck (0 = infinite)
  # After this time the script skips to the next message
  media_timeout: 100


  ## Advanced behavior settings ##

  # Enables incremental backups (progress is tracked in <outdir>/progress.json)
  # Setting this to false will force a complete re-run of the backup every time
  track_progress: true

  # Replacement string for the characters in dialog names which are potentially
  # problematic in filenames
  # You can set this to '' if the dialog names are unique enough
  character_substitute: '_'

  # Skip messages if their text matches this Ruby regex
  # Example: '/forbidden|words/i'
  filter_regex: null

rsa4046 avatar Mar 22 '17 11:03 rsa4046

Perhaps an absolute path to the config file? I don't even specify it though and it just works. Perhaps leave the argument for it out and just have the config in the same folder as the .rb file.

hbh7 avatar Jul 03 '18 04:07 hbh7