22 "transport=s" => \$ARG_TRANSPORTCFG,
23 "verbose" => \$ARG_VERBOSE,
24 "cachefile=s" => \$ARG_CACHEFILE,
28 unless ( $ARG_CACHEFILE && $ARG_ACL && $ARG_TRANSPORTCFG ) {
30 Usage: $0 --transport=<file with transport config> --cachefile=<file to keep cache> --acl=<comma seperated msisdn regexs> [--verbose]
32 transport File that contains the transport configuration.
34 cachefile File to keep latest headlines. Slashdot asks only to hit
35 the server 1 time in an hour, so we obey.
37 acl Comma seperated list of regular expression of msisdn
40 --acl=".*" : allow everybody
41 --acl="^\+32475,^\+32478" : allow these prefixes
42 --acl="^\+32475000000" : allow this number
44 verbose Print out info.
46 To access /. through a proxy ( bash ):
47 export http_proxy=http://proxy:port
57 my $CFG_TIMEOUT = 60*60; # 60 minutes, as asked by slashdot ...
58 my @CFG_ACL = split /,/, $ARG_ACL;
63 verb( join( " ", split( //, "SLASHDOT HEADLINES") ) . "\n\n" );
68 my $nbs = GSM::SMS::NBS->new( $ARG_TRANSPORTCFG );
70 die "Sorry ... could not activate NBS stack ($!) ... check transport logfiles\n"
79 verb( "waiting for message ..." );
81 $nbs->receive( \$msisdn,
93 transport: $transportname
95 --------------------------------------------------------------------------
97 --------------------------------------------------------------------------
103 if ( grep { $msisdn =~ /$_/ } @CFG_ACL ) {
104 verb( "acl pass\n" );
105 # check for code word
106 if ( $message =~ /^sld/i ) {
108 $stats = stat($ARG_CACHEFILE);
110 unless ($stats && (time - $stats->mtime) < $CFG_TIMEOUT) {
111 verb( "Getting new SLASHDOT headlines\n" );
112 getstore('http://www.slashdot.org/slashdot.xml', $ARG_CACHEFILE);
115 open XML,$ARG_CACHEFILE or die("Cannot open $ARG_CACHEFILE for read: $!");
116 my $data = join "", <XML>;
120 while ($data =~ m#<title>(.*?)<\/title>#gsi) {
121 my $line = "*".$1."\n";
122 if (length($msg.$line)>160 || $msg eq "") {
126 $msg="SLASHDOT #pa/#fr\n\n";
132 my $from = sprintf("%02d",$#msg+1);
133 for($i=0;$i<=$#msg;$i++) {
134 my $page = sprintf("%02d",$i+1);
135 $msg[$i]=~s/#pa/$page/;
136 $msg[$i]=~s/#fr/$from/;
137 verb( "=" x 75 . "\n" );
139 verb( "." x 75 . "\n\n");
140 if ($nbs->sendSMSTextMessage( $msisdn, $msg[$i] )) {
141 verb("!ERROR SENDING! *check logfile*\n");
153 print shift if $ARG_VERBOSE;