summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.py2
-rw-r--r--src/logger.py16
-rw-r--r--src/room.py2
-rw-r--r--src/tabs.py3
4 files changed, 14 insertions, 9 deletions
diff --git a/src/core.py b/src/core.py
index 104a653f..e266fc1e 100644
--- a/src/core.py
+++ b/src/core.py
@@ -519,6 +519,7 @@ class Core(object):
room.add_message(body, time=None, nickname=nick_from,
colorized=False,
forced_user=self.get_room_by_name(room_from).get_user_by_name(nick_from))
+ logger.log_message(jid.full.replace('/', '\\'), nick_from, body)
self.refresh_window()
self.doupdate()
@@ -548,6 +549,7 @@ class Core(object):
else:
remote_nick = jid.user
conversation.get_room().add_message(body, None, remote_nick, False, theme.COLOR_REMOTE_USER)
+ logger.log_message(jid.bare, remote_nick, body)
if self.current_tab() is not conversation:
conversation.set_color_state(theme.COLOR_TAB_PRIVATE)
self.refresh_window()
diff --git a/src/logger.py b/src/logger.py
index 991187a0..d2a00eaa 100644
--- a/src/logger.py
+++ b/src/logger.py
@@ -34,10 +34,10 @@ class Logger(object):
def __init__(self):
self.logfile = config.get('logfile', 'logs')
# a dict of 'groupchatname': file-object (opened)
- self.groupchat_fds = dict()
+ self.fds = dict()
def __del__(self):
- for opened_file in self.groupchat_fds.values():
+ for opened_file in self.fds.values():
opened_file.close()
def check_and_create_log_dir(self, room):
@@ -54,19 +54,19 @@ class Logger(object):
pass
try:
fd = open(os.path.join(directory, room), 'a')
- self.groupchat_fds[room] = fd
+ self.fds[room] = fd
return fd
except IOError:
return None
- def groupchat(self, room, nick, msg):
+ def log_message(self, jid, nick, msg):
"""
- log the message in the appropriate room's file
+ log the message in the appropriate jid's file
"""
- if room in self.groupchat_fds.keys():
- fd = self.groupchat_fds[room]
+ if jid in self.fds.keys():
+ fd = self.fds[jid]
else:
- fd = self.check_and_create_log_dir(room)
+ fd = self.check_and_create_log_dir(jid)
if not fd:
return
if nick:
diff --git a/src/room.py b/src/room.py
index 0c34b445..1613ecee 100644
--- a/src/room.py
+++ b/src/room.py
@@ -52,7 +52,7 @@ class Room(TextBuffer):
to be
"""
if time is None and self.joined: # don't log the history messages
- logger.groupchat(self.name, nickname, txt)
+ logger.log_message(self.name, nickname, txt)
def do_highlight(self, txt, time, nickname):
"""
diff --git a/src/tabs.py b/src/tabs.py
index 92b6f9c5..1c0e4d93 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -43,6 +43,7 @@ from sleekxmpp.xmlstream.stanzabase import JID
from config import config
from roster import RosterGroup, roster
from contact import Contact, Resource
+from logger import logger
import multiuserchat as muc
class Tab(object):
@@ -655,6 +656,7 @@ class PrivateTab(ChatTab):
def command_say(self, line):
muc.send_private_message(self.core.xmpp, self.get_name(), line)
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.get_room().own_nick)
+ logger.log_message(self.get_name().replace('/', '\\'), self.get_room().own_nick, line)
def command_unquery(self, arg):
"""
@@ -1034,6 +1036,7 @@ class ConversationTab(ChatTab):
def command_say(self, line):
muc.send_private_message(self.core.xmpp, self.get_name(), line)
self.core.add_message_to_text_buffer(self.get_room(), line, None, self.core.own_nick)
+ logger.log_message(JID(self.get_name()).bare, self.core.own_nick, line)
def command_unquery(self, arg):
self.core.close_tab()