From 2f70b8ff398b36e435167952af2e25b22519c600 Mon Sep 17 00:00:00 2001
From: Zev Benjamin <zev@zulip.com>
Date: Mon, 3 Mar 2014 14:52:09 -0500
Subject: [PATCH] jabber_mirror: Allow the MUC nickname to be specified

This allows users to run the public mirror as a regular user.

(imported from commit 3512dacf329dadc784d7be492ad290b17082bad4)
---
 bots/jabber_mirror.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/bots/jabber_mirror.py b/bots/jabber_mirror.py
index d9e57222..372709d4 100755
--- a/bots/jabber_mirror.py
+++ b/bots/jabber_mirror.py
@@ -61,8 +61,10 @@ def jid_to_zulip(jid):
 
 class JabberToZulipBot(ClientXMPP):
     def __init__(self, jid, password, rooms, openfire=False):
-        self.nick = jid.username
-        if not jid.resource:
+        if jid.resource:
+            self.nick = jid.resource
+        else:
+            self.nick = jid.username
             jid.resource = "zulip"
         ClientXMPP.__init__(self, jid, password)
         self.password = password
@@ -302,7 +304,11 @@ user and mirrors messages sent to Jabber rooms to Zulip.'''.replace("\n", " "))
     jabber_group.add_option('--jid',
                             default=None,
                             action='store',
-                            help="Your Jabber JID")
+                            help="Your Jabber JID.  If a resource is specified, "
+                            + "it will be used as the nickname when joining MUCs.  "
+                            + "Specifying the nickname is mostly useful if you want "
+                            + "to run the public mirror from a regular user instead of "
+                            + "from a dedicated account.")
     jabber_group.add_option('--jabber-password',
                             default=None,
                             action='store',