mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
Improve twit detection
This commit is contained in:
parent
a21b27a11f
commit
be80680626
@ -44,13 +44,13 @@ sub on_public {
|
|||||||
$channel = lc $channel;
|
$channel = lc $channel;
|
||||||
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||||
|
|
||||||
while ($msg =~ m/@([a-z0-9_^{}\-\\\[\]\|]+)/g) {
|
while ($msg =~ m/[@@]\s*([a-z0-9_^{}\-\\\[\]\|]+)/g) {
|
||||||
my $n = $1;
|
my $n = $1;
|
||||||
if ($self->{pbot}->{nicklist}->is_present_similar($channel, $n)) {
|
if ($self->{pbot}->{nicklist}->is_present_similar($channel, $n)) {
|
||||||
$self->{offenses}->{$channel}->{$nick}->{offenses}++;
|
$self->{offenses}->{$channel}->{$nick}->{offenses}++;
|
||||||
$self->{offenses}->{$channel}->{$nick}->{time} = gettimeofday;
|
$self->{offenses}->{$channel}->{$nick}->{time} = gettimeofday;
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("$nick!$user\@$host is a twit. $self->{offenses}->{$channel}->{$nick}->{offenses} offenses. Msg: $msg\n");
|
$self->{pbot}->{logger}->log("$nick!$user\@$host is a twit. ($self->{offenses}->{$channel}->{$nick}->{offenses} offenses) $channel: $msg\n");
|
||||||
|
|
||||||
given ($self->{offenses}->{$channel}->{$nick}->{offenses}) {
|
given ($self->{offenses}->{$channel}->{$nick}->{offenses}) {
|
||||||
when (1) {
|
when (1) {
|
||||||
@ -80,7 +80,7 @@ sub adjust_offenses {
|
|||||||
|
|
||||||
foreach my $channel (keys $self->{offenses}) {
|
foreach my $channel (keys $self->{offenses}) {
|
||||||
foreach my $nick (keys $self->{offenses}->{$channel}) {
|
foreach my $nick (keys $self->{offenses}->{$channel}) {
|
||||||
if ($now - $self->{offenses}->{$channel}->{$nick}->{time} >= 60 * 60 * 5) {
|
if ($now - $self->{offenses}->{$channel}->{$nick}->{time} >= 60 * 60 * 24 * 7) {
|
||||||
if (--$self->{offenses}->{$channel}->{$nick}->{offenses} <= 0) {
|
if (--$self->{offenses}->{$channel}->{$nick}->{offenses} <= 0) {
|
||||||
delete $self->{offenses}->{$channel}->{$nick};
|
delete $self->{offenses}->{$channel}->{$nick};
|
||||||
delete $self->{offenses}->{$channel} if not keys $self->{offenses}->{$channel};
|
delete $self->{offenses}->{$channel} if not keys $self->{offenses}->{$channel};
|
||||||
|
Loading…
Reference in New Issue
Block a user