Skip to content

Support for black_listing users #1

@bihonglu

Description

@bihonglu

This is not really an issue to be reported. It just a code contribution by me on this issue. My bot was invited and played by one user excessively, which I suspect to be an undeclared bot taking off my precious computer resource, I had to resort this to maintain sanity. Here is my code by
diff 2 DGSQBot.pm between mine and your original code:
163c163,167
< if ($self->check_board($m)) {

  if (&black_list($m->sender)) {
  $m->reject_game("reject excessive game invitation");
  $self->message("reject excessive game invitation from " .$m->sender."\n");
  }
        elsif ($self->check_board($m)) {

262a267,286

}

sub black_list {
my $senderid = shift;
my $bool = 0 ;
my %blacklist_hash;
if ( -f "black.lst") {
open (BLACKLST, "black.lst") || die " can not open black list file";
while() {
chomp;
if (/^(\d+)\s*$/) {
my $id = $1;
$blacklist_hash{$id} = 1 ;
}
}
close(BLACKLST);
}
$bool = 1 if ($blacklist_hash{$senderid});

return $bool ;

A file "black.lst" is created to have black_list senderid , one per line to be rejected by bots.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions