# Sort messages by time
messages = dg['thread'][partner]
messages.sort(key = lambda x:parser.parse(x['created_at']))
-
# Print the 1st line
dg['message_thread_margin'] = margin = 2
left_size = len(partner[0])+len(partner[1]) + margin
printNicely('')
printNicely(line)
printNicely('')
-
# Print messages
for m in messages:
if m['sender_screen_name'] == me_nick:
slicing = [m['text'][i:i+step] for i in range(0, len(m['text']), step)]
spaces = w - frame_width - dg['message_thread_margin']
dotline = ' ' * spaces + '-' * frame_width
-
+ dotline = color_func(c['MESSAGE']['me_bg'])(dotline)
+ # Draw the frame
printNicely(dotline)
for line in slicing:
fill = step - len(line)
screen_line = screen_line + ' >'
else:
screen_line = screen_line + '|'
+ screen_line = color_func(c['MESSAGE']['me_bg'])(screen_line)
printNicely(screen_line)
printNicely(dotline)
+ # Print clock
+ date = parser.parse(m['created_at'])
+ date = arrow.get(date).to('local').datetime
+ clock_format = '%Y/%m/%d %H:%M:%S'
+ try:
+ clock_format = c['FORMAT']['MESSAGE']['CLOCK_FORMAT']
+ except:
+ pass
+ clock = date.strftime(clock_format)
+ # Get rainbow id
+ if m['id'] not in c['message_dict']:
+ c['message_dict'].append(m['id'])
+ rid = len(c['message_dict']) - 1
+ else:
+ rid = c['message_dict'].index(m['id'])
+ rid = str(rid)
+ # Create line and print
+ meta = color_func(c['MESSAGE']['clock'])(clock) + \
+ color_func(c['MESSAGE']['id'])(' ('+rid+')')
+ line = ' ' * (w - len(clock + rid) - 3 - dg['message_thread_margin']) + \
+ meta
+ printNicely(line)
def print_left_message(m):
slicing = [m['text'][i:i+step] for i in range(0, len(m['text']), step)]
spaces = dg['message_thread_margin']
dotline = ' ' * spaces + '-' * frame_width
-
+ dotline = color_func(c['MESSAGE']['partner_bg'])(dotline)
+ # Draw the frame
printNicely(dotline)
for line in slicing:
fill = step - len(line)
screen_line = ' ' * (spaces-1) + '< ' + screen_line
else:
screen_line = ' ' * spaces + '|' + screen_line
+ screen_line = color_func(c['MESSAGE']['partner_bg'])(screen_line)
printNicely(screen_line)
printNicely(dotline)
+ # Print clock
+ date = parser.parse(m['created_at'])
+ date = arrow.get(date).to('local').datetime
+ clock_format = '%Y/%m/%d %H:%M:%S'
+ try:
+ clock_format = c['FORMAT']['MESSAGE']['CLOCK_FORMAT']
+ except:
+ pass
+ clock = date.strftime(clock_format)
+ # Get rainbow id
+ if m['id'] not in c['message_dict']:
+ c['message_dict'].append(m['id'])
+ rid = len(c['message_dict']) - 1
+ else:
+ rid = c['message_dict'].index(m['id'])
+ rid = str(rid)
+ # Create line and print
+ meta = color_func(c['MESSAGE']['clock'])(clock) + \
+ color_func(c['MESSAGE']['id'])(' ('+rid+')')
+ line = ' ' * dg['message_thread_margin'] + \
+ meta
+ printNicely(line)
def print_message(m):