Add support for .spectrum2 reconnect Slack command and show better error message when disconnected from 3rd-party network
This commit is contained in:
parent
f592dc0ef3
commit
b6c1ba543c
3 changed files with 14 additions and 4 deletions
|
@ -340,6 +340,14 @@ void SlackSession::handleMessageReceived(const std::string &channel, const std::
|
|||
msg += "```" + rooms + "```";
|
||||
m_rtm->sendMessage(m_ownerChannel, msg);
|
||||
}
|
||||
else if (args[1] == "reconnect") {
|
||||
Swift::Presence::ref presence = Swift::Presence::create();
|
||||
presence->setFrom(Swift::JID("", m_uinfo.jid, "default"));
|
||||
presence->setTo(m_component->getJID());
|
||||
presence->setType(Swift::Presence::Available);
|
||||
presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::MUCPayload()));
|
||||
m_component->getFrontend()->onPresenceReceived(presence);
|
||||
}
|
||||
else if (args[1] == "help") {
|
||||
std::string msg;
|
||||
msg = "Following commands are supported:\\n";
|
||||
|
@ -347,7 +355,8 @@ void SlackSession::handleMessageReceived(const std::string &channel, const std::
|
|||
msg += "```.spectrum2 join.room <3rdPartyBotName> <#3rdPartyRoom> <3rdPartyServer> <#SlackChannel>``` Starts transport between 3rd-party room and Slack channel.";
|
||||
msg += "```.spectrum2 leave.room <#SlackChannel>``` Leaves the 3rd-party room connected with the given Slack channel.";
|
||||
msg += "```.spectrum2 list.rooms``` List all the transported rooms.";
|
||||
msg += "```.spectrum2 register <3rdPartyNetworkAccount> <3rdPartyPassword> <#SlackChannel> Registers 3rd-party account for transportation.";
|
||||
msg += "```.spectrum2 reconnect``` Reconnects to 3rd-party network manually in case of fatal error.";
|
||||
msg += "```.spectrum2 register <3rdPartyNetworkAccount> <3rdPartyPassword> <#SlackChannel>``` Registers 3rd-party account for transportation.";
|
||||
m_rtm->sendMessage(m_ownerChannel, msg);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -67,7 +67,7 @@ void SlackUser::disconnectUser(const std::string &error, Swift::SpectrumErrorPay
|
|||
}
|
||||
|
||||
m_session->handleDisconnected();
|
||||
m_session->sendMessageToAll("Try using ```.spectrum2 reconnect``` to reconnect.");
|
||||
m_session->sendMessageToAll("Maybe you have provided wrong 3rd-party network account information. In that case, you can use ```.spectrum2 register ...``` command again with corrected data. You can also try using ```.spectrum2 reconnect``` to reconnect.");
|
||||
static_cast<SlackUserManager *>(m_userManager)->moveTempSession(m_jid.toString(), m_session);
|
||||
m_session = NULL;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,10 @@ class Responder(sleekxmpp.ClientXMPP):
|
|||
self.tests["abc_received"] = ["Test message received", False]
|
||||
|
||||
def message(self, msg):
|
||||
if msg['body'] == "Not Authorized" or msg['body'] == "Server may require plaintext authentication over an unencrypted stream":
|
||||
if msg['body'] == "Not Authorized" or msg['body'] == "Server may require plaintext authentication over an unencrypted stream"
|
||||
:
|
||||
self.tests["not_authorized"][1] = True
|
||||
elif msg['body'].find("Try using") != -1:
|
||||
elif msg['body'].find("try using") != -1:
|
||||
self.send_message(mto="spectrum2@spectrum2tests.xmpp.slack.com", mbody=".spectrum2 register client@localhost password #spectrum2_contactlist")
|
||||
self.tests["help_received"][1] = True
|
||||
elif msg['body'] == "You have successfully registered 3rd-party account. Spectrum 2 is now connecting to the 3rd-party network.":
|
||||
|
|
Loading…
Add table
Reference in a new issue