summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsmsbot45
1 files changed, 44 insertions, 1 deletions
diff --git a/smsbot b/smsbot
index 60fb8f6..6cf5995 100755
--- a/smsbot
+++ b/smsbot
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use strict;
use utf8;
+
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
@@ -8,6 +9,38 @@ use AnyEvent::XMPP::Ext::Version;
use AnyEvent::XMPP::Ext::MUC;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
use AnyEvent::XMPP::Util qw/node_jid res_jid/;
+use NetSDS::Kannel;
+#use Coro;
+
+use Getopt::Long::Descriptive;
+
+my ($opt, $usage) = describe_options(
+ '%c %o <jid> <password> <talkfile> [<room>]',
+ ['kannelserver=s', "the Kannel server to connect to",
+ {default => 'localhost'}],
+ ['kannelport=i', "the Kannel port to connect to",
+ {default => 13013}],
+ ['kanneluser=s', "the Kannel users to authenticate as",
+ {default => 'tester'}],
+ ['kannelpasswd=s', "the Kannel password to authenticate with",
+ {default => 'foobar'}],
+ ['kannelsmsc=s', "the Kannel SMSC to correspond with"],
+ [],
+# [ 'verbose|v', "print extra stuff"],
+ [ 'debug', "print debug stuff"],
+ [ 'help', "print usage message and exit"],
+);
+
+print($usage->text), exit if $opt->help;
+
+# TODO: support overriding full URL
+# TODO: use URI module to construct URL
+my $kannel = NetSDS::Kannel->new(
+ sendsms_url => 'http://' . $opt->kannelserver . ':' . $opt->kannelport . '/cgi-bin/sendsms',
+ sendsms_user => $opt->kanneluser,
+ sendsms_passwd => $opt->kannelpasswd,
+ default_smsc => $opt->kannelsmsc,
+);
my @msgs;
@@ -37,7 +70,7 @@ unless (@ARGV >= 3) {
read_messages ($inputfile);
my $j = AnyEvent->condvar;
-my $cl = AnyEvent::XMPP::Client->new (debug => 1);
+my $cl = AnyEvent::XMPP::Client->new (debug => $opt->debug);
my $disco = AnyEvent::XMPP::Ext::Disco->new;
my $version = AnyEvent::XMPP::Ext::Version->new;
my $muc = AnyEvent::XMPP::Ext::MUC->new (disco => $disco);
@@ -101,3 +134,13 @@ $cl->reg_cb (
$cl->start;
$j->wait;
+
+__END__
+
+=head1 COPYRIGHT
+
+2012 © Jonas Smedegaard <dr@jones.dk>
+
+=head1 BUGS
+
+Send Bug Reports to Jonas Smedegaard <dr@jones.dk>