27 "transport=s" => \$ARG_TRANSPORTCFG,
28 "verbose" => \$ARG_VERBOSE,
29 "cachefile=s" => \$ARG_CACHEFILE,
33 unless ( $ARG_CACHEFILE && $ARG_ACL && $ARG_TRANSPORTCFG ) {
35 Usage: $0 --transport=<file with transport config> --cachefile=<file to keep cache> --acl=<comma seperated msisdn regexs> [--verbose]
37 transport File that contains the transport configuration.
39 cachefile File to keep latest headlines. Slashdot asks only to hit
40 the server 1 time in an hour, so we obey.
42 acl Comma seperated list of regular expression of msisdn
45 --acl=".*" : allow everybody
46 --acl="^\+32475,^\+32478" : allow these prefixes
47 --acl="^\+32475000000" : allow this number
49 verbose Print out info.
51 To access /. through a proxy ( bash ):
52 export http_proxy=http://proxy:port
62 my $CFG_TIMEOUT = 60*60; # 60 minutes, as asked by slashdot ...
63 my @CFG_ACL = split /,/, $ARG_ACL;
68 verb( join( " ", split( //, "SLASHDOT HEADLINES") ) . "\n\n" );
73 my $nbs = GSM::SMS::NBS->new( $ARG_TRANSPORTCFG );
81 verb( "waiting for message ..." );
83 $nbs->receive( \$msisdn,
95 transport: $transportname
97 --------------------------------------------------------------------------
99 --------------------------------------------------------------------------
105 if ( grep { $msisdn =~ /$_/ } @CFG_ACL ) {
106 verb( "acl pass\n" );
107 # check for code word
108 if ( $message =~ /^sld/i ) {
110 $stats = stat($ARG_CACHEFILE);
112 unless ($stats && (time - $stats->mtime) < $CFG_TIMEOUT) {
113 verb( "Getting new SLASHDOT headlines\n" );
114 getstore('http://www.slashdot.org/slashdot.xml', $ARG_CACHEFILE);
117 open XML,$ARG_CACHEFILE or die("Cannot open $ARG_CACHEFILE for read: $!");
118 my $data = join "", <XML>;
122 while ($data =~ m#<title>(.*?)<\/title>#gsi) {
123 my $line = "*".$1."\n";
124 if (length($msg.$line)>160 || $msg eq "") {
128 $msg="SLASHDOT #pa/#fr\n\n";
134 my $from = sprintf("%02d",$#msg+1);
135 for($i=0;$i<=$#msg;$i++) {
136 my $page = sprintf("%02d",$i+1);
137 $msg[$i]=~s/#pa/$page/;
138 $msg[$i]=~s/#fr/$from/;
139 verb( "=" x 75 . "\n" );
141 verb( "." x 75 . "\n\n");
142 $nbs->sendSMSTextMessage( $msisdn, $msg[$i] );
153 print shift if $ARG_VERBOSE;