]> ruin.nu Git - NDIRC.git/blobdiff - Bot.pm
Minor discord fixes
[NDIRC.git] / Bot.pm
diff --git a/Bot.pm b/Bot.pm
index cbc0c5cd90332910e76871d705cd398bbe36cb4c..e20412974d739aed53fcab70262188d564a3bc3f 100644 (file)
--- a/Bot.pm
+++ b/Bot.pm
@@ -255,7 +255,7 @@ sub _build_disp {
                if ($chan =~ /^(.*):(.*)$/){
                        $chan = $1;
                        $self->targets->{$2} = [] unless exists $self->targets->{$2};
-                       push @{$self->targets->{$2}},$chan;
+                       push @{$self->targets->{$2}},lc $chan;
                        say "$2 - @{$self->targets->{$2}}";
                }
                $disp->add_channel($chan,\@types);
@@ -370,6 +370,26 @@ sub discord_channel_create {
        $self->discord_channels->{$chan->{id}} = $chan;
 }
 
+sub handleCommand {
+       my ($self, $c, $msg) = @_;
+
+       my ($p,$command,$args) = ($msg =~ /^([.])(\S+)(?: (.+))?/);
+
+       if ($msg =~ m{https?://[\w.]+/.+?scan(_id|_grp)?=(\w+)}){
+               if (!$command || $command =~ m{^https?://}){
+                       ($p,$command,$args) = ('.','addscan',$msg);
+               }elsif($command ne 'addscan'){
+                       $self->handleCommand ($c, ".addscan $msg")
+               }
+       }
+
+       return 0 unless $self->disp->has_command($command,$c->channel);
+
+       say localtime(time) . " - $msg";
+
+       return $self->disp->run_command($c,$command,$args);
+}
+
 sub parseCommand {
        my ($self, $msg, $server, $nick, $address, $channel, $model) = @_;
 
@@ -429,7 +449,7 @@ sub message {
        my ($self, $msg, @targets) = @_;
 
        for (@targets) {
-               when (/^D-(\d+)$/) {
+               when (/^D-(\d+)$/i) {
                        $self->discordMessage($1, $msg);
                }
                default {