aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2015-07-21 13:47:51 -0700
committerRyan Huber <rhuber@gmail.com>2015-07-21 13:47:51 -0700
commit8265cb04f54ab088df909533ee68a84219286d19 (patch)
treea887828b3650e7cdaa4538aab3c7a776cc91f9a3 /wee_slack.py
parentf14e4b30bd672fe9c8446d44e089e9b46ffcc1f5 (diff)
downloadwee-slack-8265cb04f54ab088df909533ee68a84219286d19.tar.gz
more efficient nicklist building
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index ade99cb..bc5b617 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -8,7 +8,6 @@ import pickle
import sha
import re
import urllib
-import urlparse
import HTMLParser
import sys
from websocket import create_connection
@@ -371,6 +370,7 @@ class Channel(object):
self.members = set(members)
self.topic = topic
+ self.members_table = {}
self.channel_buffer = None
self.type = "channel"
self.server = server
@@ -384,6 +384,7 @@ class Channel(object):
self.attach_buffer()
self.update_nicklist()
self.set_topic(self.topic)
+ self.create_members_table()
buffer_list_update_next()
def __str__(self):
@@ -398,6 +399,10 @@ class Channel(object):
else:
return False
+ def create_members_table(self):
+ for user in self.members:
+ self.members_table[user] = self.server.users.find(user)
+
def create_buffer(self):
channel_buffer = w.buffer_search("", "{}.{}".format(self.server.domain, self.name))
if channel_buffer:
@@ -431,7 +436,7 @@ class Channel(object):
w.nicklist_remove_all(self.channel_buffer)
try:
for user in self.members:
- user = self.server.users.find(user)
+ user = self.members_table[user]
if user.deleted:
continue
if user.presence == 'away':
@@ -439,7 +444,7 @@ class Channel(object):
else:
w.nicklist_add_nick(self.channel_buffer, "", user.name, user.color_name, "+", "", 1)
except Exception as e:
- print "DEBUG: {} {} {}".format(self.identifier, self.name, e)
+ dbg("DEBUG: {} {} {}".format(self.identifier, self.name, e))
def fullname(self):
return "{}.{}".format(self.server.domain, self.name)
@@ -449,11 +454,13 @@ class Channel(object):
def user_join(self, name):
self.members.add(name)
+ self.create_members_table()
self.update_nicklist()
def user_leave(self, name):
if name in self.members:
self.members.remove(name)
+ self.create_members_table()
self.update_nicklist()
def set_active(self):