2016-04-30 23:53:26 +02:00
|
|
|
package MarkovBot::Ignore;
|
|
|
|
use base qw(Exporter);
|
2016-07-04 21:32:07 +02:00
|
|
|
use 5.010;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2016-04-30 23:53:26 +02:00
|
|
|
|
|
|
|
our @EXPORT = qw(ignore unignore isIgnored);
|
|
|
|
|
|
|
|
use FindBin qw($Bin);
|
|
|
|
use lib $Bin;
|
|
|
|
|
|
|
|
use MarkovBot::Config;
|
|
|
|
use MarkovBot::Redis;
|
|
|
|
|
|
|
|
sub ignore( $ ) {
|
|
|
|
# ignore($user)
|
|
|
|
|
|
|
|
my $user = shift;
|
|
|
|
my $redis = redis();
|
|
|
|
my $redis_prefix = config("redis_prefix");
|
|
|
|
|
|
|
|
$redis->sadd("$redis_prefix:ignore", $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub unignore( $ ) {
|
|
|
|
# unignore($user)
|
|
|
|
|
|
|
|
my $user = shift;
|
|
|
|
my $redis = redis();
|
|
|
|
my $redis_prefix = config("redis_prefix");
|
|
|
|
|
|
|
|
$redis->srem("$redis_prefix:ignore", $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub isIgnored( $ ) {
|
|
|
|
# isIngored($user)
|
|
|
|
# returns 0 or 1
|
|
|
|
|
|
|
|
my $user = shift;
|
|
|
|
my $redis = redis();
|
|
|
|
my $redis_prefix = config("redis_prefix");
|
|
|
|
|
|
|
|
return $redis->sismember("$redis_prefix:ignore", $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|