summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.py2
-rw-r--r--src/config.py5
-rw-r--r--src/gui.py22
-rw-r--r--src/room.py4
-rw-r--r--src/user.py22
5 files changed, 46 insertions, 9 deletions
diff --git a/src/client.py b/src/client.py
index 3480907b..dfc31f3c 100644
--- a/src/client.py
+++ b/src/client.py
@@ -21,7 +21,7 @@ import sys
# disable any printout (this would mess the display)
# sys.stdout = open('/dev/null', 'w')
-sys.stderr = open('debug', 'w')
+sys.stderr = open('errors', 'w')
from connection import Connection
from multiuserchat import MultiUserChat
diff --git a/src/config.py b/src/config.py
index 57c3d90a..8237c7b7 100644
--- a/src/config.py
+++ b/src/config.py
@@ -59,7 +59,10 @@ class Config(RawConfigParser):
return self._get(option)
def getint(self, option):
- return int(self._get(option))
+ try:
+ return int(self._get(option))
+ except ValueError:
+ return -1
def getfloat(self, option):
return float(self._get(option))
diff --git a/src/gui.py b/src/gui.py
index b3964354..f0b06af0 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -118,9 +118,6 @@ class Gui(object):
try:
key = stdscr.getkey()
except:
- debug("main_loop exception")
- # self.window.resize(stdscr)
- # self.window.refresh(self.rooms)
continue
if str(key) in self.key_func.keys():
self.key_func[key]()
@@ -256,7 +253,7 @@ class Gui(object):
room.topic = subject.encode('utf-8').replace('\n', '|')
if room == self.current_room():
self.window.topic_win.refresh(room.topic)
- else:
+ elif body:
if body.startswith('/me '):
self.add_info(room, nick_from + ' ' + body[4:], date)
else:
@@ -292,7 +289,8 @@ class Gui(object):
# New user
if not user:
room.users.append(User(from_nick, affiliation, show, status, role))
- if not config.get('hide_enter_join', "false") == "true":
+ hide_exit_join = config.get('hide_exit_join', -1)
+ if hide_exit_join != 0:
self.add_info(room, _('%(nick)s joined the room %(roomname)s') % {'nick':from_nick, 'roomname': room.name})
# nick change
elif change_nick:
@@ -325,12 +323,21 @@ class Gui(object):
# user quit
elif status == 'offline' or role == 'none':
room.users.remove(user)
- if not config.get('hide_enter_join', "false") == "true":
+ hide_exit_join = config.get('hide_exit_join', -1)\
+ if config.get('hide_exit_join', -1) >= -1\
+ else -1
+ if hide_exit_join == -1 or \
+ user.has_talked_since(hide_exit_join):
self.add_info(room, _('%s has left the room') % (from_nick))
# status change
else:
user.update(affiliation, show, status, role)
- if not config.get('hide_status_change', "false") == "true":
+ hide_status_change = config.get('hide_status_change', -1)\
+ if config.get('hide_status_change', -1) >= -1\
+ else -1
+ if hide_status_change == -1 or \
+ user.has_talked_since(hide_status_change) or\
+ user.nick == room.own_nick:
self.add_info(room, _('%(nick)s changed his/her status : %(a)s, %(b)s, %(c)s, %(d)s') % {'nick':from_nick, 'a':affiliation, 'b':role, 'c':show, 'd':status})
if room == self.current_room():
self.window.user_win.refresh(room.users)
@@ -464,6 +471,7 @@ class Gui(object):
if not r: # if the room window exists, we don't recreate it.
self.join_room(room, nick)
else:
+ r.own_nick = nick
r.users = []
def command_bookmark(self, args):
diff --git a/src/room.py b/src/room.py
index 100b2fe5..eb6e7de8 100644
--- a/src/room.py
+++ b/src/room.py
@@ -53,11 +53,15 @@ class Room(object):
if word.lower() in msg.lower() and word != '':
self.set_color_state(13)
color = 3
+ break
if not msg:
logger.info('msg is None..., %s' % (nick))
return
self.lines.append((date, nick.encode('utf-8'),
msg.encode('utf-8'), color))
+ user = self.get_user_by_name(nick)
+ if user:
+ user.set_last_talked(date)
if self.joined: # log only NEW messages, not the history received on join
logger.message(self.name, nick.encode('utf-8'), msg.encode('utf-8'))
return color
diff --git a/src/user.py b/src/user.py
index 0dee9e42..6f0f3328 100644
--- a/src/user.py
+++ b/src/user.py
@@ -19,12 +19,14 @@
from random import randrange
from config import config
+from datetime import timedelta, datetime
class User(object):
"""
keep trace of an user in a Room
"""
def __init__(self, nick, affiliation, show, status, role):
+ self.last_talked = None
self.update(affiliation, show, status, role)
self.change_nick(nick)
self.color = randrange(2, 10)
@@ -37,3 +39,23 @@ class User(object):
def change_nick(self, nick):
self.nick = nick.encode('utf-8')
+
+ def set_last_talked(self, time):
+ """
+ time: datetime object
+ """
+ self.last_talked = time
+
+ def has_talked_since(self, t):
+ """
+ get a int
+ Return True if the user talked since the last s seconds
+ """
+ from common import debug
+ if self.last_talked is None:
+ return False
+ delta = timedelta(0, t)
+ debug("Last talk: %s\nDelai:%s\nDelta:%s\n" % (str(self.last_talked), str(t), str(delta)))
+ if datetime.now() - delta > self.last_talked:
+ return False
+ return True