#include "WeatherPlugin.h" #include "ISmsTransceiver.h" #include "Sms.h" #include "Util.h" using namespace std; using namespace Util; WeatherPlugin::WeatherPlugin() : Plugin("vejr", "Find danish weather report on dmi.dk") { } void WeatherPlugin::Execute(ISmsTransceiver& modem, SMS& sms) { string doc = Util::readUrl("http://www.dmi.dk/dmi/danmark.htm","/tmp/sms_vejr.tmp"); int pos = doc.find(""); int pos2 = doc.find("",pos); string title = doc.substr(pos, (pos2-pos) ); title = str_trim( str_striptags(title) ) + "\n"; pos = doc.find("",pos); string section = doc.substr(pos, (pos2-pos) ); section = str_trim( str_striptags(section) ); section = str_characters( section ); section = str_replace(section, "\r"); section = str_replace(section, " \n"); section = str_replace(section, " ", " "); section = str_replace(section, "\n\n\n", "\n"); section = str_replace(section, "\n\n", "\n"); modem.SendSms(sms.GetSender(), title + section, true); }