]>
iEval git - app-remotegnokii.git/blob - lib/App/RemoteGnokii.pm
1 package App
:: RemoteGnokii
;
6 our $VERSION = '0.000_001' ;
9 use File
:: Copy qw
/move/ ;
10 use File
:: Temp qw
/tempfile/ ;
15 sub cfg
($){ ## no critic (ProhibitSubroutinePrototypes)
17 $cfg = Config
:: Any
-> load_stems ({ stems
=> [ $ENV { RGCONFIG
} // '/etc/rg' ], use_ext
=> 1 , flatten_to_hash
=> 1 });
18 my @cfg = values % $cfg ;
26 my ( $number , $text ) = @_ ;
27 my ( $fh , $file ) = tempfile
'smsXXXX' , TMPDIR
=> 1 ;
28 print $fh " $number \n $text " or warn "print: $!" ; ## no critic (RequireCarping)
29 close $fh or warn "close: $!" ; ## no critic (RequireCarping)
30 move
$file , cfg
'spool' ;
33 ##################################################
36 my ( $number , $date , $text ) = @_ ;
37 my $password = cfg
'password' ;
38 sendsms cfg
'number' , <<"EOF"
47 my $correct_password = cfg
'password' ;
49 my $r = Plack
:: Request
-> new ( shift );
50 my @numbers = split /,/s , $r -> param ( 'numbers' );
51 my $password = $r -> param ( 'password' );
52 return [ 403 , [ 'Content-Type' , 'text/plain' ], [ 'Bad password' ]] unless $password eq $correct_password ;
53 my $text = $r -> param ( 'text' );
55 sendsms
$_ , $text for @numbers
66 App::RemoteGnokii - Send SMS over the internet with gnokii-smsd
70 use App::RemoteGnokii;
71 my $config_option = App::RemoteGnokii::cfg 'name';
72 App::RemoteGnokii::sendsms '0755555555', 'Hello world';
73 App::RemoteGnokii::action('0755555555', '2014-02-01', 'Goodbye');
77 RemoteGnokii is a set of scripts that add networking to gnokii-smsd. With them, all messages received are forwarded to a given phone number, and messages can be sent via the HTTP gateway provided by RemoteGnokii.
79 =head1 CONFIGURATION OPTIONS
81 See below for the location of the configuration file. The following options are recognised:
87 Forward incoming messages to this number (used by L<rg-action>).
91 The password needed to send a message with L<rg-psgi> and included in forwarded messages.
95 The gnokii-smsd spool directory. Needs to be readable and writable by gnokii-smsd and L<rg-psgi>.
105 The basename of the configuration file. For example, if the configuration file is '/srv/rg/config.yml', RGCONF should be set to '/srv/rg/config'. Defaults to '/etc/rg'.
113 =item Write a section 7 manpage explaining everything
117 =item Add a way to store messages for later retrieval via the webapp, instead of sending them immediately via SMS
123 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
125 =head1 COPYRIGHT AND LICENSE
127 Copyright (C) 2014 by Marius Gavrilescu
129 This library is free software: you can redistribute it and/or modify
130 it under the terms of the GNU General Public License as published by
131 the Free Software Foundation, either version 3 of the License, or (at
132 your option) any later version.
This page took 0.058853 seconds and 5 git commands to generate.