telegram: Add option for geo custom URL
patch 505cd255e7a1cea83385a48467c6d1d099b3bc5d
Author: E. Bosch <presidev@AT@gmail.com>
Date: Fri Jul 21 01:12:18 CEST 2023
* telegram: Add option for geo custom URL
diff -rN -u old-irgramd/irgramd new-irgramd/irgramd
--- old-irgramd/irgramd 2024-11-22 11:35:45.031970994 +0100
+++ new-irgramd/irgramd 2024-11-22 11:35:45.031970994 +0100
@@ -74,6 +74,7 @@
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')
+ tornado.options.define('geo_url', type=str, default=None, metavar='TEMPLATE_URL', help='Use custom URL for showing geo latitude/longitude location, eg. OpenStreetMap')
tornado.options.define('hist_timestamp_format', metavar='DATETIME_FORMAT', help='Format string for timestamps in history, see https://www.strfti.me')
tornado.options.define('irc_address', default='127.0.0.1', metavar='ADDRESS', help='Address to listen on for IRC')
tornado.options.define('irc_nicks', type=str, multiple=True, metavar='nick,..', help='List of nicks allowed for IRC, if `pam` and optionally `pam_group` are set, PAM authentication will be used instead')
diff -rN -u old-irgramd/irgramdrc.sample new-irgramd/irgramdrc.sample
--- old-irgramd/irgramdrc.sample 2024-11-22 11:35:45.031970994 +0100
+++ new-irgramd/irgramdrc.sample 2024-11-22 11:35:45.035970987 +0100
@@ -15,3 +15,7 @@
#emoji_ascii=True
hist_timestamp_format='[%m-%d %H:%M]'
#timezone='Europe/Madrid'
+#geo url OpenStreetMap
+#geo_url='https://osm.org/search?query={lat}%20{long}#map=15'
+#geo url Google Maps
+#geo_url='https://maps.google.com/?q={lat},{long}'
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-22 11:35:45.031970994 +0100
+++ new-irgramd/telegram.py 2024-11-22 11:35:45.035970987 +0100
@@ -51,6 +51,7 @@
self.quote_len = settings['quote_length']
self.hist_fmt = settings['hist_timestamp_format']
self.timezone = settings['timezone']
+ self.geo_url = settings['geo_url']
if not settings['emoji_ascii']:
e.emo = {}
self.media_cn = 0
@@ -737,7 +738,12 @@
media_type = 'geo'
caption = ''
to_download = False
- media_url_or_data = 'lat: {}, long: {}'.format(message.media.geo.lat, message.media.geo.long)
+ if self.geo_url:
+ geo_url = ' | ' + self.geo_url
+ else:
+ geo_url = ''
+ lat_long_template = 'lat: {lat}, long: {long}' + geo_url
+ media_url_or_data = lat_long_template.format(lat=message.media.geo.lat, long=message.media.geo.long)
elif message.invoice:
media_type = 'invoice'