we now save conferences history in a folder, and all pm related to this conference in this folder
This commit is contained in:
parent
8139c645f8
commit
74a45a7224
1 changed files with 35 additions and 11 deletions
|
@ -62,32 +62,52 @@ class Logger:
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = ''
|
msg = ''
|
||||||
msg = msg.replace('\n', '\\n')
|
msg = msg.replace('\n', '\\n')
|
||||||
ji = jid.split('/')[0]
|
if len(jid.split('/')) > 1:
|
||||||
|
ji, nick = jid.split('/', 1)
|
||||||
|
else:
|
||||||
|
ji = jid
|
||||||
|
nick = ''
|
||||||
files = []
|
files = []
|
||||||
if kind == 'status': #we save time:jid:show:msg
|
if kind == 'status': #we save time:jid:show:msg
|
||||||
if not show:
|
if not show:
|
||||||
show = 'online'
|
show = 'online'
|
||||||
if common.gajim.config.get('log_notif_in_user_file'):
|
if common.gajim.config.get('log_notif_in_user_file'):
|
||||||
files.append(ji)
|
path_to_file = os.path.join(LOGPATH, ji)
|
||||||
|
if os.path.isdir(path_to_file):
|
||||||
|
files.append(ji + '/' + ji)
|
||||||
|
if os.path.isfile(jid):
|
||||||
|
files.append(jid)
|
||||||
|
else:
|
||||||
|
files.append(ji)
|
||||||
if common.gajim.config.get('log_notif_in_sep_file'):
|
if common.gajim.config.get('log_notif_in_sep_file'):
|
||||||
files.append('notify.log')
|
files.append('notify.log')
|
||||||
elif kind == 'incoming': # we save time:recv:message
|
elif kind == 'incoming': # we save time:recv:message
|
||||||
files.append(ji)
|
path_to_file = os.path.join(LOGPATH, ji)
|
||||||
|
if os.path.isdir(path_to_file):
|
||||||
|
files.append(jid)
|
||||||
|
else:
|
||||||
|
files.append(ji)
|
||||||
jid = 'recv'
|
jid = 'recv'
|
||||||
show = msg
|
show = msg
|
||||||
msg = ''
|
msg = ''
|
||||||
elif kind == 'outgoing': # we save time:sent:message
|
elif kind == 'outgoing': # we save time:sent:message
|
||||||
files.append(ji)
|
path_to_file = os.path.join(LOGPATH, ji)
|
||||||
|
if os.path.isdir(path_to_file):
|
||||||
|
files.append(jid)
|
||||||
|
else:
|
||||||
|
files.append(ji)
|
||||||
jid = 'sent'
|
jid = 'sent'
|
||||||
show = msg
|
show = msg
|
||||||
msg = ''
|
msg = ''
|
||||||
elif kind == 'gc':
|
elif kind == 'gc': # we save time:gc:nick:message
|
||||||
files.append(ji)
|
# create the folder if needed
|
||||||
jid = 'recv'
|
ji_fn = os.path.join(LOGPATH, ji)
|
||||||
jids = jid.split('/')
|
if os.path.isfile(ji_fn):
|
||||||
nick = ''
|
os.remove(ji_fn)
|
||||||
if len(jids) > 1:
|
if not os.path.isdir(ji_fn):
|
||||||
nick = jids[1]
|
os.mkdir(ji_fn)
|
||||||
|
files.append(ji + '/' + ji)
|
||||||
|
jid = 'gc'
|
||||||
show = nick
|
show = nick
|
||||||
for f in files:
|
for f in files:
|
||||||
path_to_file = os.path.join(LOGPATH, f)
|
path_to_file = os.path.join(LOGPATH, f)
|
||||||
|
@ -102,6 +122,8 @@ class Logger:
|
||||||
'''return total number of lines in a log file
|
'''return total number of lines in a log file
|
||||||
return 0 if log file does not exist'''
|
return 0 if log file does not exist'''
|
||||||
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
||||||
|
if os.path.isdir(path_to_file):
|
||||||
|
path_to_file = os.path.join(LOGPATH, jid)
|
||||||
if not os.path.exists(path_to_file):
|
if not os.path.exists(path_to_file):
|
||||||
return 0
|
return 0
|
||||||
fic = open(path_to_file, 'r')
|
fic = open(path_to_file, 'r')
|
||||||
|
@ -115,6 +137,8 @@ class Logger:
|
||||||
'''return number of lines read and the text in the lines
|
'''return number of lines read and the text in the lines
|
||||||
return 0 and empty respectively if log file does not exist'''
|
return 0 and empty respectively if log file does not exist'''
|
||||||
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
path_to_file = os.path.join(LOGPATH, jid.split('/')[0])
|
||||||
|
if os.path.isdir(path_to_file):
|
||||||
|
path_to_file = os.path.join(LOGPATH, jid)
|
||||||
if not os.path.exists(path_to_file):
|
if not os.path.exists(path_to_file):
|
||||||
return 0, []
|
return 0, []
|
||||||
fic = open(path_to_file, 'r')
|
fic = open(path_to_file, 'r')
|
||||||
|
|
Loading…
Add table
Reference in a new issue