[SVN] release 0.3.4
[FIX] corrext exception handling when uploading media; if exception caught— we will just send link as plaintext
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
from xmpp_tg.xmpp import XMPPTelegram
|
||||
|
||||
__version__ = '0.3.3'
|
||||
__version__ = '0.3.4'
|
||||
|
||||
@@ -146,14 +146,20 @@ class XMPPTelegram(ComponentXMPP):
|
||||
tg_peer = InputPeerChannel(tg_id, self.tg_dialogs[jid]['supergroups'][tg_id].access_hash)
|
||||
|
||||
if tg_peer:
|
||||
result = None
|
||||
|
||||
# detect media
|
||||
if msg.startswith('http') and re.match(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg):
|
||||
urls = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg)
|
||||
message = msg.replace(urls[0], '')
|
||||
media = InputMediaPhotoExternal(urls[0])
|
||||
try:
|
||||
result = self.tg_connections[jid].invoke(SendMediaRequest(tg_peer, media, message, random_id = generate_random_long(), reply_to_msg_id = reply_mid))
|
||||
# no media — plain message #
|
||||
else:
|
||||
except Exception:
|
||||
print('Media upload failed.')
|
||||
|
||||
# media send failed. #
|
||||
if not result:
|
||||
result = self.tg_connections[jid].invoke(SendMessageRequest(tg_peer, msg, generate_random_long(), reply_to_msg_id=reply_mid))
|
||||
|
||||
msg_id = None
|
||||
|
||||
Reference in New Issue
Block a user