-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightwood.pm
49 lines (38 loc) · 1.08 KB
/
Lightwood.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl -wT
# ==== SETUP
package Lightwood;
use strict;
use Lightwood::Slack::App;
use Lightwood::TestCommands qw(%commands);
# Try to load the instance commands from the Commands submodule
my $instance_commands = eval {
no warnings 'once';
require Lightwood::Commands;
Lightwood::Commmands->import();
\%Lightwood::Commands::commands
};
# Create the app
sub new {
my ($class) = @_;
my $lightwood = Lightwood::Slack::App->new();
# Add the "/lw" command
my $lw = $lightwood->slash_command("lw",
usage => "I'm Lightwood. I can help you interact with the wiki. " .
"To do so, use the `/lw` command.");
# Add test subcommands
my %test_commands = %Lightwood::TestCommands::commands;
for my $name (keys %test_commands) {
$lw->subcommand($name, %{$test_commands{$name}})
}
# Add instance (sub-)commands, if any
if ($instance_commands) {
for my $name (keys %$instance_commands) {
$lw->subcommand($name, %{$$instance_commands{$name}})
}
} else {
print STDERR "WARNING: no instance commands defined!\n"
}
# Done
$lightwood
}
1