From 7c4f39a023a02e053e19b3ba4381ae864a72c0ca Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 8 Apr 2016 00:32:28 +0100 Subject: [PATCH] Tidied browser.py --- browser.py | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/browser.py b/browser.py index d56459c..09f6aa2 100644 --- a/browser.py +++ b/browser.py @@ -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)