Added hook on_connect and moved on connect stuff to Core::IRC.
This commit is contained in:
1 parent
4ea3945c21
commit
b44cd33c65
3 files changed
+53
-28
No files matched your search
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Added on_connect hook, triggered after we receive 001.
|
||||||
* Updated hooks to use hashrefs.
|
* Updated hooks to use hashrefs.
|
||||||
* Moved CTCP VERSION reply to Core::IRC.
|
* Moved CTCP VERSION reply to Core::IRC.
|
||||||
* Renamed Core::IRC to Core::Cmd.
|
* Renamed Core::IRC to Core::Cmd.
|
||||||
|
|||||||
+48
-1
@@ -7,7 +7,7 @@ package Core::IRC;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use API::Std qw(hook_add);
|
use API::Std qw(hook_add conf_get);
|
||||||
use API::IRC qw(notice usrc);
|
use API::IRC qw(notice usrc);
|
||||||
our $VERSION = 3.000000;
|
our $VERSION = 3.000000;
|
||||||
|
|
||||||
@@ -41,5 +41,52 @@ hook_add("on_quit", "quit_update_chanusers", sub {
|
|||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# Modes on connect.
|
||||||
|
hook_add("on_connect", "on_connect_modes", sub {
|
||||||
|
my ($svr) = @_;
|
||||||
|
|
||||||
|
if (conf_get("server:$svr:modes")) {
|
||||||
|
my $connmodes = (conf_get("server:$svr:modes"))[0][0];
|
||||||
|
API::IRC::umode($svr, $connmodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
# Plaintext auth.
|
||||||
|
hook_add("on_connect", "plaintext_auth", sub {
|
||||||
|
my ($svr) = @_;
|
||||||
|
|
||||||
|
if (conf_get("server:$svr:idstr")) {
|
||||||
|
my $idstr = (conf_get("server:$svr:idstr"))[0][0];
|
||||||
|
Auto::socksnd($svr, $idstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
# Auto join.
|
||||||
|
hook_add("on_connect", "autojoin", sub {
|
||||||
|
my ($svr) = @_;
|
||||||
|
|
||||||
|
# Get the auto-join from the config.
|
||||||
|
my @cajoin = @{ (conf_get("server:$svr:ajoin"))[0] };
|
||||||
|
|
||||||
|
# Join the channels.
|
||||||
|
if (!defined $cajoin[1]) {
|
||||||
|
# For single-line ajoins.
|
||||||
|
my @sajoin = split(',', $cajoin[0]);
|
||||||
|
|
||||||
|
API::IRC::cjoin($svr, $_) foreach (@sajoin);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# For multi-line ajoins.
|
||||||
|
API::IRC::cjoin($svr, $_) foreach (@cajoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
# vim: set ai sw=4 ts=4:
|
# vim: set ai sw=4 ts=4:
|
||||||
+4
-27
@@ -38,6 +38,7 @@ our %RAWC = (
|
|||||||
our (%got_001, %botnick, %botchans, %csprefix, %chanusers, %chanmodes);
|
our (%got_001, %botnick, %botchans, %csprefix, %chanusers, %chanmodes);
|
||||||
|
|
||||||
# Events.
|
# Events.
|
||||||
|
API::Std::event_add("on_connect");
|
||||||
API::Std::event_add("on_rcjoin");
|
API::Std::event_add("on_rcjoin");
|
||||||
API::Std::event_add("on_ucjoin");
|
API::Std::event_add("on_ucjoin");
|
||||||
API::Std::event_add("on_kick");
|
API::Std::event_add("on_kick");
|
||||||
@@ -97,34 +98,10 @@ sub num001
|
|||||||
$botnick{$svr}{nick} = $botnick{$svr}{newnick};
|
$botnick{$svr}{nick} = $botnick{$svr}{newnick};
|
||||||
delete $botnick{$svr}{newnick};
|
delete $botnick{$svr}{newnick};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Modes on connect.
|
# Trigger on_connect.
|
||||||
unless (!conf_get("server:$svr:modes")) {
|
API::Std::event_run("on_connect", $svr);
|
||||||
my $connmodes = (conf_get("server:$svr:modes"))[0][0];
|
|
||||||
API::IRC::umode($svr, $connmodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Identify string.
|
|
||||||
unless (!conf_get("server:$svr:idstr")) {
|
|
||||||
my $idstr = (conf_get("server:$svr:idstr"))[0][0];
|
|
||||||
Auto::socksnd($svr, $idstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the auto-join from the config.
|
|
||||||
my @cajoin = @{ (conf_get("server:$svr:ajoin"))[0] };
|
|
||||||
|
|
||||||
# Join the channels.
|
|
||||||
if (!defined $cajoin[1]) {
|
|
||||||
# For single-line ajoins.
|
|
||||||
my @sajoin = split(',', $cajoin[0]);
|
|
||||||
|
|
||||||
API::IRC::cjoin($svr, $_) foreach (@sajoin);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# For multi-line ajoins.
|
|
||||||
API::IRC::cjoin($svr, $_) foreach (@cajoin);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user