1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 19:14:06 +02:00

* Added stop/pause/prev/next commands to XMPPBot.

This commit is contained in:
Christian Muehlhaeuser
2010-10-29 12:12:30 +02:00
parent 59d269d631
commit 51789f5120

View File

@@ -130,14 +130,14 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
if (msg.subtype() != Message::Chat || msg.from().full().empty() || msg.to().full().empty())
return;
QString body = QString::fromStdString( msg.body() );
QString body = QString::fromStdString( msg.body() ).toLower().trimmed();
QString originatingJid = QString::fromStdString( msg.from().full() );
if ( body.toLower().startsWith( "play" ) )
if ( body.startsWith( "play" ) )
{
QStringList tokens = body.right( body.length() - 5 ).split( QString( "-" ), QString::SkipEmptyParts );
qDebug() << tokens;
if ( tokens.count() < 2 )
APP->audioEngine()->play();
QVariantMap qv;
qv["artist"] = tokens.first().trimmed();
@@ -152,8 +152,28 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
APP->pipeline()->add( ql );
return;
}
else if ( body.startsWith( "stop" ) )
{
APP->audioEngine()->stop();
return;
}
else if ( body.startsWith( "prev" ) )
{
APP->audioEngine()->previous();
return;
}
else if ( body.startsWith( "next" ) )
{
APP->audioEngine()->next();
return;
}
else if ( body.startsWith( "pause" ) )
{
APP->audioEngine()->pause();
return;
}
QStringList tokens( body.toLower().split( QString( " and " ), QString::SkipEmptyParts ) );
QStringList tokens( body.split( QString( " and " ), QString::SkipEmptyParts ) );
if ( tokens.isEmpty() )
return;