|
|
|
@@ -17,6 +17,7 @@ use BotLib::Admin qw (FortuneToggleList);
|
|
|
|
use BotLib qw (RandomCommonPhrase Command Highlight BotSleep IsCensored);
|
|
|
|
use BotLib qw (RandomCommonPhrase Command Highlight BotSleep IsCensored);
|
|
|
|
use BotLib::Conf qw (LoadConf);
|
|
|
|
use BotLib::Conf qw (LoadConf);
|
|
|
|
use BotLib::Fortune qw (Fortune);
|
|
|
|
use BotLib::Fortune qw (Fortune);
|
|
|
|
|
|
|
|
use BotLib::Image qw (Oboobs Obutts);
|
|
|
|
use BotLib::Karma qw (KarmaSet);
|
|
|
|
use BotLib::Karma qw (KarmaSet);
|
|
|
|
use BotLib::Util qw (trim fmatch);
|
|
|
|
use BotLib::Util qw (trim fmatch);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -125,17 +126,22 @@ sub __on_msg {
|
|
|
|
foreach my $member (@{$msg->new_chat_members}) {
|
|
|
|
foreach my $member (@{$msg->new_chat_members}) {
|
|
|
|
my $member_str = '';
|
|
|
|
my $member_str = '';
|
|
|
|
|
|
|
|
|
|
|
|
if ($member->can ('first_name') && defined ($member->first_name)) {
|
|
|
|
# avoid naming people by spacing symbols, or empty names
|
|
|
|
|
|
|
|
if ($member->can ('first_name') && defined ($member->first_name) && $member->first_name !~ /^\s+$/ui) {
|
|
|
|
$member_str .= $member->first_name;
|
|
|
|
$member_str .= $member->first_name;
|
|
|
|
|
|
|
|
|
|
|
|
if ($member->can ('last_name') && defined ($member->last_name)) {
|
|
|
|
if ($member->can ('last_name') && defined ($member->last_name) && $member->last_name !~ /^\s+$/ui) {
|
|
|
|
$member_str .= ' ' . $member->last_name;
|
|
|
|
$member_str .= ' ' . $member->last_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ($member->can ('last_name') && defined ($member->last_name)) {
|
|
|
|
if ($member->can ('last_name') && defined ($member->last_name) && $member->last_name !~ /^\s+$/ui) {
|
|
|
|
$member_str .= ' ' . $member->last_name;
|
|
|
|
$member_str .= ' ' . $member->last_name;
|
|
|
|
} else {
|
|
|
|
# username must be uniq and should contain only english letters and numbers, so...
|
|
|
|
|
|
|
|
} elsif ($member->can ('username') && defined ($member->username)) {
|
|
|
|
$member_str .= '@' . $member->username;
|
|
|
|
$member_str .= '@' . $member->username;
|
|
|
|
|
|
|
|
# fallback to id if uose trying to be smartass and use only spacing chars in it's firstname and/or lastname
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$member_str .= $member->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -195,16 +201,22 @@ sub __on_msg {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$just_message_in_chat = 1;
|
|
|
|
$just_message_in_chat = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$just_message_in_chat = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($just_message_in_chat) {
|
|
|
|
if ($just_message_in_chat) {
|
|
|
|
if ($text =~ /^кто +все +эти +люди *\?$/i) {
|
|
|
|
if ($text =~ /^ *кто +все +эти +люди *\?$/ui) {
|
|
|
|
$reply = 'Какие люди? Мы здесь вдвоём, только ты и я.';
|
|
|
|
$reply = 'Какие "люди"? Мы здесь вдвоём, только ты и я.';
|
|
|
|
} elsif ($text =~ /покажи +(сиськи|сиси|титьки) *$/i) {
|
|
|
|
} elsif ($text =~ /^ *кто +я *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Где?';
|
|
|
|
|
|
|
|
} elsif ($text =~ /^ *кто +(здесь|тут) *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Ты да я, да мы с тобой.';
|
|
|
|
|
|
|
|
} elsif ($text =~ /покажи +(сиськи|сиси|титьки) *$/ui) {
|
|
|
|
$reply = Oboobs ();
|
|
|
|
$reply = Oboobs ();
|
|
|
|
} elsif ($text =~ /show +(titts|tities|boobs) *$/i) {
|
|
|
|
} elsif ($text =~ /show +(titts|tities|boobs) *$/i) {
|
|
|
|
$reply = Oboobs ();
|
|
|
|
$reply = Oboobs ();
|
|
|
|
} elsif ($text =~ /покажи +(попку|попу) *$/i) {
|
|
|
|
} elsif ($text =~ /покажи +(попку|попу) *$/ui) {
|
|
|
|
$reply = Obutts ();
|
|
|
|
$reply = Obutts ();
|
|
|
|
} elsif ($text =~ /show +(ass|butt|butty) *$/i) {
|
|
|
|
} elsif ($text =~ /show +(ass|butt|butty) *$/i) {
|
|
|
|
$reply = Obutts ();
|
|
|
|
$reply = Obutts ();
|
|
|
|
@@ -262,20 +274,31 @@ sub __on_msg {
|
|
|
|
$log->debug (sprintf ('[DEBUG] In public chat %s (%s) %s quote us!', $chatname, $chatid, $vis_a_vi));
|
|
|
|
$log->debug (sprintf ('[DEBUG] In public chat %s (%s) %s quote us!', $chatname, $chatid, $vis_a_vi));
|
|
|
|
|
|
|
|
|
|
|
|
# do not answer back if someone quote our new member greet
|
|
|
|
# do not answer back if someone quote our new member greet
|
|
|
|
if ((substr ($msg->reply_to_message->text, 0, 9) eq 'Дратути, ') &&
|
|
|
|
if (substr ($msg->reply_to_message->text, -61) eq 'Представьтес, пожалуйста, и расскажите, что вас сюда привело.') {
|
|
|
|
(substr ($msg->reply_to_message->text, -61) eq 'Представьтес, пожалуйста, и расскажите, что вас сюда привело.')) {
|
|
|
|
my @hello = (
|
|
|
|
return;
|
|
|
|
'Дратути, ',
|
|
|
|
} else {
|
|
|
|
'Дарована, ',
|
|
|
|
# remove our name from users reply, just in case
|
|
|
|
'Доброе утро, день или вечер, ',
|
|
|
|
my $pat1 = quotemeta ('@' . $myusername);
|
|
|
|
'Добро пожаловать в наше скромное коммунити, ',
|
|
|
|
my $pat2 = quotemeta $myfullname;
|
|
|
|
'Наше вам с кисточкой тут, на канальчике, ',
|
|
|
|
$phrase = $text;
|
|
|
|
);
|
|
|
|
$phrase =~ s/$pat1//g;
|
|
|
|
|
|
|
|
$phrase =~ s/$pat2//g;
|
|
|
|
foreach my $hi (@hello) {
|
|
|
|
|
|
|
|
if (substr ($msg->reply_to_message->text, 0, length $hi) eq $hi) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# remove our name from users reply, just in case
|
|
|
|
|
|
|
|
my $pat1 = quotemeta ('@' . $myusername);
|
|
|
|
|
|
|
|
my $pat2 = quotemeta $myfullname;
|
|
|
|
|
|
|
|
$phrase = $text;
|
|
|
|
|
|
|
|
$phrase =~ s/$pat1//g;
|
|
|
|
|
|
|
|
$phrase =~ s/$pat2//g;
|
|
|
|
|
|
|
|
|
|
|
|
# figure out reply :)
|
|
|
|
# figure out reply :)
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase) if (length ($phrase) > 3);
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase) if (length ($phrase) > 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
# simple commands
|
|
|
|
# simple commands
|
|
|
|
} elsif (substr ($text, 0, 1) eq $csign) {
|
|
|
|
} elsif (substr ($text, 0, 1) eq $csign) {
|
|
|
|
$reply = Command ($self, $msg, $text, $chatid);
|
|
|
|
$reply = Command ($self, $msg, $text, $chatid);
|
|
|
|
@@ -295,8 +318,12 @@ sub __on_msg {
|
|
|
|
if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){
|
|
|
|
if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){
|
|
|
|
$phrase = $1;
|
|
|
|
$phrase = $1;
|
|
|
|
|
|
|
|
|
|
|
|
if ($phrase =~ /^кто +все +эти +люди *\?$/i) {
|
|
|
|
if ($phrase =~ /^ *кто +все +эти +люди *\?$/ui) {
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +я *?$/ui){
|
|
|
|
|
|
|
|
$reply = 'Где?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +(здесь|тут) *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Здесь все: Никита, Стас, Гена, Турбо и Дюша Метёлкин.';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -304,8 +331,12 @@ sub __on_msg {
|
|
|
|
} elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) {
|
|
|
|
} elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) {
|
|
|
|
$phrase = $text;
|
|
|
|
$phrase = $text;
|
|
|
|
|
|
|
|
|
|
|
|
if ($phrase =~ /^кто +все +эти +люди *\?$/i) {
|
|
|
|
if ($phrase =~ /^ *кто +все +эти +люди *\?$/ui) {
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +я *?$/ui){
|
|
|
|
|
|
|
|
$reply = 'Где?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +(здесь|тут) *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Здесь все: Никита, Стас, Гена, Турбо и Дюша Метёлкин.';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -313,8 +344,12 @@ sub __on_msg {
|
|
|
|
} elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) {
|
|
|
|
} elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) {
|
|
|
|
$phrase = $text;
|
|
|
|
$phrase = $text;
|
|
|
|
|
|
|
|
|
|
|
|
if ($phrase =~ /^кто +все +эти +люди *\?$/i) {
|
|
|
|
if ($phrase =~ /^ *кто +все +эти +люди *\?$/ui) {
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +я *?$/ui){
|
|
|
|
|
|
|
|
$reply = 'Где?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +(здесь|тут) *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Здесь все: Никита, Стас, Гена, Турбо и Дюша Метёлкин.';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -330,8 +365,12 @@ sub __on_msg {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# just message in chat
|
|
|
|
# just message in chat
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ($text =~ /^кто +все +эти +люди *\?$/i) {
|
|
|
|
if ($text =~ /^ *кто +все +эти +люди *\?$/ui) {
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
$reply = 'Кто здесь?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +я *?$/ui){
|
|
|
|
|
|
|
|
$reply = 'Где?';
|
|
|
|
|
|
|
|
} elsif ($phrase =~ /^ *кто +(здесь|тут) *\?$/ui) {
|
|
|
|
|
|
|
|
$reply = 'Здесь все: Никита, Стас, Гена, Турбо и Дюша Метёлкин.';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$hailo->{$msg->chat->id}->learn ($text);
|
|
|
|
$hailo->{$msg->chat->id}->learn ($text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|