Spam Blocker Plugin

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
rhpot03
Noob
Noob
Posts: 3
Joined: 19 Nov 2009, 23:36
Noob?: No

Spam Blocker Plugin

#1 Post by rhpot03 »

A plugin to automatically mute those pesky zeny selling spammers in prontera

Usage:
  • block <player_name> - manually block someone
  • unblock <player_name> - remove player from block list
spamblocker.pl

Code: Select all

#
# spamblocker.pl
#
# Automatically block spammers from chat
#

package SpamBlocker;

use strict;
use Plugins;
use Globals;
use Log qw(message error);

Plugins::register("spamblocker", "Spam Blocker Plugin", \&unloadFunc, \&reloadFunc);
my $plugHook = Plugins::addHook("ChatQueue::add", \&onMessage);
my $cmdHooks = Commands::register(
  ['block', "Block user from chat", \&onCommand],
  ['unblock', "Unblock user from chat", \&onCommand]
);

sub unloadFunc {
  Plugins::delHook($plugHook);
  Commands::unregister($cmdHooks);
}

sub reloadFunc {
  &unloadFunc;
}

my %userHistory = ();
my %blackList = ();
my %whiteList = ();

my $threshold_msg = 8;
my $threshold_sec = 5;

sub block {
  my $player = shift;

  Commands::run("ignore 1 $player");
  delete $userHistory{$player};
  delete $whiteList{$player};
  $blackList{$player} = undef;
  message "Player $player added to block list.\n";
}

sub unblock {
  my $player = shift;

  Commands::run("ignore 0 $player");
  delete $blackList{$player};
  $whiteList{$player} = undef;
  message "Player $player removed from block list.\n";
}

sub onMessage {
  my $data = $_[1]; #type, userID, user, msg, time

  return if exists($whiteList{$data->{user}}) or exists($blackList{$data->{user}});

  # increase message count in a second
  if(exists($userHistory{$data->{user}}) && $data->{time}-$userHistory{$data->{user}}[0]<$threshold_sec) {
    $userHistory{$data->{user}}[1]++;
  } else {
    $userHistory{$data->{user}} = [($data->{time}, 1)];
  }

  # block player
  if($userHistory{$data->{user}}[1] >= $threshold_msg) {
    block($data->{user});
  }

}

sub onCommand {
  my ($cmd,$player) = @_;
  if(!defined($player)) {
    error "Usage: $cmd <player_name>\n";
  } elsif ($cmd =~ /^block$/) {
    block($player);
  } elsif ($cmd =~ /^unblock$/) {
    unblock($player);
  }
}

return 1;

funky_vinit
Noob
Noob
Posts: 1
Joined: 01 Nov 2009, 09:17
Noob?: No

Re: Spam Blocker Plugin

#2 Post by funky_vinit »

i play in iRO valkyrie. there are spammers spamming offers in normal chat. at many places in almost all towns. so will this help???
if so how???

rhpot03
Noob
Noob
Posts: 3
Joined: 19 Nov 2009, 23:36
Noob?: No

Re: Spam Blocker Plugin

#3 Post by rhpot03 »

This plugin automatically use the 'ignore' command on players who have been detected to be spamming messages. By default, a player is determined to be a spammer if he sends more than 8 messages over 5 seconds.

Effectively, the plugin will automatically stop spam from flooding your console whereas you would normally use the ignore command on each player manually.

Cicero
Noob
Noob
Posts: 6
Joined: 02 Oct 2008, 11:05
Noob?: No

Re: Spam Blocker Plugin

#4 Post by Cicero »

Nice app,

But is it possible to save the names to a file, and when i log in again reload this names to plugin?

maybe in a new version?

Cicero_Poter

randombotter
Noob
Noob
Posts: 3
Joined: 26 Nov 2009, 15:57
Noob?: Yes

Re: Spam Blocker Plugin

#5 Post by randombotter »

Thank you for such an awsm plugin.

sidd199
Noob
Noob
Posts: 3
Joined: 05 Jan 2010, 03:47
Noob?: Yes

Re: Spam Blocker Plugin

#6 Post by sidd199 »

If the bot disconnects and again reconnects the plugin doesn't block the spammers.Please look into this issue

Thanks in advance

jstinso7455
Noob
Noob
Posts: 8
Joined: 25 Nov 2010, 02:15
Noob?: Yes

Re: Spam Blocker Plugin

#7 Post by jstinso7455 »

where do i put the plugin at?

Post Reply