]> ruin.nu Git - NDIRC.git/blobdiff - Bot.pm
reorganize context
[NDIRC.git] / Bot.pm
diff --git a/Bot.pm b/Bot.pm
index 89ec47d7c1e75ae9d7c3cb397b07e0b92b6a2026..1f5ff2102e50db0c18139449920b2bd969f884be 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;
 
@@ -61,6 +61,12 @@ has discord_id => (
        isa => 'Str'
 );
 
+has discord_channels => (
+       is => 'rw',
+       isa => 'HashRef',
+       default => sub { {} }
+);
+
 # We registered for all events, this will produce some debug info.
 sub _default {
        my ($event, $args) = @_[ARG0 .. $#_];
@@ -329,6 +335,13 @@ sub discord_message_create {
 }
 
 sub discord_guild_create {
+       my $self = shift;
+       my $hash = shift;
+
+       for my $chan (@{$hash->{channels}}) {
+               say localtime(time) . "$chan->{id} - $chan->{name}";
+               $self->discord_channels->{$chan->{id}} = $chan->{name};
+       }
 }
 
 sub parseCommand {
@@ -363,7 +376,7 @@ sub parseCommand {
        }
 
        $address =~ s/.*@(.*)/$1/;
-       my $c = NDIRC::Context->new({
+       my $c = NDIRC::IrcContext->new({
                        host => $address,
                        nick => $nick,
                        channel => $channel,