[SVN] bump to version 0.2.1

[UPD] roster exchange (XEP-0144) now is not mandatory since not all clients supports it; it is optional and configurable
This commit is contained in:
annelin
2018-06-19 19:29:49 +00:00
parent 55f85db5d1
commit c16faf8e4e
3 changed files with 19 additions and 6 deletions

View File

@@ -10,6 +10,8 @@ CONFIG = {
'server': 'localhost', 'server': 'localhost',
'port': '8889', 'port': '8889',
'xmpp_use_roster_exchange': True, # use XEP-0144 to import roster from Telegram
'tg_api_id': '17349', # Telegram Desktop (GitHub) 'tg_api_id': '17349', # Telegram Desktop (GitHub)
'tg_api_hash': '344583e45741c457fe1862106095a5eb', 'tg_api_hash': '344583e45741c457fe1862106095a5eb',

View File

@@ -427,9 +427,7 @@ class TelegramGateClient(TelegramClient):
# group converted to supergroup # group converted to supergroup
elif type(message.action) in [MessageActionChatMigrateTo, MessageActionChannelMigrateFrom]: elif type(message.action) in [MessageActionChatMigrateTo, MessageActionChannelMigrateFrom]:
print('--ACHTUNG!--') pass
print(message)
#del(self.xmpp_gate.tg_dialogs[self.jid]['groups'][message.chat_id])
return msg return msg

View File

@@ -433,7 +433,18 @@ class XMPPTelegram(ComponentXMPP):
rawxml = rawxml + "</x>" rawxml = rawxml + "</x>"
message.appendxml(ET.fromstring(rawxml)) message.appendxml(ET.fromstring(rawxml))
return message self.send(message)
def roster_fill(self, tojid, contacts):
for jid, nick in contacts.items():
presence = sleekxmpp.Presence()
presence['from'] = jid
presence['to'] = tojid
presence['type'] = 'subscribe'
presence.appendxml(ET.fromstring("<nick xmlns='http://jabber.org/protocol/nick'>%s</nick>" % nick))
self.send(presence)
def tg_process_dialogs(self, jid): def tg_process_dialogs(self, jid):
@@ -549,8 +560,10 @@ class XMPPTelegram(ComponentXMPP):
self.send_presence(pto=jid, pfrom=c_jid) self.send_presence(pto=jid, pfrom=c_jid)
if len(dlgs.dialogs) == 0: # Если все диалоги получены - прерываем цикл if len(dlgs.dialogs) == 0: # Если все диалоги получены - прерываем цикл
rosterxchange = self.roster_exchange(jid, self.contact_list[jid]) if self.config['xmpp_use_roster_exchange']:
self.send(rosterxchange) self.roster_exchange(jid, self.contact_list[jid])
else:
self.roster_fill(jid, self.contact_list[jid])
break break
else: # Иначе строим оффсеты else: # Иначе строим оффсеты
last_msg_id = dlgs.dialogs[-1].top_message # Нужен последний id сообщения. Наркоманы. last_msg_id = dlgs.dialogs[-1].top_message # Нужен последний id сообщения. Наркоманы.