patch 712de2f8a9af0ab75b8b3f05f7564e1987fe0453 Author: E. Bosch Date: Fri Mar 18 20:57:45 CET 2022 * irc: Add character encoding selection diff -rN -u old-irgramd/irc.py new-irgramd/irc.py --- old-irgramd/irc.py 2024-11-22 21:49:29.069569308 +0100 +++ new-irgramd/irc.py 2024-11-22 21:49:29.069569308 +0100 @@ -82,7 +82,7 @@ user.del_from_channels(self) del user break - message = message.decode().replace('\r','\n') + message = message.decode(self.conf['char_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()) + user.stream.write(command.encode(self.conf['char_encoding'], errors='replace')) # IRC handlers diff -rN -u old-irgramd/irgramd new-irgramd/irgramd --- old-irgramd/irgramd 2024-11-22 21:49:29.069569308 +0100 +++ new-irgramd/irgramd 2024-11-22 21:49:29.069569308 +0100 @@ -69,6 +69,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('char_encoding', default='utf-8', metavar='ENCODING', help='Character 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('irc_address', default='127.0.0.1', metavar='ADDRESS', help='Address to listen on for IRC')