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

Contents of /smsdaemon/plugins/SpamPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (show annotations) (download)
Wed Jun 11 08:25:34 2008 UTC (15 years, 11 months ago) by torben
File size: 1002 byte(s)
Intermediate code sync.

TrainInfo.*
TogPlugin.*: plugin to get train departure info from bane.dk

SpamPlugin.*
ShellExecPlugin.*
EchoPlugin.*
Plugin.h
GsmModem.h: implemented IGsmModem in order to make offline Plugin testing easier.


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

  ViewVC Help
Powered by ViewVC 1.1.20