Move IsCensored to Admin.pm
This commit is contained in:
@@ -18,7 +18,8 @@ our @ISA = qw / Exporter /; ## no critic (ClassHierarchies::ProhibitExplicitI
|
||||
our @EXPORT_OK = qw (@ForbiddenMessageTypes @PluginList GetForbiddenTypes AddForbiddenType DelForbiddenType
|
||||
ListForbidden FortuneToggle FortuneToggleList FortuneStatus PluginToggle PluginStatus
|
||||
PluginEnabled ChanMsgToggle ChanMsgStatus ChanMsgEnabled GreetMsgToggle GreetMsgStatus
|
||||
GreetMsgEnabled GoodbyeMsgToggle GoodbyeMsgStatus GoodbyeMsgEnabled MigrateSettingsToNewChatID);
|
||||
GreetMsgEnabled GoodbyeMsgToggle GoodbyeMsgStatus GoodbyeMsgEnabled MigrateSettingsToNewChatID
|
||||
IsCensored);
|
||||
|
||||
my $c = LoadConf ();
|
||||
my $cachedir = $c->{cachedir};
|
||||
@@ -606,6 +607,27 @@ sub MigrateSettingsToNewChatID {
|
||||
return;
|
||||
}
|
||||
|
||||
sub IsCensored {
|
||||
my $msg = shift;
|
||||
|
||||
my $forbidden = GetForbiddenTypes ($msg->chat->id);
|
||||
|
||||
# voice messages are special
|
||||
if (defined ($msg->voice) && defined ($msg->voice->duration) && ($msg->voice->duration > 0)) {
|
||||
if ($forbidden->{'voice'}) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %{$forbidden}) {
|
||||
if ($forbidden->{$_} && (defined $msg->{$_})) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# vim: set ft=perl noet ai ts=4 sw=4 sts=4:
|
||||
|
||||
@@ -15,7 +15,7 @@ use URI::URL qw (url);
|
||||
|
||||
use version; our $VERSION = qw (1.0);
|
||||
use Exporter qw (import);
|
||||
our @EXPORT_OK = qw (trim urlencode fmatch utf2b64 utf2sha1 BotSleep Highlight IsCensored RandomCommonPhrase);
|
||||
our @EXPORT_OK = qw (trim urlencode fmatch utf2b64 utf2sha1 BotSleep Highlight RandomCommonPhrase);
|
||||
|
||||
sub trim {
|
||||
my $str = shift;
|
||||
@@ -124,27 +124,6 @@ sub Highlight {
|
||||
return ($userid, $username, $fullname, $highlight, $visavi);
|
||||
}
|
||||
|
||||
sub IsCensored {
|
||||
my $msg = shift;
|
||||
|
||||
my $forbidden = GetForbiddenTypes ($msg->chat->id);
|
||||
|
||||
# voice messages are special
|
||||
if (defined ($msg->voice) && defined ($msg->voice->duration) && ($msg->voice->duration > 0)) {
|
||||
if ($forbidden->{'voice'}) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %{$forbidden}) {
|
||||
if ($forbidden->{$_} && (defined $msg->{$_})) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub RandomCommonPhrase {
|
||||
my @myphrase = (
|
||||
'Так, блядь...',
|
||||
|
||||
@@ -14,10 +14,11 @@ use Log::Any qw ($log);
|
||||
use Math::Random::Secure qw (irand);
|
||||
use Mojo::Base 'Teapot::Bot::Brain';
|
||||
|
||||
use BotLib::Admin qw (FortuneToggleList ChanMsgEnabled GreetMsgEnabled GoodbyeMsgEnabled MigrateSettingsToNewChatID);
|
||||
use BotLib::Admin qw (FortuneToggleList ChanMsgEnabled GreetMsgEnabled GoodbyeMsgEnabled MigrateSettingsToNewChatID
|
||||
IsCensored);
|
||||
use BotLib qw (Command);
|
||||
use BotLib::Conf qw (LoadConf);
|
||||
use BotLib::Util qw (trim fmatch BotSleep Highlight IsCensored RandomCommonPhrase);
|
||||
use BotLib::Util qw (trim fmatch BotSleep Highlight RandomCommonPhrase);
|
||||
use RedisLib qw (redis_events_listener);
|
||||
|
||||
use version; our $VERSION = qw (1.0);
|
||||
|
||||
Reference in New Issue
Block a user