From 91b0720f92971c97bf940e0afbba9bd54618806a Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Wed, 25 Jun 2025 00:03:27 +0800 Subject: [PATCH 1/6] feat: add baidu map button --- efb_telegram_master/slave_message.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index 8c4e9eeb..e68b51e2 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -783,6 +783,12 @@ def slave_message_location(self, msg: Message, tg_dest: TelegramChatID, msg_temp self.logger.debug("[%s] updated target_msg_id %s", msg.uid, target_msg_id) location_reply_markup = self.build_chat_info_inline_keyboard(msg, msg_template, reactions, reply_markup) + name = html.escape(msg.text) + content = html.escape(msg.author.long_name) + url = f'https://api.map.baidu.com/marker?title={name}&content={content}&location={attributes.latitude},{attributes.longitude}&output=html&coord_type=gcj02' + # gaode require login on pc + # url = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1' + location_reply_markup.inline_keyboard = location_reply_markup.inline_keyboard + [[InlineKeyboardButton(f'Open {msg.text} in Baidu Map', url=url)]] # TODO: Use live location if possible? Lift live location messages to EFB Framework? return self.bot.send_location(tg_dest, latitude=attributes.latitude, From c8cd7d76e37c5998cdc952ec78a7e1ecf9814f4f Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Wed, 25 Jun 2025 09:19:20 +0800 Subject: [PATCH 2/6] feat: add gaode map button --- .../locale/zh_CN/LC_MESSAGES/efb_telegram_master.po | 8 ++++++++ efb_telegram_master/slave_message.py | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po b/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po index e017d6a0..ad7b87b7 100644 --- a/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po +++ b/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po @@ -45,6 +45,14 @@ msgstr "[已编辑]" msgid "(unsupported)" msgstr "(不支持)" +#: efb_telegram_master/slave_message.py:880 +msgid "Baidu" +msgstr "百度地图" + +#: efb_telegram_master/slave_message.py:880 +msgid "Gaode" +msgstr "高德地图" + #: efb_telegram_master/slave_message.py:919 #: efb_telegram_master/master_message.py:310 #: efb_telegram_master/master_message.py:312 diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index e68b51e2..394b82bb 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -785,10 +785,12 @@ def slave_message_location(self, msg: Message, tg_dest: TelegramChatID, msg_temp location_reply_markup = self.build_chat_info_inline_keyboard(msg, msg_template, reactions, reply_markup) name = html.escape(msg.text) content = html.escape(msg.author.long_name) - url = f'https://api.map.baidu.com/marker?title={name}&content={content}&location={attributes.latitude},{attributes.longitude}&output=html&coord_type=gcj02' + baidu = f'https://api.map.baidu.com/marker?title={name}&content={content}&location={attributes.latitude},{attributes.longitude}&output=html&coord_type=gcj02' # gaode require login on pc - # url = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1' - location_reply_markup.inline_keyboard = location_reply_markup.inline_keyboard + [[InlineKeyboardButton(f'Open {msg.text} in Baidu Map', url=url)]] + gaode = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1' + location_reply_markup.inline_keyboard = location_reply_markup.inline_keyboard + [ + [InlineKeyboardButton(self._('Baidu'), url=baidu), InlineKeyboardButton(self._('Gaode'), url=gaode)], + ] # TODO: Use live location if possible? Lift live location messages to EFB Framework? return self.bot.send_location(tg_dest, latitude=attributes.latitude, From 72edfed1989ac60e399dbb2eeb0bbfeb6b2882ef Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Wed, 25 Jun 2025 17:20:03 +0800 Subject: [PATCH 3/6] feat: add tencent map button --- efb_telegram_master/slave_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index 394b82bb..ab496759 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -788,8 +788,9 @@ def slave_message_location(self, msg: Message, tg_dest: TelegramChatID, msg_temp baidu = f'https://api.map.baidu.com/marker?title={name}&content={content}&location={attributes.latitude},{attributes.longitude}&output=html&coord_type=gcj02' # gaode require login on pc gaode = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1' + tencent = f'https://apis.map.qq.com/uri/v1/marker?marker=coord:{attributes.latitude},{attributes.longitude};title:{content};addr:{name}' location_reply_markup.inline_keyboard = location_reply_markup.inline_keyboard + [ - [InlineKeyboardButton(self._('Baidu'), url=baidu), InlineKeyboardButton(self._('Gaode'), url=gaode)], + [InlineKeyboardButton(self._('Baidu'), url=baidu), InlineKeyboardButton(self._('Gaode'), url=gaode), InlineKeyboardButton(self._('Tencent'), url=tencent)], ] # TODO: Use live location if possible? Lift live location messages to EFB Framework? From 22a4a3f91a04e3eaef645cd310963dc5950b9d42 Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Tue, 15 Jul 2025 15:02:57 +0800 Subject: [PATCH 4/6] feat: add i18n for Tencent --- .../locale/zh_CN/LC_MESSAGES/efb_telegram_master.po | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po b/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po index ad7b87b7..f7890127 100644 --- a/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po +++ b/efb_telegram_master/locale/zh_CN/LC_MESSAGES/efb_telegram_master.po @@ -45,14 +45,18 @@ msgstr "[已编辑]" msgid "(unsupported)" msgstr "(不支持)" -#: efb_telegram_master/slave_message.py:880 +#: efb_telegram_master/slave_message.py:793 msgid "Baidu" msgstr "百度地图" -#: efb_telegram_master/slave_message.py:880 +#: efb_telegram_master/slave_message.py:793 msgid "Gaode" msgstr "高德地图" +#: efb_telegram_master/slave_message.py:793 +msgid "Tencent" +msgstr "腾讯地图" + #: efb_telegram_master/slave_message.py:919 #: efb_telegram_master/master_message.py:310 #: efb_telegram_master/master_message.py:312 From 39d86fafc19b6685ad3e9039ce7c2069c396db25 Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Wed, 23 Jul 2025 11:00:31 +0800 Subject: [PATCH 5/6] fix: fix baidu bug --- efb_telegram_master/slave_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index ab496759..2acb96c9 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -785,7 +785,7 @@ def slave_message_location(self, msg: Message, tg_dest: TelegramChatID, msg_temp location_reply_markup = self.build_chat_info_inline_keyboard(msg, msg_template, reactions, reply_markup) name = html.escape(msg.text) content = html.escape(msg.author.long_name) - baidu = f'https://api.map.baidu.com/marker?title={name}&content={content}&location={attributes.latitude},{attributes.longitude}&output=html&coord_type=gcj02' + baidu = f'https://api.map.baidu.com/marker?location={attributes.latitude},{attributes.longitude}&title={name}&content={content}&output=html&coord_type=gcj02' # gaode require login on pc gaode = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1' tencent = f'https://apis.map.qq.com/uri/v1/marker?marker=coord:{attributes.latitude},{attributes.longitude};title:{content};addr:{name}' From 8a922923c8b3cf694d36cb05ca8f9241be286680 Mon Sep 17 00:00:00 2001 From: jiz4oh Date: Mon, 10 Nov 2025 16:54:31 +0800 Subject: [PATCH 6/6] fix: fix url encode --- efb_telegram_master/slave_message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index 2acb96c9..dc5bdd67 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -783,8 +783,8 @@ def slave_message_location(self, msg: Message, tg_dest: TelegramChatID, msg_temp self.logger.debug("[%s] updated target_msg_id %s", msg.uid, target_msg_id) location_reply_markup = self.build_chat_info_inline_keyboard(msg, msg_template, reactions, reply_markup) - name = html.escape(msg.text) - content = html.escape(msg.author.long_name) + name = urllib.parse.quote(html.escape(msg.text)) + content = urllib.parse.quote(html.escape(msg.author.long_name)) baidu = f'https://api.map.baidu.com/marker?location={attributes.latitude},{attributes.longitude}&title={name}&content={content}&output=html&coord_type=gcj02' # gaode require login on pc gaode = f'https://uri.amap.com/marker?position={attributes.longitude},{attributes.latitude}&name={name}&coordinate=gaode&callnative=1'