Tidied browser.py

This commit is contained in:
James Booth
2016-04-08 00:32:28 +01:00
parent e15ea30cf0
commit 7c4f39a023

View File

@@ -89,7 +89,7 @@ def prof_on_room_win_focus(room):
prof.completer_add("/browser", _links[room])
def prof_post_chat_message_display(jid, message):
def _process_message(jid, current_jid, message):
links = re.findall(r'(https?://\S+)', message)
if (len(links) > 0):
if jid not in _links:
@@ -98,43 +98,23 @@ def prof_post_chat_message_display(jid, message):
for link in links:
if link not in _links[jid]:
_links[jid].append(link)
# add to autocompleter if in chat with jid
current_jid = prof.get_current_recipient()
# add to autocompleter if message for current window
if current_jid == jid:
prof.completer_add("/browser", _links[jid])
# set last link for jid
_lastlink[jid] = links[len(links)-1]
def prof_post_chat_message_display(jid, message):
current_jid = prof.get_current_recipient()
_process_message(jid, current_jid, message)
def prof_post_room_message_display(room, nick, message):
links = re.findall(r'(https?://\S+)', message)
if (len(links) > 0):
if room not in _links:
_links[room] = []
# add to list of links for room
for link in links:
if link not in _links[room]:
_links[room].append(link)
# add to autocompleter if in room
current_room = prof.get_current_muc()
if current_room == room:
prof.completer_add("/browser", _links[room])
# set last link for room
_lastlink[room] = links[len(links)-1]
current_jid = prof.get_current_muc()
_process_message(room, current_jid, message)
def prof_on_room_history_message(room, nick, message, timestamp):
links = re.findall(r'(https?://\S+)', message)
if (len(links) > 0):
if room not in _links:
_links[room] = []
# add to list of links for room
for link in links:
if link not in _links[room]:
_links[room].append(link)
# add to autocompleter if in room
current_room = prof.get_current_muc()
if current_room == room:
prof.completer_add("/browser", _links[room])
# set last link for room
_lastlink[room] = links[len(links)-1]
current_jid = prof.get_current_muc()
_process_message(room, current_jid, message)