mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-18 03:41:27 +02:00
* Added stop/pause/prev/next commands to XMPPBot.
This commit is contained in:
@@ -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())
|
if (msg.subtype() != Message::Chat || msg.from().full().empty() || msg.to().full().empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString body = QString::fromStdString( msg.body() );
|
QString body = QString::fromStdString( msg.body() ).toLower().trimmed();
|
||||||
QString originatingJid = QString::fromStdString( msg.from().full() );
|
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 );
|
QStringList tokens = body.right( body.length() - 5 ).split( QString( "-" ), QString::SkipEmptyParts );
|
||||||
|
if ( tokens.count() < 2 )
|
||||||
qDebug() << tokens;
|
APP->audioEngine()->play();
|
||||||
|
|
||||||
QVariantMap qv;
|
QVariantMap qv;
|
||||||
qv["artist"] = tokens.first().trimmed();
|
qv["artist"] = tokens.first().trimmed();
|
||||||
@@ -152,8 +152,28 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
|
|||||||
APP->pipeline()->add( ql );
|
APP->pipeline()->add( ql );
|
||||||
return;
|
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() )
|
if ( tokens.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user