));
$self->discord->gw->on('MESSAGE_CREATE' => sub { $self->discord_message_create(@_) });
+ $self->discord->gw->on('MESSAGE_UPDATE' => sub { $self->discord_message_create(@_) });
$self->discord->gw->on('READY' => sub { $self->discord_ready(@_) });
$self->discord->gw->on('GUILD_CREATE' => sub { $self->discord_guild_create(@_) });
$self->discord->gw->on('CHANNEL_CREATE' => sub { $self->discord_channel_create(@_) });
sub _build_disp {
my ($self) = @_;
- my $disp = new NDIRC::Dispatcher;
+ my $disp = NDIRC::Dispatcher->new;
- if (my $commands = new IO::File 'commands'){
+ if (my $commands = IO::File->new('commands')){
my @commands = split /\W+/, do{local $/; <$commands>};
say "Loading commands from: @commands";
$disp->load(@commands);
}
%{$self->targets} = ();
- my $channels = new IO::File 'channels' or die $!;;
+ my $channels = IO::File->new('channels') or die $!;;
while (<$channels>){
my ($chan, @types) = split /\s+/;
say "$chan - @types";
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?://}){
say localtime(time) . " - $msg";
+ $c->dm_reply(1) if $p eq '!';
+
return $self->disp->run_command($c,$command,$args);
}