telegram: Add options for API_ID and API_HASH
patch cd15d391cfdd3f1db483a5235ac7233eb912e03e
Author: E. Bosch <presidev@AT@gmail.com>
Date: Wed Feb 16 02:18:10 CET 2022
* telegram: Add options for API_ID and API_HASH
diff -rN -u old-irgramd/irgramd new-irgramd/irgramd
--- old-irgramd/irgramd 2024-11-22 22:56:09.111221490 +0100
+++ new-irgramd/irgramd 2024-11-22 22:56:09.111221490 +0100
@@ -59,6 +59,8 @@
if __name__ == '__main__':
logger = logging.getLogger()
tornado.options.define('address', default=None, metavar='ADDRESS', help='Address to listen on.')
+ 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('config', default='irgramdrc', metavar='CONFIGFILE', help='Config file absolute or relative to `config_dir` (command line options override it)')
tornado.options.define('config_dir', default='~/.config/irgramd', metavar='PATH', help='Configuration directory where telegram session info is saved')
tornado.options.define('irc_nicks', type=str, multiple=True, metavar='nick,..', help='List of nicks allowed for IRC, if `pam` and optionally `pam_group` are set, PAM authentication will be used instead')
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-22 22:56:09.111221490 +0100
+++ new-irgramd/telegram.py 2024-11-22 22:56:09.111221490 +0100
@@ -12,15 +12,6 @@
from irc import IRCUser
from utils import sanitize_filename, remove_slash, remove_http_s, get_human_size, get_human_duration
-# Configuration
-
-# GET API_ID and API_HASH from https://my.telegram.org/apps
-# AND PUT HERE BEFORE RUNNING irgramd
-
-TELEGRAM_API_ID =
-TELEGRAM_API_HASH = ''
-
-
# Telegram
class TelegramHandler(object):
@@ -28,6 +19,8 @@
self.logger = logging.getLogger()
self.config_dir = settings['config_dir']
self.media_url = settings['media_url']
+ self.api_id = settings['api_id']
+ self.api_hash = settings['api_hash']
self.media_cn = 0
self.irc = irc
self.authorized = False
@@ -50,9 +43,7 @@
# Construct Telegram client
telegram_session = os.path.join(self.telegram_session_dir, 'telegram')
- self.telegram_client = telethon.TelegramClient(telegram_session,
- TELEGRAM_API_ID, TELEGRAM_API_HASH
- )
+ self.telegram_client = telethon.TelegramClient(telegram_session, self.api_id, self.api_hash)
# Initialize Telegram ID to IRC nick mapping
self.tid_to_iid = {}