patch fa015f3a5b1ea9fe2b6c068491481d57837ecdc5 Author: E. Bosch Date: Sun Apr 14 02:13:34 CEST 2024 * telegram: Use directory ".cache/irgramd/media" instead of ".config/irgramd/media" by default (relative to home directory) Added "cache_dir" option to override the default "~/.cache/irgramd" diff -rN -u old-irgramd/irgramd new-irgramd/irgramd --- old-irgramd/irgramd 2024-11-22 16:08:09.274071580 +0100 +++ new-irgramd/irgramd 2024-11-22 16:08:09.274071580 +0100 @@ -3,7 +3,7 @@ # irgramd: IRC-Telegram gateway - Main file # # Copyright (c) 2019 Peter Bui -# Copyright (c) 2020-2023 E. Bosch +# Copyright (c) 2020-2024 E. Bosch # # Use of this source code is governed by a MIT style license that # can be found in the LICENSE file included in this project. @@ -79,6 +79,7 @@ tornado.options.define('api_hash', default=None, metavar='HASH', help='Telegram API Hash for your account (obtained from https://my.telegram.org/apps)') tornado.options.define('api_id', type=int, default=None, metavar='ID', help='Telegram API ID for your account (obtained from https://my.telegram.org/apps)') tornado.options.define('ask_code', default=False, help='Ask authentication code (sent by Telegram) in console instead of "code" service command in IRC') + tornado.options.define('cache_dir', default='~/.cache/irgramd', metavar='PATH', help='Cache directory where telegram media is saved by default') tornado.options.define('char_in_encoding', default='utf-8', metavar='ENCODING', help='Character input encoding for IRC') tornado.options.define('char_out_encoding', default='utf-8', metavar='ENCODING', help='Character output encoding for IRC') tornado.options.define('config', default='irgramdrc', metavar='CONFIGFILE', help='Config file absolute or relative to `config_dir` (command line options override it)') @@ -94,7 +95,7 @@ tornado.options.define('irc_port', type=int, default=None, metavar='PORT', help='Port to listen on for IRC. (default 6667, default with TLS 6697)') tornado.options.define('log_file', default=None, metavar='PATH', help='File where logs are appended, if not set will be stderr') tornado.options.define('log_level', default='INFO', metavar='DEBUG|INFO|WARNING|ERROR|CRITICAL|NONE', help='The log level (and any higher to it) that will be logged') - tornado.options.define('media_dir', default=None, metavar='PATH', help='Directory where Telegram media files are downloaded, default "media" in `config_dir`') + tornado.options.define('media_dir', default=None, metavar='PATH', help='Directory where Telegram media files are downloaded, default "media" in `cache_dir`') tornado.options.define('media_url', default=None, metavar='BASE_URL', help='Base URL for media files, should be configured in the external (to irgramd) webserver') tornado.options.define('pam', default=False, help='Use PAM for IRC authentication, if not set you should set `irc_password`') tornado.options.define('pam_group', default=None, metavar='GROUP', help='Unix group allowed if `pam` enabled, if empty any user is allowed') diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py --- old-irgramd/telegram.py 2024-11-22 16:08:09.274071580 +0100 +++ new-irgramd/telegram.py 2024-11-22 16:08:09.274071580 +0100 @@ -38,6 +38,7 @@ def __init__(self, irc, settings): self.logger = logging.getLogger() self.config_dir = settings['config_dir'] + self.cache_dir = settings['cache_dir'] self.download = settings['download_media'] self.notice_size = settings['download_notice'] * 1048576 self.media_dir = settings['media_dir'] @@ -72,7 +73,7 @@ async def initialize_telegram(self): # Setup media folder - self.telegram_media_dir = self.media_dir or os.path.join(self.config_dir, 'media') + self.telegram_media_dir = os.path.expanduser(self.media_dir or os.path.join(self.cache_dir, 'media')) if not os.path.exists(self.telegram_media_dir): os.makedirs(self.telegram_media_dir)