1 |
torben |
520 |
#include "DelaySpamPlugin.h" |
2 |
|
|
#include "ISmsTransceiver.h" |
3 |
|
|
#include "Sms.h" |
4 |
|
|
|
5 |
|
|
#include "tasks/DelaySpamTask.h" |
6 |
|
|
#include "TaskManager.h" |
7 |
|
|
|
8 |
|
|
#include "Common.h" |
9 |
|
|
#include "Logger.h" |
10 |
|
|
#include "Util.h" |
11 |
|
|
|
12 |
|
|
#include <stdlib.h> |
13 |
|
|
|
14 |
|
|
#include <sstream> |
15 |
|
|
#include <string> |
16 |
|
|
#include <vector> |
17 |
|
|
|
18 |
|
|
using namespace std; |
19 |
|
|
|
20 |
|
|
const string USAGE = "Usage: delayspam <recipient> <nr> <interval> message"; |
21 |
|
|
|
22 |
|
|
DelaySpamPlugin::DelaySpamPlugin() |
23 |
|
|
: Plugin("delayspam", "Like spam plugin but with interval between transmitted SMS") |
24 |
|
|
{ |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
void DelaySpamPlugin::Execute(ISmsTransceiver& modem, SMS& sms) |
28 |
|
|
{ |
29 |
|
|
|
30 |
|
|
string cmd = sms.ExtractParameters(); |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
if (cmd == "") |
34 |
|
|
{ |
35 |
|
|
modem.SendSms(sms.GetSender(), USAGE, false); |
36 |
|
|
return; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
vector<string> parts = Util::str_split(cmd," "); |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
if (parts.size() < 3 ) |
43 |
|
|
{ |
44 |
|
|
modem.SendSms(sms.GetSender(), USAGE, false); |
45 |
|
|
return; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
string nr = parts[0]; |
49 |
|
|
unsigned int count = atoi( parts[1].c_str() ); |
50 |
|
|
unsigned int interval = atoi( parts[2].c_str() ); |
51 |
|
|
if (count > 25) |
52 |
|
|
count = 25; |
53 |
|
|
|
54 |
|
|
string message; |
55 |
|
|
for (unsigned i=3; i<parts.size(); ++i) |
56 |
|
|
{ |
57 |
|
|
if (message.length() > 0) |
58 |
|
|
message += " "; |
59 |
|
|
message += parts[i]; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
ostringstream os; |
63 |
|
|
os << "Spamming " << nr << ", " << count << " times, with an interval on " << interval << " minutes"; |
64 |
|
|
modem.SendSms(sms.GetSender(), os.str(), false); |
65 |
|
|
|
66 |
|
|
Logger::logMessage(os.str()); |
67 |
|
|
|
68 |
|
|
DelaySpamTask* task = new DelaySpamTask(); |
69 |
|
|
task->SetDestination( nr ); |
70 |
|
|
task->SetNumber( count ); |
71 |
|
|
task->SetInterval( interval ); |
72 |
|
|
task->SetMessage( message ); |
73 |
|
|
|
74 |
|
|
task->RegisterTask();//register with taskmanager |
75 |
|
|
|
76 |
|
|
} |