Add ban() to API::IRC. Also, bantype is now a required config value.

This commit is contained in:
Elijah Perrault committed 2011-02-15 22:58:15 -07:00
1 parent f97b55a56c
commit 7dbebdeca9
4 files changed
+40 -3

No files matched your search

+1
View File
@@ -28,6 +28,7 @@ Incompatibilities:
* Database: Changed structure of the `qdb` table. Modify the configuration
values in upgrade.pl then run it to upgrade the database.
* 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
development stages. But we hope we've piqued your interest, as Auto's upcoming
+1 -1
View File
@@ -143,7 +143,7 @@ if (conf_get('die')) {
}
# 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) {
if (!conf_get($REQCVAL)) {
my $err = 2;
+2
View File
@@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log
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_uprivmsg arguments to: \%src, @msg
* Bug fix: Commands getting Permission denied even with incorrect prefix.
+36 -2
View File
@@ -4,13 +4,47 @@
package API::IRC;
use strict;
use warnings;
use feature qw(switch);
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(cjoin cpart cmode umode kick privmsg notice quit nick names topic
usrc match_mask);
our @EXPORT_OK = qw(ban cjoin cpart cmode umode kick privmsg notice quit nick names
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.
sub cjoin
{