restructure
This commit is contained in:
@@ -4,6 +4,7 @@ import logging, traceback, pprint
|
||||
|
||||
from sleekxmpp.componentxmpp import ComponentXMPP
|
||||
from sleekxmpp import Presence, Message
|
||||
from sleekxmpp.exceptions import XMPPError
|
||||
|
||||
from telethon.tl.functions.messages import GetDialogsRequest, SendMessageRequest, SendMediaRequest, EditMessageRequest, DeleteMessagesRequest, ImportChatInviteRequest, GetFullChatRequest, AddChatUserRequest, DeleteChatUserRequest, CreateChatRequest, DeleteHistoryRequest
|
||||
from telethon.tl.functions.account import UpdateStatusRequest, GetAuthorizationsRequest, UpdateProfileRequest, UpdateUsernameRequest
|
||||
@@ -125,10 +126,14 @@ class XMPPTelegram(ComponentXMPP):
|
||||
self.gate_reply_message(iq, 'Error.')
|
||||
|
||||
else: # -- normal message --
|
||||
self.send_tg_message(iq)
|
||||
|
||||
def send_tg_message(self, iq):
|
||||
jid = iq['from'].bare
|
||||
try:
|
||||
tg_id = int(iq['to'].node[1:])
|
||||
except ValueError:
|
||||
self.gate_reply_message(iq, 'Invalid JID')
|
||||
raise XMPPError(text="Invalid Telegram-ID")
|
||||
tg_peer = None
|
||||
msg = iq['body']
|
||||
reply_mid = None
|
||||
@@ -173,7 +178,6 @@ class XMPPTelegram(ComponentXMPP):
|
||||
self.tg_dialogs[jid]['messages'][tg_id] = {'id': msg_id, 'body': msg}
|
||||
#self.send_message(mto=iq['from'], mfrom=iq['to'], mtype='chat', mbody='[Your MID:{}]'.format(msg_id))
|
||||
|
||||
|
||||
def event_presence_unsub(self, presence):
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user