cleanup/bugfixes
This commit is contained in:
@@ -36,6 +36,8 @@ class CommandHandler():
|
|||||||
"""nolist Show debug info"""
|
"""nolist Show debug info"""
|
||||||
return pprint.pformat(self.__dict__)
|
return pprint.pformat(self.__dict__)
|
||||||
|
|
||||||
|
#TODO: handle non-existant commands
|
||||||
|
#TODO: add end text
|
||||||
def help(self, *args, **kwargs):
|
def help(self, *args, **kwargs):
|
||||||
"""List available commands"""
|
"""List available commands"""
|
||||||
#taken from https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation
|
#taken from https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation
|
||||||
@@ -112,13 +114,13 @@ class GateCommandHandler(CommandHandler):
|
|||||||
gate.spawn_tg_client(self.jid, phone_no)
|
gate.spawn_tg_client(self.jid, phone_no)
|
||||||
|
|
||||||
if gate.tg_connections[self.jid].is_user_authorized():
|
if gate.tg_connections[self.jid].is_user_authorized():
|
||||||
gate.send_presence(pto=jid, pfrom=gate.boundjid.bare, ptype='online', pstatus='connected')
|
# gate.send_presence(pto=jid, pfrom=gate.boundjid.bare, ptype='online', pstatus='connected') #already called in spawn_tg_client
|
||||||
return "You are already authenticated in Telegram"
|
return "You are already authenticated in Telegram"
|
||||||
else:
|
else:
|
||||||
# remove old sessions for this JID #
|
# remove old sessions for this JID #
|
||||||
gate.db_connection.execute("DELETE from accounts where jid = ?", (self.jid,))
|
gate.db_connection.execute("DELETE from accounts where jid = ?", (self.jid,))
|
||||||
gate.tg_connections[self.jid].send_code_request(phone_no)
|
gate.tg_connections[self.jid].send_code_request(phone_no)
|
||||||
gate._update('Gate is connected. Telegram should send SMS message to you.')
|
self._update('Gate is connected. Telegram should send SMS message to you.')
|
||||||
return 'Please enter one-time code via !code 12345.'
|
return 'Please enter one-time code via !code 12345.'
|
||||||
|
|
||||||
def code(self, gate):
|
def code(self, gate):
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ class XMPPTelegram(ComponentXMPP):
|
|||||||
"""
|
"""
|
||||||
jid = iq['from'].bare
|
jid = iq['from'].bare
|
||||||
|
|
||||||
|
if iq['type'] == 'normal':
|
||||||
|
raise XMPPError(text="Sorry, this type of message is not supported")
|
||||||
|
|
||||||
if iq['to'] == self.config['jid'] and iq['type'] == 'chat': # message to gateway
|
if iq['to'] == self.config['jid'] and iq['type'] == 'chat': # message to gateway
|
||||||
if iq['body'].startswith('!'):
|
if iq['body'].startswith('!'):
|
||||||
self.process_command(iq)
|
self.process_command(iq)
|
||||||
@@ -161,6 +164,8 @@ class XMPPTelegram(ComponentXMPP):
|
|||||||
result = None
|
result = None
|
||||||
|
|
||||||
# detect media
|
# detect media
|
||||||
|
#TODO: fix
|
||||||
|
#TODO: implement OOB for images
|
||||||
if msg.startswith('http') and re.match(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg):
|
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)
|
urls = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg)
|
||||||
message = msg.replace(urls[0], '')
|
message = msg.replace(urls[0], '')
|
||||||
|
|||||||
Reference in New Issue
Block a user