summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonas Smedegaard <jonas@atreju.jones.dk>2012-10-11 23:13:39 +0200
committerJonas Smedegaard <jonas@atreju.jones.dk>2012-10-11 23:13:39 +0200
commite102baef1e60c6ee866ebf6e817490935fdd703a (patch)
tree26a272b507885194dc9029637064713e59255c13 /lib
parenta5f3b76aa8fd1c8d13695f814d61c8bda767d021 (diff)
Separate Kannel stub code as new Status command plugin.
Diffstat (limited to 'lib')
-rw-r--r--lib/App/smsg/Command/Status.pm56
-rw-r--r--lib/App/smsg/Command/Talk.pm21
2 files changed, 56 insertions, 21 deletions
diff --git a/lib/App/smsg/Command/Status.pm b/lib/App/smsg/Command/Status.pm
new file mode 100644
index 0000000..019cd5b
--- /dev/null
+++ b/lib/App/smsg/Command/Status.pm
@@ -0,0 +1,56 @@
+package App::smsg::Command::Status;
+
+use 5.010;
+use strict;
+use warnings;
+use utf8;
+
+BEGIN {
+ $App::smsg::Command::Status::AUTHORITY = 'https://dr.jones.dk/me#me';
+ $App::smsg::Command::Status::VERSION = '0.001';
+}
+
+use App::smsg -command;
+use namespace::clean;
+
+use NetSDS::Kannel;
+#use Coro;
+
+use constant abstract => q (Check status of platform(s).);
+use constant usage_desc => '%c status %o <platform>...';
+use constant description => <<'DESCRIPTION';
+Connect to one or more platforms (Kannel, Jabber, IRC etc.) and check
+operational status.
+DESCRIPTION
+use constant opt_spec => (
+ ['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"],
+);
+
+sub execute {
+ my ($self, $opt, $args) = @_;
+
+ # 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,
+ );
+
+ die 'FIXME: unimplemented!';
+
+}
+
+1;
diff --git a/lib/App/smsg/Command/Talk.pm b/lib/App/smsg/Command/Talk.pm
index cffdaa5..9f853f7 100644
--- a/lib/App/smsg/Command/Talk.pm
+++ b/lib/App/smsg/Command/Talk.pm
@@ -20,8 +20,6 @@ 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 constant abstract => q (Respond (stupidly simple) when addressed in a Jabber MUC.);
use constant usage_desc => '%c talk %o <jid> <password> <talkfile> [<room>]';
@@ -30,16 +28,6 @@ Connect to a Jabber MUC (a.k.a. chatroom) and emit a (silly) reply to
each message posted which starts with bot name and a colon.
DESCRIPTION
use constant opt_spec => (
- ['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"],
);
@@ -55,15 +43,6 @@ sub execute {
my ($jid, $pw, $inputfile, $room) = @$args;
-# 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;
sub read_messages {