73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
#include "todomodule.h"
|
|
#include "message.h"
|
|
#include <time.h>
|
|
#include <QStringList>
|
|
|
|
TodoModule::TodoModule()
|
|
{
|
|
|
|
}
|
|
|
|
bool TodoModule::messageHandler(Message msg)
|
|
{
|
|
if(msg.command.compare(QString("PRIVMSG"), Qt::CaseInsensitive) == 0)
|
|
{
|
|
if(msg.args.startsWith("!todo "))
|
|
{
|
|
answer = usage(TODO);
|
|
Task t;
|
|
int deltaIndex = 1;
|
|
t.isPrivate = !msg.target.contains(getChan());
|
|
t.emitter = msg.nick;
|
|
t.date = time(NULL);
|
|
QStringList splitter = msg.args.split(' ');
|
|
if(splitter[deltaIndex].compare("to") == 0)
|
|
{
|
|
deltaIndex += 2;
|
|
t.emitter = splitter[2];
|
|
}
|
|
if(splitter.size() < deltaIndex+2)
|
|
return true;
|
|
QString dateString = splitter[deltaIndex];
|
|
if(dateString.startsWith("date("))
|
|
{
|
|
//t.date += dateString;
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
QString TodoModule::usage(int type)
|
|
{
|
|
switch(type)
|
|
{
|
|
case TODO:
|
|
return say("usage = !todo [to TARGET] DATE | DURATION [every DURATION] DESCRIPTION");
|
|
case DURATION:
|
|
return say("DURATION = HOURS[:MINUTES[:SECONDS]]");
|
|
case DATE:
|
|
return say("DATE = date(DAY/MONTH-[HOUR[:MINUTE[:SECOND]]])");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void TodoModule::addTask(unsigned long date, unsigned long repeat, QString description, QString emitter, QString recipient, bool isPrivate)
|
|
{
|
|
Task t;
|
|
t.date = date;
|
|
t.description = description;
|
|
t.emitter = emitter;
|
|
t.recipient = recipient;
|
|
t.repeat = repeat;
|
|
t.isPrivate = isPrivate;
|
|
tasks.push_back(t);
|
|
// TODO -> append it to save file
|
|
}
|