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

Annotation of /smsdaemon/plugins/oldSpamPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 678 - (hide annotations) (download)
Tue Apr 27 21:06:53 2010 UTC (14 years, 1 month ago) by torben
File size: 1130 byte(s)
undo previous unintentional commit
1 torben 28 #include "SpamPlugin.h"
2 torben 149 #include "ISmsTransceiver.h"
3 torben 90 #include "Sms.h"
4 torben 28
5 torben 158 #include "Util.h"
6 torben 157 #include "Logger.h"
7 torben 28 #include <sstream>
8 torben 114 #include <stdlib.h>
9 torben 28
10    
11     using namespace std;
12    
13    
14     SpamPlugin::SpamPlugin()
15 torben 196 : Plugin("spam", "Sends a number of messages to a given phone nr")
16 torben 28 {
17     }
18    
19     const string USAGE = "Usage: spam <recipient> <nr> message";
20    
21 torben 149 void SpamPlugin::Execute(ISmsTransceiver& modem, SMS& sms)
22 torben 28 {
23 torben 142 string cmd = sms.ExtractParameters();
24 torben 28
25    
26     if (cmd == "")
27     {
28 torben 142 modem.SendSms(sms.GetSender(), USAGE, false);
29 torben 28 return;
30     }
31 torben 196
32 torben 28 vector<string> parts = Util::str_split(cmd," ");
33    
34    
35     if (parts.size() < 2 )
36     {
37 torben 142 modem.SendSms(sms.GetSender(), USAGE, false);
38 torben 28 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 torben 196
46 torben 28 ostringstream os;
47     os << "Spamming " << nr << " " << count << " times.";
48 torben 442 modem.SendSms(sms.GetSender(), os.str(), false);
49    
50 torben 157 Logger::logMessage(os.str());
51 torben 28
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 torben 63 modem.SendSms(nr,message, false);
63 torben 28 }
64     }

  ViewVC Help
Powered by ViewVC 1.1.20