git » msnlib » commit 28c8ea4

Add a command to print the differences between fwd and reverse lists.

author Alberto Bertogli
2005-05-27 15:40:21 UTC
committer Alberto Bertogli
2005-05-27 15:40:21 UTC
parent 0a5d4ea22a2e3ba474bea9f0839432b9a27f9b59

Add a command to print the differences between fwd and reverse lists.

msn +26 -1

diff --git a/msn b/msn
index ffcc616..54a7f23 100644
--- a/msn
+++ b/msn
@@ -39,6 +39,7 @@ status [mode]	Shows the current status, or changes it to "mode", which can
 q		Quits the program
 w		Prints your entire contact list
 ww		Prints your entire contact list, including email addresses
+wd		Prints the differences between your forward and reverse lists
 e		Prints your online contacts
 ee		Prints your online contacts, including email addresses
 eg		Prints your online contacts with the groups
@@ -119,7 +120,7 @@ c = color_classes['default']()
 command_list = [ 'a', 'add', 'block', 'close', 'color', 'config', 'del', 'e',
 	'ee', 'eg', 'g', 'gadd', 'gdel', 'green', 'h', 'help', 'info',
 	'invite', 'lignore', 'luignore', 'm', 'nick', 'privacy', 'q', 'r',
-	'ren', 'status', 'unblock', 'w', 'wr', 'ww' ]
+	'ren', 'status', 'unblock', 'w', 'wd', 'wr', 'ww' ]
 
 
 #
@@ -180,6 +181,27 @@ def print_list(md, only_online = 0, userlist = None, include_emails = 0):
 			printl('[!]')
 		printl('\n')
 
+def print_diff(md):
+	"Prints the differences between forward and reverse lists"
+	fwdl = md.users.keys()
+	fwdl.sort()
+
+	revl = md.reverse.keys()
+	revl.sort()
+
+	printl("People you have that don't have you:\n", bold = 1)
+	for email in fwdl:
+		if email not in revl:
+			user = md.users[email]
+			printl("    %s (%s)\n" % (user.nick, email))
+	printl('\n')
+
+	printl("People you don't have that have you:\n", bold = 1)
+	for email in revl:
+		if email not in fwdl:
+			user = md.reverse[email]
+			printl("    %s (%s)\n" % (user.nick, email))
+
 def print_group_list(md):
 	"Prints the group list"
 	gids = md.groups.keys()
@@ -934,6 +956,9 @@ def parse_cmd(cmd):
 	elif cmd == 'wr':		# reverse list
 		print_list(m, userlist = m.reverse, include_emails = 1)
 
+	elif cmd == 'wd':		# difference list
+		print_diff(m)
+
 	elif cmd == 'e':		# list (online only)
 		print_list(m, only_online = 1)