patch 3976770a9424b2085ba1260328b3adb5ce6b1ebe
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Dec 2 20:41:44 CET 2023
* telegram: Add target nick in private messages sent from the self user
from another Telegram client
diff -rN -u old-irgramd/service.py new-irgramd/service.py
--- old-irgramd/service.py 2024-11-22 09:57:01.697404231 +0100
+++ new-irgramd/service.py 2024-11-22 09:57:01.701404225 +0100
@@ -77,10 +77,8 @@
if id == self.tg.id:
name_in_irc = self.tmp_ircnick
else:
- if id in self.tg.tid_to_iid.keys():
- name_in_irc = self.tg.tid_to_iid[id]
- else:
- name_in_irc = '<Unknown>'
+ name_in_irc = self.tg.get_irc_name_from_telegram_id(id)
+
reply += (' {:<11d} {:<9d} {:<9d} {:5} {:<3} {:<4} {:<6} {}'.format(
id, unr, men, ty, pin, arch, last, name_in_irc),
)
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-22 09:57:01.701404225 +0100
+++ new-irgramd/telegram.py 2024-11-22 09:57:01.701404225 +0100
@@ -206,6 +206,13 @@
if nick == self.tg_username: return None
return self.irc.users[nick.lower()]
+ def get_irc_name_from_telegram_id(self, tid):
+ if tid in self.tid_to_iid.keys():
+ name_in_irc = self.tid_to_iid[tid]
+ else:
+ name_in_irc = '<Unknown>'
+ return name_in_irc
+
async def get_irc_name_from_telegram_forward(self, fwd, saved):
from_id = fwd.saved_from_peer if saved else fwd.from_id
if from_id is None:
@@ -578,7 +585,9 @@
else:
refwd_text = ''
- final_text = '[{}] {}{}'.format(mid, refwd_text, text)
+ target_mine = self.handle_target_mine(message.peer_id, user)
+
+ final_text = '[{}] {}{}{}'.format(mid, target_mine, refwd_text, text)
final_text = self.filters(final_text)
return final_text
@@ -823,6 +832,19 @@
text += '\n* ' + ans.text
return text
+ def handle_target_mine(self, target, user):
+ # Add the target of messages sent by self user (me)
+ # received in other clients
+ target_id, target_type = self.get_peer_id_and_type(target)
+ if user is None and target_type == 'user' and target_id != self.id:
+ # self user^
+ # as sender
+ irc_id = self.get_irc_name_from_telegram_id(target_id)
+ target_mine = '[T: {}] '.format(irc_id)
+ else:
+ target_mine = ''
+ return target_mine
+
async def handle_webpage(self, webpage, message):
media_type = 'web'
logo = await self.download_telegram_media(message)