First run fixes for fortune commands, also fixes for karma

This commit is contained in:
eleksir
2020-11-22 16:29:26 +03:00
parent ad37a349c1
commit 63304d6bb9
3 changed files with 7 additions and 7 deletions

View File

@@ -262,15 +262,15 @@ sub command {
$reply = 'Шта?'; $reply = 'Шта?';
} elsif (substr ($text, 1) eq 'ver' || substr ($text, 1) eq 'version' || substr ($text, 1) eq 'версия') { } elsif (substr ($text, 1) eq 'ver' || substr ($text, 1) eq 'version' || substr ($text, 1) eq 'версия') {
$reply = 'Версия: Нуль.Чего-то_там.Чего-то_там'; $reply = 'Версия: Нуль.Чего-то_там.Чего-то_там';
} elsif (substr ($text, 1, 2) eq 'w ' || substr ($text, 1, 2) eq 'п ') { } elsif (length ($text) >= 2 && (substr ($text, 1, 2) eq 'w ' || substr ($text, 1, 2) eq 'п ')) {
my $city = substr ($text, 3); my $city = substr ($text, 3);
$reply = weather ($city); $reply = weather ($city);
} elsif (substr ($text, 1) eq 'lat' || substr ($text, 1) eq 'лат') { } elsif (substr ($text, 1) eq 'lat' || substr ($text, 1) eq 'лат') {
$reply = latAnswer (); $reply = latAnswer ();
} elsif (substr ($text, 1, 6) eq 'karma ' || substr ($text, 1, 6) eq 'карма ' || substr($text, 1) eq 'karma' || substr($text, $1) eq 'карма') { } elsif ((length ($text) >= 6 && (substr ($text, 1, 6) eq 'karma ' || substr ($text, 1, 6) eq 'карма ')) || substr($text, 1) eq 'karma' || substr($text, 1) eq 'карма') {
my $mytext = ''; my $mytext = '';
if (length($text) >= 7) { if (length($text) > 6) {
$mytext = substr ($text, 7); $mytext = substr ($text, 7);
chomp ($mytext); chomp ($mytext);
$mytext = trim ($mytext); $mytext = trim ($mytext);

View File

@@ -42,7 +42,7 @@ sub seed () {
while (my $fortunefile = readdir ($srcdirhandle)) { while (my $fortunefile = readdir ($srcdirhandle)) {
my $srcfile = sprintf '%s/%s', $srcdir, $fortunefile; my $srcfile = sprintf '%s/%s', $srcdir, $fortunefile;
next unless (-f $srcfile); next unless (-f $srcfile);
next if (m/[\.|\$|\@]/); next if ($fortunefile =~ m/\./);
open (my $fh, '<', $srcfile) || croak "Unable to open $srcfile, $OS_ERROR\n"; open (my $fh, '<', $srcfile) || croak "Unable to open $srcfile, $OS_ERROR\n";
# set correct phrase delimiter # set correct phrase delimiter
local $INPUT_RECORD_SEPARATOR = "\n%\n"; local $INPUT_RECORD_SEPARATOR = "\n%\n";
@@ -145,7 +145,7 @@ sub fortune_status ($) {
if (defined $state && $state) { if (defined $state && $state) {
$phrase .= 'показываtтся.'; $phrase .= 'показываtтся.';
} else { } else {
$phrase .= 'yt показываtтся.'; $phrase .= 'не показывается.';
} }
untie %toggle; untie %toggle;

View File

@@ -41,10 +41,10 @@ sub __cron {
# fortune mod # fortune mod
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time);
if ($hour = 8 && ($min >= 0 && $min <= 14)) { if ($hour == 8 && ($min >= 0 && $min <= 14)) {
foreach my $enabledfortunechat (fortune_toggle_list()) { foreach my $enabledfortunechat (fortune_toggle_list()) {
my $send_args; my $send_args;
$send_args->{text} = sptintf "Сегодняшний день пройдёт под эгидой фразы:\n%s", fortune(); $send_args->{text} = sprintf "Сегодняшний день пройдёт под эгидой фразы:\n%s", fortune();
$send_args->{chat_id} = $enabledfortunechat; $send_args->{chat_id} = $enabledfortunechat;
Teapot::Bot::Brain::sendMessage ($self, $send_args); Teapot::Bot::Brain::sendMessage ($self, $send_args);
} }