patch 3f2611ef2ec2a73f0327df45855e40f04ebb5955
Author: E. Bosch <presidev@AT@gmail.com>
Date: Tue Jul 7 23:15:14 CEST 2026
* Merge pull request #11 on github from Mirochill/fix-9-invalid-escape-warnings
Fix invalid escape warnings
hunk ./emoji2emoticon.py 17
- '\U0001f525': '"\^^^/"',
+ '\U0001f525': r'"\^^^/"',
hunk ./irc.py 31
-VALID_IRC_NICK_FIRST_CHARS = string.ascii_letters + '[]\`_^{|}'
+VALID_IRC_NICK_FIRST_CHARS = string.ascii_letters + r'[]\`_^{|}'
patch 7827ddfc286acd03ba80f6dfef6efed92fc0457a
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Jun 21 23:41:03 CEST 2026
* Update year in copyright notices
hunk ./LICENSE 4
-Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
+Copyright (c) 2020-2026 E. Bosch <presidev@AT@gmail.com>
hunk ./README.md 128
-Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
+Copyright (c) 2020-2026 E. Bosch <presidev@AT@gmail.com>
hunk ./emoji2emoticon.py 4
-# (C) Copyright 2019,2023 E. Bosch <presidev@AT@gmail.com>
+# (C) Copyright 2019,2023,2025 E. Bosch <presidev@AT@gmail.com>
hunk ./exclam.py 4
-# Copyright (c) 2023, 2024 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2023-2025 E. Bosch <presidev@AT@gmail.com>
hunk ./include.py 4
-# Copyright (c) 2020-2022 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
hunk ./irc.py 5
-# Copyright (c) 2020-2023 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
hunk ./service.py 4
-# Copyright (c) 2022,2023 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2022-2024 E. Bosch <presidev@AT@gmail.com>
hunk ./telegram.py 5
-# Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2020-2026 E. Bosch <presidev@AT@gmail.com>
hunk ./utils.py 5
-# Copyright (c) 2020-2024 E. Bosch <presidev@AT@gmail.com>
+# Copyright (c) 2020-2026 E. Bosch <presidev@AT@gmail.com>
patch 6493c04f9d8bdb7b1d2c037fdd66c337a7a91af5
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun May 31 00:26:34 CEST 2026
* utils: Modify sanitize_filename(): convert invalid chars to hex representation,
this makes the filenames deterministic for the same session,
and helps to not download a file more than once
hunk ./utils.py 21
-FILENAME_INVALID_CHARS = re.compile('[/{}<>()"\'\\|&#%?]')
+FILENAME_INVALID_CHARS = re.compile('[\0-\x1F/{}<>"\'\\|*&#%?\x7F]')
hunk ./utils.py 90
- cn = str(sanitize_filename.cn)
- new_fn, ns = FILENAME_INVALID_CHARS.subn(cn, fn)
- if ns:
- sanitize_filename.cn += 1
- return new_fn.strip('-').replace(' ','_')
-sanitize_filename.cn = 0
+ def hexize(m):
+ return '-{:x}-'.format(ord(m.group(0)))
+
+ new_fn = FILENAME_INVALID_CHARS.sub(hexize, fn)
+ return new_fn.lstrip('-').replace(' ','_')
patch dd18dbebc3877faa7fe1c7f1257fb3a4048aab32
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat May 30 22:25:32 CEST 2026
* utils: In add_filename() don't put a final dot if there is no extension in the filename
hunk ./utils.py 101
+ last_dot = '.'
hunk ./utils.py 106
- return '{}-{}.{}'.format(name, add, ext)
+ last_dot = ''
+ return '{}-{}{}{}'.format(name, add, last_dot, ext)
patch feebc9eac596c484be6e5f67934196e64d52beeb
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat May 30 21:33:57 CEST 2026
* telegram: Refactor download media routine
optimized to download files only once
utils: Add session tokens for unnamed files
hunk ./telegram.py 26
-from utils import get_highlighted, fix_braces, format_timestamp, pretty, current_date
+from utils import get_highlighted, fix_braces, format_timestamp, pretty, current_date, token
hunk ./telegram.py 47
+ if self.media_url[-1:] != '/':
+ self.media_url += '/'
hunk ./telegram.py 64
- self.media_cn = 0
+ self.token = token('+0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz')
+ self.filename_token = self.token.gen_token(5)
hunk ./telegram.py 1034
- idd_file = add_filename(filename, mid)
- new_file = sanitize_filename(idd_file)
- new_path = os.path.join(self.telegram_media_dir, new_file)
- if os.path.exists(new_path):
- local_path = new_path
+ aux_file = filename
+ else:
+ if hasattr(message, 'file') and message.file is not None:
+ aux_file = self.filename_token + message.file.ext
hunk ./telegram.py 1039
- await self.notice_downloading(size, relay_attr)
- local_path = await message.download_media(new_path)
- if not local_path: return ''
+ aux_file = self.filename_token
+
+ idd_file = add_filename(aux_file, mid)
+ new_file = sanitize_filename(idd_file)
+ new_path = os.path.join(self.telegram_media_dir, new_file)
+ if os.path.exists(new_path) and (size == 0 or size == os.path.getsize(new_path)):
+ local_path = new_path
hunk ./telegram.py 1048
- local_path = await message.download_media(self.telegram_media_dir)
+ local_path = await message.download_media(new_path)
hunk ./telegram.py 1050
- filetype = os.path.splitext(local_path)[1]
- gen_file = str(self.media_cn) + filetype
- idd_file = add_filename(gen_file, mid)
- new_file = sanitize_filename(idd_file)
- self.media_cn += 1
- new_path = os.path.join(self.telegram_media_dir, new_file)
hunk ./telegram.py 1053
- if self.media_url[-1:] != '/':
- self.media_url += '/'
hunk ./utils.py 17
+import random
hunk ./utils.py 244
+
+class token:
+ def __init__(self, alpha):
+ self.alpha = alpha
+ self.long_alpha = len(alpha)
+
+ def gen_token(self, long_token):
+ if long_token == 1:
+ return self.alpha[random.randrange(self.long_alpha)]
+ else:
+ aux = self.gen_token(long_token - 1)
+ return aux + self.alpha[random.randrange(self.long_alpha)]
patch 4009bc07c6261c0ea2cb1a4112f8aaf266cbd65d
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Jul 26 01:56:12 CEST 2025
* emoji2emoticon: Add emoji "rolling on the floor laughing" to convert to ASCII
hunk ./emoji2emoticon.py 88
+ '\U0001f923': '"X__D"',
patch 10725c4fff915a1c95e95b5f998f26c97b146d5e
Author: E. Bosch <presidev@AT@gmail.com>
Date: Wed Jan 22 00:35:42 CET 2025
* telegram: Try to fix ChatAdminRequiredError when getting participants from a channel
reported in https://github.com/prsai/irgramd/issues/1
hunk ./telegram.py 180
- async for user in self.telegram_client.iter_participants(chat.id):
- user_nick = self.set_ircuser_from_telegram(user)
- if not user.is_self:
- self.irc.irc_channels[chan].add(user_nick)
- # Add admin users as ops in irc
- if isinstance(user.participant, tgty.ChatParticipantAdmin) or \
- isinstance(user.participant, tgty.ChannelParticipantAdmin):
- self.irc.irc_channels_ops[chan].add(user_nick)
- # Add creator users as founders in irc
- elif isinstance(user.participant, tgty.ChatParticipantCreator) or \
- isinstance(user.participant, tgty.ChannelParticipantCreator):
- self.irc.irc_channels_founder[chan].add(user_nick)
+ try:
+ async for user in self.telegram_client.iter_participants(chat.id):
+ user_nick = self.set_ircuser_from_telegram(user)
+ if not user.is_self:
+ self.irc.irc_channels[chan].add(user_nick)
+ # Add admin users as ops in irc
+ if isinstance(user.participant, tgty.ChatParticipantAdmin) or \
+ isinstance(user.participant, tgty.ChannelParticipantAdmin):
+ self.irc.irc_channels_ops[chan].add(user_nick)
+ # Add creator users as founders in irc
+ elif isinstance(user.participant, tgty.ChatParticipantCreator) or \
+ isinstance(user.participant, tgty.ChannelParticipantCreator):
+ self.irc.irc_channels_founder[chan].add(user_nick)
+ except:
+ self.logger.warning('Not possible to get participants of channel %s', channel)