Add ban() to API::IRC. Also, bantype is now a required config value.
This commit is contained in:
1 parent
f97b55a56c
commit
7dbebdeca9
4 files changed
+40
-3
No files matched your search
@@ -28,6 +28,7 @@ Incompatibilities:
|
|||||||
* Database: Changed structure of the `qdb` table. Modify the configuration
|
* Database: Changed structure of the `qdb` table. Modify the configuration
|
||||||
values in upgrade.pl then run it to upgrade the database.
|
values in upgrade.pl then run it to upgrade the database.
|
||||||
* database:format is now required in the config.
|
* database:format is now required in the config.
|
||||||
|
* bantype is now required in the config.
|
||||||
|
|
||||||
We thank you for choosing Auto. Please remember that he is still in early
|
We thank you for choosing Auto. Please remember that he is still in early
|
||||||
development stages. But we hope we've piqued your interest, as Auto's upcoming
|
development stages. But we hope we've piqued your interest, as Auto's upcoming
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ if (conf_get('die')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check for required configuration values.
|
# Check for required configuration values.
|
||||||
my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit database:format);
|
my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit database:format bantype);
|
||||||
foreach my $REQCVAL (@REQCVALS) {
|
foreach my $REQCVAL (@REQCVALS) {
|
||||||
if (!conf_get($REQCVAL)) {
|
if (!conf_get($REQCVAL)) {
|
||||||
my $err = 2;
|
my $err = 2;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
* bantype is now a required configuration value.
|
||||||
|
* Added ban() to API::IRC.
|
||||||
* Changed on_cprivmsg arguments to: \%src, $channel, @msg
|
* Changed on_cprivmsg arguments to: \%src, $channel, @msg
|
||||||
* Changed on_uprivmsg arguments to: \%src, @msg
|
* Changed on_uprivmsg arguments to: \%src, @msg
|
||||||
* Bug fix: Commands getting Permission denied even with incorrect prefix.
|
* Bug fix: Commands getting Permission denied even with incorrect prefix.
|
||||||
|
|||||||
+36
-2
@@ -4,13 +4,47 @@
|
|||||||
package API::IRC;
|
package API::IRC;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use feature qw(switch);
|
||||||
use Exporter;
|
use Exporter;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT_OK = qw(cjoin cpart cmode umode kick privmsg notice quit nick names topic
|
our @EXPORT_OK = qw(ban cjoin cpart cmode umode kick privmsg notice quit nick names
|
||||||
usrc match_mask);
|
topic usrc match_mask);
|
||||||
|
|
||||||
|
|
||||||
|
# Set a ban, based on config bantype value.
|
||||||
|
sub ban
|
||||||
|
{
|
||||||
|
my ($svr, $chan, $type, $user) = @_;
|
||||||
|
my $cbt = (API::Std::conf_get('bantype'))[0][0];
|
||||||
|
|
||||||
|
# Prepare the mask we're going to ban.
|
||||||
|
my $mask;
|
||||||
|
given ($cbt) {
|
||||||
|
when (1) { $mask = '*!*@'.$user->{host}; }
|
||||||
|
when (2) { $mask = $user->{nick}.'!*@*'; }
|
||||||
|
when (3) { $mask = '*!'.$user->{user}.'@'.$user->{host}; }
|
||||||
|
when (4) { $mask = $user->{nick}.'!*'.$user->{user}.'@'.$user->{host}; }
|
||||||
|
when (5) {
|
||||||
|
my @hd = split m/[\.]/, $user->{host};
|
||||||
|
shift @hd;
|
||||||
|
$mask = '*!*@*.'.join ' ', @hd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now set the ban.
|
||||||
|
if (lc $type eq 'b') {
|
||||||
|
# We were requested to set a regular ban.
|
||||||
|
cmode($svr, $chan, "+b $mask");
|
||||||
|
}
|
||||||
|
elsif (lc $type eq 'q') {
|
||||||
|
# We were requested to set a ratbox-style quiet.
|
||||||
|
cmode($svr, $chan, "+q $mask");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
# Join a channel.
|
# Join a channel.
|
||||||
sub cjoin
|
sub cjoin
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user