Thu May 12 15:35:54 ART 2005  Alberto Bertogli <albertogli@telpin.com.ar>
  * Implement show on real nick changes.
  This patch implements detection, showing and logging of real nicks changes,
  enabled optionally with the "show nick changes" msnrc option. Based on
  Sebastián Santisi's work.
  
diff -rN -u old-msnlib/msn new-msnlib/msn
--- old-msnlib/msn	2005-05-27 13:09:29.000000000 -0300
+++ new-msnlib/msn	2005-05-27 13:09:29.000000000 -0300
@@ -494,6 +494,8 @@
 		out += '*** ' + msg + '\n'
 	elif type == 'multi':
 		out += '+++ ' + msg + '\n'
+	elif type == 'realnick':
+		out += '--- ' + msg + '\n'
 
 	fd = open(file, 'a')
 	fd.write(out)
@@ -1248,13 +1250,21 @@
 	t = params.split(' ')
 	status = msnlib.reverse_status[t[0]]
 	email = t[1]
+	rnick = urllib.unquote(t[2])
 	nick = md.users[email].nick
 	ctime = time.strftime('%I:%M:%S%p', now())
+
 	printl('\r%s ' % ctime, c.blue)
 	printl(nick, c.blue, 1)
-	printl(' changed status to ', c.magenta)
-	printl('%s\n' % status, c.magenta, 1)
+	printl(' is ', c.magenta)
+	printl('%s' % status, c.magenta, 1)
 	log_msg(email, 'status', status)
+	if config["show nick changes"]:
+		printl(' with realnick ', c.magenta)
+		printl('%s' % rnick, c.magenta, 1)
+		log_msg(email, 'realnick', rnick)
+	printl('\n')
+
 	msncb.cb_iln(md, type, tid, params)
 m.cb.iln = cb_iln
 
@@ -1262,13 +1272,36 @@
 	status = msnlib.reverse_status[tid]
 	t = params.split(' ')
 	email = t[0]
+	if len(params) > 1:
+		rnick = urllib.unquote(t[1])
+	else:
+		rnick = ''
+
 	nick = md.users[email].nick
+	realnick = md.users[email].realnick
 	ctime = time.strftime('%I:%M:%S%p', now())
-	printl('\r%s ' % ctime, c.blue)
-	printl(nick, c.blue, 1)
-	printl(' changed status to ', c.magenta)
-	printl('%s\n' % status, c.magenta, 1)
-	log_msg(email, 'status', status)
+
+	if tid != md.users[email].status:
+		printl('\r%s ' % ctime, c.blue)
+		printl(nick, c.blue, 1)
+		printl(' changed status to ', c.magenta)
+		printl('%s' % status, c.magenta, 1)
+		log_msg(email, 'status', status)
+		# if we don't know the realnick yet, include it in the same line
+		if not realnick and config["show nick changes"]:
+			printl(' with realnick ', c.magenta)
+			printl('%s' % rnick, c.magenta, 1)
+			log_msg(email, 'realnick', rnick)
+		printl("\n")
+
+	if realnick and rnick and realnick != rnick \
+			and config["show nick changes"]:
+		printl("\r%s " % ctime, c.blue)
+		printl(nick, c.blue, 1)
+		printl(' changed the realnick to ', c.magenta)
+		printl('%s\n' % rnick, c.magenta, 1)
+		log_msg(email, 'realnick', rnick)
+
 	msncb.cb_nln(md, type, tid, params)
 m.cb.nln = cb_nln
 
@@ -1642,6 +1675,12 @@
 if not config.has_key('history directory'):
 	config['history directory'] = os.environ['HOME'] + '/.msn/history'
 
+# show nick changes
+if not config.has_key('show nick changes'):
+	config['show nick changes'] = 0
+elif config['show nick changes'] != 'yes':
+	config['show nick changes'] = 0
+
 # auto away time
 if not config.has_key('auto away'):
 	config['auto away'] = 0
diff -rN -u old-msnlib/msnrc.sample new-msnlib/msnrc.sample
--- old-msnlib/msnrc.sample	2005-05-27 13:09:29.000000000 -0300
+++ new-msnlib/msnrc.sample	2005-05-27 13:09:29.000000000 -0300
@@ -34,6 +34,9 @@
 # defaults to $HOME/.msn/history
 history directory = /home/myself/.msn/history
 
+# show changes in real nicks
+show nick changes = no
+
 # number of seconds after, if no command was received, we set automatically
 # away. defaults to 0, which disables it.
 auto away = 0
diff -rN -u old-msnlib/utils/msnlog.vim new-msnlib/utils/msnlog.vim
--- old-msnlib/utils/msnlog.vim	2005-05-27 13:09:29.000000000 -0300
+++ new-msnlib/utils/msnlog.vim	2005-05-12 15:33:43.000000000 -0300
@@ -14,8 +14,9 @@
 syntax match	mlogMultiStr	"^\t.*$"
 syntax match	mlogIMsg	"<<< .*$"
 syntax match	mlogOMsg	">>> .*$"
-syntax match	mlogStatus	".*\*\*\* .*$"
+syntax match	mlogStatus	"\*\*\* .*$"
 syntax match	mlogMchat	"+++ .*$"
+syntax match	mlogRnick	"--- .*$"
 syntax match	mlogDate	"^../.../.... ..:..:.."
 
 
@@ -24,6 +25,7 @@
 hi mlogOMsg		ctermfg=cyan
 hi mlogStatus		ctermfg=yellow
 hi mlogMchat		ctermfg=yellow
+hi mlogRnick		ctermfg=yellow
 hi mlogMultiStr		ctermfg=magenta
 
 

