sub handleCommand {
my ($self, $c, $msg) = @_;
- my ($p,$command,$args) = ($msg =~ /^([.])(\S+)(?: (.+))?/);
+ my ($p,$command,$args) = ($msg =~ /^([.!])(\S+)(?: (.+))?/);
if ($msg =~ m{https?://[\w.]+/.+?scan(_id|_grp)?=(\w+)}){
if (!$command || $command =~ m{^https?://}){
}
}
+ $c->dm_reply(1) if $p eq '!';
+
return 0 unless $self->disp->has_command($command,$c->channel);
say localtime(time) . " - $msg";
my $c = NDIRC::DiscordContext->new({
discord_id => $author_name,
channel_id => $channel_id,
+ author_id => $author_id,
channel => $channel,
disp => $self->disp,
model => DB(),
required => 1
);
+has author_id => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1
+);
+
has discord => (
is => 'ro',
isa => 'Object',
required => 1
);
+has dm_reply => (
+ is => 'rw',
+ isa => 'Bool',
+ required => 0,
+ default => 0
+);
+
sub reply {
my ($self,$msg) = @_;
- $self->message($self->channel_id, $msg);
+ if ($self->dm_reply)
+ {
+ $msg =~ s`<b>(.*?)</b>`**$1**`gi;
+ $msg =~ s`<c(\d+)>(.*?)</c>`*$2*`gi;
+ $self->discord->send_dm($self->author_id, $msg);
+ }
+ else
+ {
+ $self->message($self->channel_id, $msg);
+ }
}
sub message {