First run fixes for fortune commands, also fixes for karma
This commit is contained in:
@@ -262,15 +262,15 @@ sub command {
|
||||
$reply = 'Шта?';
|
||||
} elsif (substr ($text, 1) eq 'ver' || substr ($text, 1) eq 'version' || substr ($text, 1) eq 'версия') {
|
||||
$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);
|
||||
$reply = weather ($city);
|
||||
} elsif (substr ($text, 1) eq 'lat' || substr ($text, 1) eq 'лат') {
|
||||
$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 = '';
|
||||
|
||||
if (length($text) >= 7) {
|
||||
if (length($text) > 6) {
|
||||
$mytext = substr ($text, 7);
|
||||
chomp ($mytext);
|
||||
$mytext = trim ($mytext);
|
||||
|
||||
@@ -42,7 +42,7 @@ sub seed () {
|
||||
while (my $fortunefile = readdir ($srcdirhandle)) {
|
||||
my $srcfile = sprintf '%s/%s', $srcdir, $fortunefile;
|
||||
next unless (-f $srcfile);
|
||||
next if (m/[\.|\$|\@]/);
|
||||
next if ($fortunefile =~ m/\./);
|
||||
open (my $fh, '<', $srcfile) || croak "Unable to open $srcfile, $OS_ERROR\n";
|
||||
# set correct phrase delimiter
|
||||
local $INPUT_RECORD_SEPARATOR = "\n%\n";
|
||||
@@ -145,7 +145,7 @@ sub fortune_status ($) {
|
||||
if (defined $state && $state) {
|
||||
$phrase .= 'показываtтся.';
|
||||
} else {
|
||||
$phrase .= 'yt показываtтся.';
|
||||
$phrase .= 'не показывается.';
|
||||
}
|
||||
|
||||
untie %toggle;
|
||||
|
||||
@@ -41,10 +41,10 @@ sub __cron {
|
||||
# fortune mod
|
||||
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()) {
|
||||
my $send_args;
|
||||
$send_args->{text} = sptintf "Сегодняшний день пройдёт под эгидой фразы:\n%s", fortune();
|
||||
$send_args->{text} = sprintf "Сегодняшний день пройдёт под эгидой фразы:\n%s", fortune();
|
||||
$send_args->{chat_id} = $enabledfortunechat;
|
||||
Teapot::Bot::Brain::sendMessage ($self, $send_args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user