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

Contents of /smsdaemon/plugins/SpamPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90 - (show annotations) (download)
Mon Jun 16 10:21:02 2008 UTC (15 years, 11 months ago) by torben
File size: 1041 byte(s)
Move IGsmModem to its own header file.

1 #include "SpamPlugin.h"
2 #include "IGsmModem.h"
3 #include "Sms.h"
4
5 #include "util.h"
6 #include "common.h"
7 #include <sstream>
8
9
10 using namespace std;
11
12
13 SpamPlugin::SpamPlugin()
14 : Plugin("spam", "Sends a number of messages to a given phone nr")
15 {
16 }
17
18 const string USAGE = "Usage: spam <recipient> <nr> message";
19
20 void SpamPlugin::Execute(IGsmModem& modem, SMS& sms)
21 {
22 string cmd = GetSmsData(sms);
23
24
25 if (cmd == "")
26 {
27 modem.SendSms(sms.sender, USAGE, false);
28 return;
29 }
30
31 vector<string> parts = Util::str_split(cmd," ");
32
33
34 if (parts.size() < 2 )
35 {
36 modem.SendSms(sms.sender, USAGE, false);
37 return;
38 }
39
40 string nr = parts[0];
41 unsigned int count = atoi(parts[1].c_str());
42 if (count > 25)
43 count = 25;
44
45 ostringstream os;
46 os << "Spamming " << nr << " " << count << " times.";
47 Common::instance()->logMessage(os.str());
48
49 string message;
50 for (unsigned i=2; i<parts.size(); ++i)
51 {
52 if (message.length() > 0)
53 message += " ";
54 message += parts[i];
55 }
56
57 for (unsigned i=0; i<count; ++i)
58 {
59 modem.SendSms(nr,message, false);
60 }
61 }

  ViewVC Help
Powered by ViewVC 1.1.20