Handle situation when sending /whois with non existing nickname :)

This commit is contained in:
Jan Kaluza 2015-12-17 18:25:26 +01:00
parent ab4740c7b6
commit b44919ed9b
5 changed files with 20 additions and 4 deletions

View file

@ -183,6 +183,7 @@ void IRCNetworkPlugin::handleMessageSendRequest(const std::string &user, const s
}
else if (message.find("/whois") == 0 || message.find(".whois") == 0) {
m_sessions[session]->sendWhoisCommand(target, message.substr(7));
return;
}
else {
m_sessions[session]->sendCommand(IrcCommand::createMessage(FROM_UTF8(target), FROM_UTF8(message)));

View file

@ -376,6 +376,14 @@ void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
LOG4CXX_INFO(logger, m_user << "Asking /who for channel " << TO_UTF8(channel));
sendCommand(IrcCommand::createWho(channel));
break;
case 401:
case 402:
nick = TO_UTF8(parameters[1]);
if (m_whois.find(nick) != m_whois.end()) {
sendMessageToFrontend(m_whois[nick], "whois", nick + ": No such client");
m_whois.erase(nick);
}
break;
case 432:
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Erroneous Nickname");
break;

View file

@ -29,12 +29,15 @@ class Client(sleekxmpp.ClientXMPP):
self.finished = False
self.tests = {}
self.tests["whois_received"] = ["libcommuni: Receive /whois command response", False]
self.tests["whois1_received"] = ["libcommuni: Receive /whois command response", False]
self.tests["whois2_received"] = ["libcommuni: Receive /whois command response for invalid nickname", False]
def muc_message(self, msg):
if msg['mucnick'] != self.nick:
if msg["body"] == "responder is connected to irc.example.net (responder)\nresponder is a user on channels: @#channel":
self.tests["whois_received"][1] = True
self.tests["whois1_received"][1] = True
elif msg["body"] == "nonexisting: No such client":
self.tests["whois2_received"][1] = True
self.finished = True
def start(self, event):
@ -42,3 +45,4 @@ class Client(sleekxmpp.ClientXMPP):
self.sendPresence()
self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
self.send_message(mto=self.room, mbody="/whois responder", mtype='groupchat')
self.send_message(mto=self.room, mbody="/whois nonexisting", mtype='groupchat')

View file

@ -171,12 +171,12 @@
;DefaultUserModes = i
# Do DNS lookups when a client connects to the server.
;DNS = yes
DNS = no
# Do IDENT lookups if ngIRCd has been compiled with support for it.
# Users identified using IDENT are registered without the "~" character
# prepended to their user name.
;Ident = yes
Ident = no
# Directory containing configuration snippets (*.conf), that should
# be read in after parsing this configuration file.

View file

@ -103,6 +103,9 @@ for conf in configurations:
if not f.endswith(".py") or f == "start.py":
continue
if len(sys.argv) == 2 and sys.argv[1] != f:
continue
print conf.__class__.__name__ + ": Starting " + f + " test ..."
test = imp.load_source('test', './' + f)
try: