]> ruin.nu Git - NDIRC.git/commitdiff
Update for new Mojo::Discord compatibility
authorMichael Andreen <harv@ruin.nu>
Sun, 21 Jun 2020 13:34:32 +0000 (15:34 +0200)
committerMichael Andreen <harv@ruin.nu>
Sun, 21 Jun 2020 13:34:32 +0000 (15:34 +0200)
Bot.pm
Delling.pm

diff --git a/Bot.pm b/Bot.pm
index e20412974d739aed53fcab70262188d564a3bc3f..078563d8bdfa3e85e0f78da7c48d5cbd30b35799 100644 (file)
--- a/Bot.pm
+++ b/Bot.pm
@@ -121,13 +121,12 @@ sub _start {
        ));
 
        $heap->{connector} = POE::Component::IRC::Plugin::Connector->new(
-               servers => [['irc.netgamers.org'], ['underworld.no.eu.netgamers.org']
-                       ,['firefly.no.eu.netgamers.org'], ['underworld.ca.us.netgamers.org'] ]
+               servers => [['chronos.fr.eu.netgamers.org'], ['underworld.no.eu.netgamers.org']]
        );
        $irc->plugin_add( 'Connector' => $heap->{connector} );
 
        $irc->yield( register => 'all' );
-       $irc->yield( connect => { server => 'irc.netgamers.org' } );
+       #$irc->yield( connect => { server => 'chronos.fr.eu.netgamers.org' } );
 
        $kernel->delay( refresh => 60 );
 
@@ -142,15 +141,16 @@ sub _start {
                                'name'      => $user,
                                'url'       => 'https://nd.ruin.nu',
                                'version'   => '1.0',
-                               'callbacks' => {
-                                       '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,
+                               'logdir'   => '/tmp',
                        ));
+
+               $self->discord->gw->on('MESSAGE_CREATE' => 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(@_) });
+
                $self->discord->init();
        }
        return;
@@ -339,8 +339,8 @@ sub irc_join {
 }
 
 sub discord_ready {
-       my $self = shift;
-       my $hash = shift;
+       my ($self, $gw, $hash) = @_;
+
        $self->discord_id($hash->{user}{id});
        $self->discord_name($hash->{user}{username});
 
@@ -351,8 +351,7 @@ sub discord_message_create {
 }
 
 sub discord_guild_create {
-       my $self = shift;
-       my $hash = shift;
+       my ($self, $gw, $hash) = @_;
 
        for my $chan (@{$hash->{channels}}) {
                say localtime(time) . " - $chan->{id} - $chan->{name}";
@@ -361,8 +360,7 @@ sub discord_guild_create {
 }
 
 sub discord_channel_create {
-       my $self = shift;
-       my $chan = shift;
+       my ($self, $gw, $chan) = @_;
 
        for my $key (keys %{$chan}) {
                say localtime(time) . " - $key - $chan->{$key}";
index 545df2fdc8aeaab7b886ac415422ad42ff4882da..fea261ed48246afc4200fede1883a350f1246534 100644 (file)
@@ -220,8 +220,7 @@ after _start => sub {
 };
 
 after discord_message_create => sub {
-       my $self = shift;
-       my $hash = shift;
+       my ($self, $gw, $hash) = @_;
 
        my $author = $hash->{author};
        my $msg = $hash->{content};