]> ruin.nu Git - NDIRC.git/blobdiff - Bot.pm
Use discord channel id
[NDIRC.git] / Bot.pm
diff --git a/Bot.pm b/Bot.pm
index 9bf39f9ae09c612b88bdca9100558b1a4f505955..0a65f8fbafc11c7f84f7774579bb36e9818f1dd2 100644 (file)
--- a/Bot.pm
+++ b/Bot.pm
@@ -36,7 +36,7 @@ use Mojo::Discord;
 use Mojo::IOLoop;
 
 use NDIRC::Dispatcher;
-use NDIRC::Context;
+use NDIRC::IrcContext;
 
 use IO::File;
 
@@ -134,6 +134,7 @@ sub _start {
                                        'READY'          => sub { $self->discord_ready(@_) },
                                        'MESSAGE_CREATE' => sub { $self->discord_message_create(@_) },
                                        'GUILD_CREATE' => sub { $self->discord_guild_create(@_) },
+                                       'CHANNEL_CREATE' => sub { $self->discord_channel_create(@_) },
                                },
                                'reconnect' => 1,
                                'verbose'   => 1,
@@ -339,11 +340,21 @@ sub discord_guild_create {
        my $hash = shift;
 
        for my $chan (@{$hash->{channels}}) {
-               say localtime(time) . "$chan->{id} - $chan->{name}";
-               $self->discord_channels->{$chan->{id}} = $chan->{name};
+               say localtime(time) . " - $chan->{id} - $chan->{name}";
+               $self->discord_channels->{$chan->{id}} = $chan;
        }
 }
 
+sub discord_channel_create {
+       my $self = shift;
+       my $chan = shift;
+
+       for my $key (keys %{$chan}) {
+               say localtime(time) . " - $key - $chan->{$key}";
+       }
+       $self->discord_channels->{$chan->{id}} = $chan;
+}
+
 sub parseCommand {
        my ($self, $msg, $server, $nick, $address, $channel, $model) = @_;
 
@@ -376,7 +387,7 @@ sub parseCommand {
        }
 
        $address =~ s/.*@(.*)/$1/;
-       my $c = NDIRC::Context->new({
+       my $c = NDIRC::IrcContext->new({
                        host => $address,
                        nick => $nick,
                        channel => $channel,