1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Display a helpful message when someone gives non-JSON data to the xmpp bot

This commit is contained in:
Jeff Mitchell
2011-03-26 16:49:26 -04:00
parent 9496885d63
commit 9558270d86

View File

@@ -24,9 +24,11 @@
#include <QString>
#include <QRegExp>
#include <QThread>
#include <QVariant>
#include <utils/tomahawkutils.h>
#include <gloox/capabilities.h>
#include <QMessageBox>
#include <qjson/parser.h>
using namespace gloox;
using namespace std;
@@ -430,6 +432,15 @@ Jabber_p::handleMessage( const Message& m, MessageSession * /*session*/ )
//sendMsg( from, QString("You said %1").arg(msg) );
QJson::Parser parser;
bool ok;
QVariant v = parser.parse( msg.toAscii(), &ok );
if ( !ok || v.type() != QVariant::Map )
{
sendMsg( from, QString( "I'm sorry -- I'm just an automatic presence used by Tomahawk Player (http://gettomahawk.com). If you are getting this message, the person you are trying to reach is probably not signed on, so please try again later!" ) );
return;
}
emit msgReceived( from, msg );
}