From 33123f46950b7a209d05ad7f9b9c302870d04687 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Wed, 10 Feb 2016 15:42:10 -0500 Subject: [PATCH] Fixed bug that caused user modes to be sent incorrectly when an alternate nickname was in use. --- src/client/server/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index 4a32923..e7be283 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -268,6 +268,16 @@ impl IrcServer { res } + /// Gets the current nickname in use. + pub fn current_nickname(&self) -> &str { + let alt_nicks = self.config().alternate_nicknames(); + let index = self.state.alt_nick_index.read().unwrap(); + match *index { + 0 => self.config().nickname(), + i => alt_nicks[i - 1] + } + } + #[cfg(feature = "encode")] fn write>(state: &Arc, msg: M) -> Result<()> { state.conn.send(&msg.into().into_string(), state.config.encoding()) @@ -357,7 +367,7 @@ impl IrcServer { ))) } if self.config().umodes() != "" { - try!(self.send_mode(self.config().nickname(), self.config().umodes(), "")) + try!(self.send_mode(self.current_nickname(), self.config().umodes(), "")) } for chan in self.config().channels().into_iter() { try!(self.send_join(chan))