X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Bot.pm;h=e25918221d2dcb02af98c76f5883dffa7c718714;hb=b8bf12b07ac296bd878c20951ee6435515bae169;hp=078563d8bdfa3e85e0f78da7c48d5cbd30b35799;hpb=6e09408e9745c52f46cfb9fbf337a3935a03dc07;p=NDIRC.git diff --git a/Bot.pm b/Bot.pm index 078563d..e259182 100644 --- a/Bot.pm +++ b/Bot.pm @@ -239,16 +239,16 @@ sub sig_usr2 { 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"; @@ -371,7 +371,7 @@ sub discord_channel_create { 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?://}){ @@ -385,6 +385,8 @@ sub handleCommand { say localtime(time) . " - $msg"; + $c->dm_reply(1) if $p eq '!'; + return $self->disp->run_command($c,$command,$args); }