list roster via chat and fix media

This commit is contained in:
Yannik Enss
2019-02-26 14:02:02 +01:00
parent 5dc406c261
commit 4fa79b0010

View File

@@ -147,7 +147,7 @@ class XMPPTelegram(ComponentXMPP):
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])
media = InputMediaPhotoExternal(urls[0], "Image")
try:
result = self.tg_connections[jid].invoke(SendMediaRequest(tg_peer, media, message, random_id = generate_random_long(), reply_to_msg_id = reply_mid))
except Exception:
@@ -283,6 +283,8 @@ class XMPPTelegram(ComponentXMPP):
'!name first last - Change your name in Telegram\n'
'!about text - Change about text in Telegram\n'
'!username - Changes your @username in Telegram\n'
'!roster - Lists yout TG roster\n\n'
)
elif parsed[0] == '!configure':
config_exclude = ['jid', 'tg_phone']
@@ -414,6 +416,9 @@ class XMPPTelegram(ComponentXMPP):
contact = InputPhoneContact(client_id=generate_random_long(), phone=phone, first_name=firstname, last_name=lastname)
self.tg_connections[jid].invoke(ImportContactsRequest([contact]))
self.tg_process_dialogs(jid)
elif parsed[0] == '!roster': # create new channel
self.gate_reply_message(iq, str(self.contact_list[jid]))
else: # --------------------------------------------------
self.gate_reply_message(iq, 'Unknown command. Try !help for list all commands.')