/[projects]/smsdaemon/plugins/oldSpamPlugin.cpp
ViewVC logotype

Contents of /smsdaemon/plugins/oldSpamPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 678 - (show annotations) (download)
Tue Apr 27 21:06:53 2010 UTC (14 years ago) by torben
File size: 1130 byte(s)
undo previous unintentional commit
1 #include "SpamPlugin.h"
2 #include "ISmsTransceiver.h"
3 #include "Sms.h"
4
5 #include "Util.h"
6 #include "Logger.h"
7 #include <sstream>
8 #include <stdlib.h>
9
10
11 using namespace std;
12
13
14 SpamPlugin::SpamPlugin()
15 : Plugin("spam", "Sends a number of messages to a given phone nr")
16 {
17 }
18
19 const string USAGE = "Usage: spam <recipient> <nr> message";
20
21 void SpamPlugin::Execute(ISmsTransceiver& modem, SMS& sms)
22 {
23 string cmd = sms.ExtractParameters();
24
25
26 if (cmd == "")
27 {
28 modem.SendSms(sms.GetSender(), USAGE, false);
29 return;
30 }
31
32 vector<string> parts = Util::str_split(cmd," ");
33
34
35 if (parts.size() < 2 )
36 {
37 modem.SendSms(sms.GetSender(), USAGE, false);
38 return;
39 }
40
41 string nr = parts[0];
42 unsigned int count = atoi(parts[1].c_str());
43 if (count > 25)
44 count = 25;
45
46 ostringstream os;
47 os << "Spamming " << nr << " " << count << " times.";
48 modem.SendSms(sms.GetSender(), os.str(), false);
49
50 Logger::logMessage(os.str());
51
52 string message;
53 for (unsigned i=2; i<parts.size(); ++i)
54 {
55 if (message.length() > 0)
56 message += " ";
57 message += parts[i];
58 }
59
60 for (unsigned i=0; i<count; ++i)
61 {
62 modem.SendSms(nr,message, false);
63 }
64 }

  ViewVC Help
Powered by ViewVC 1.1.20