irc: Separate character encoding options as input and output
patch 746b8dec8a7b53ef2750501c320aaa627d5ae7fe
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Jun 11 00:44:55 CEST 2023
* irc: Separate character encoding options as input and output
diff -rN -u old-irgramd/irc.py new-irgramd/irc.py
--- old-irgramd/irc.py 2024-10-23 02:28:42.299736405 +0200
+++ new-irgramd/irc.py 2024-10-23 02:28:42.303736398 +0200
@@ -82,7 +82,7 @@
user.del_from_channels(self)
del user
break
- message = message.decode(self.conf['char_encoding'], errors='replace').replace('\r','\n')
+ message = message.decode(self.conf['char_in_encoding'], errors='replace').replace('\r','\n')
self.logger.debug(message)
for pattern, handler, register_required, num_params_required in self.irc_handlers:
@@ -147,7 +147,7 @@
async def send_irc_command(self, user, command):
self.logger.debug('Send IRC Command: %s', command)
command = command + '\r\n'
- user.stream.write(command.encode(self.conf['char_encoding'], errors='replace'))
+ user.stream.write(command.encode(self.conf['char_out_encoding'], errors='replace'))
# IRC handlers
diff -rN -u old-irgramd/irgramd new-irgramd/irgramd
--- old-irgramd/irgramd 2024-10-23 02:28:42.299736405 +0200
+++ new-irgramd/irgramd 2024-10-23 02:28:42.303736398 +0200
@@ -69,7 +69,8 @@
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('char_encoding', default='utf-8', metavar='ENCODING', help='Character encoding for IRC')
+ 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)')
tornado.options.define('config_dir', default='~/.config/irgramd', metavar='PATH', help='Configuration directory where telegram session info is saved')
tornado.options.define('emoji_ascii', default=False, help='Replace emoji with ASCII emoticons')