Пример #1
0
void PluginWizzflux::analyse(QNetworkReply* networkReply)
{
	if (!networkReply->error()) {
		Bunny * bunny = BunnyManager::GetBunny(this, networkReply->parent()->property("BunnyID").toByteArray());
		if(bunny) {
            QString message = QString::fromUtf8(networkReply->readAll());
        	if(message != "" && bunny->IsIdle()) {
                message = "ST "+message.toAscii()+"\nPL "+QString::number(qrand() % 8).toAscii()+"\nMW\n";
                bunny->SendPacket(MessagePacket(message.toAscii()));
            }
		}
	}
	networkReply->deleteLater();
	networkReply->parent()->deleteLater();
}
Пример #2
0
void PluginClock::OnCron(Bunny *, QVariant)
{
	QMapIterator<Bunny *, QString> i(bunnyList);
	while (i.hasNext()) {
		i.next();
		Bunny * b = i.key();
		QString voice = i.value();
		if(b->IsIdle())
		{
			QString hour = QDateTime::currentDateTime().toString("h");
			QByteArray file;
			if(voice == "tts")
//			if(voice == "French")
//				file = TTSManager::CreateNewSound("Il est " + hour + " heure", "julie");
//			if(voice == "English")
				file = TTSManager::CreateNewSound("It is " + hour + " O'Clock", "heather");
			else
			{
				// Fetch available files
				QDir * dir = GetLocalHTTPFolder();
				if(dir)
				{
					dir->cd(voice);
					dir->cd(hour);
					QStringList list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot);
					if(list.count())
					{
						file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count())));
					}
					delete dir;
				}
				else
					LogError("Invalid GetLocalHTTPFolder()");
			}

			if(!file.isNull())
			{
				QByteArray message = "MU "+file+"\nPL 3\nMW\n";
				b->SendPacket(MessagePacket(message));
			}
		}

	}
}
Пример #3
0
void PluginClock::OnCron(Bunny *, QVariant)
{
	QMapIterator<Bunny *, QString> i(bunnyList);
	while (i.hasNext()) {
		i.next();
		Bunny * b = i.key();
		QString voice = i.value();
		if(b->IsIdle())
		{
			QString hour = QDateTime::currentDateTime().toString("h");
			QByteArray file;
			QDir * dir = GetLocalHTTPFolder();
			QStringList list;
			if(voice == "tts")
				file = TTSManager::CreateNewSound("Sono le ore " + hour, "chiara");
			else
			{
				// Fetch available files
				if(dir)
				{
					dir->cd(voice);
					dir->cd(hour);
					list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot);
					if(list.count())
					{
						file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count())));
					}
					delete dir;
				}
				else
					LogError("Invalid GetLocalHTTPFolder()");
			}

			if(!file.isNull())
			{	
            	QByteArray fileR;
                dir = GetLocalHTTPFolder();
                if (voice == "tts")
                	voice = "violet";	// Directory default respiration TTS
				
				QString respiration = "respiration";	// Directory respiration
                if (dir->cd(voice) && dir->cd(respiration))
                {
                	list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot);
                    if(list.count())
					{	
                		fileR = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, respiration, list.at(qrand()%list.count())));
                    }
                }
                
                QByteArray message;
                if(!fileR.isNull())
                	message = "MU "+fileR+"\nPL 3\nMW\nMU "+file+"\nPL 3\nMW\nMU "+fileR+"\nPL 3\nMW\n";
                else
					message = "MU "+file+"\nPL 3\nMW\n";
                    
				b->SendPacket(MessagePacket(message));
			}
		}
	}
}