Paint help message in markdown
This commit is contained in:
@@ -36,6 +36,7 @@ sub __cron {
|
|||||||
|
|
||||||
sub __on_msg {
|
sub __on_msg {
|
||||||
my ($self, $msg) = @_;
|
my ($self, $msg) = @_;
|
||||||
|
my $chatid;
|
||||||
|
|
||||||
unless ($myid) {
|
unless ($myid) {
|
||||||
my $myObj = Telegram::Bot::Brain::getMe($self);
|
my $myObj = Telegram::Bot::Brain::getMe($self);
|
||||||
@@ -43,7 +44,7 @@ sub __on_msg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($msg->{'chat'}->can('id')) {
|
if ($msg->{'chat'}->can('id')) {
|
||||||
my $chatid = $msg->{'chat'}->id;
|
$chatid = $msg->{'chat'}->id;
|
||||||
my $group_talk = 0;
|
my $group_talk = 0;
|
||||||
|
|
||||||
# because of bot api restriction there is no events about changing permissions in chat sent to bot
|
# because of bot api restriction there is no events about changing permissions in chat sent to bot
|
||||||
@@ -69,6 +70,8 @@ sub __on_msg {
|
|||||||
} else {
|
} else {
|
||||||
$can_talk = $group_talk;
|
$can_talk = $group_talk;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $phrase;
|
my $phrase;
|
||||||
@@ -99,10 +102,10 @@ sub __on_msg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# lazy init chat-bot brains
|
# lazy init chat-bot brains
|
||||||
unless (defined($hailo->{$msg->chat->id})) {
|
unless (defined($hailo->{$chatid})) {
|
||||||
$hailo->{$msg->chat->id} = Hailo->new(
|
$hailo->{$chatid} = Hailo->new(
|
||||||
# we'll got file like this: data/telegrambot-brains/-1001332512695.brain.sqlite
|
# we'll got file like this: data/telegrambot-brains/-1001332512695.brain.sqlite
|
||||||
brain => sprintf("%s/%s.brain.sqlite", $c->{telegrambot}->{braindir}, $msg->chat->id),
|
brain => sprintf("%s/%s.brain.sqlite", $c->{telegrambot}->{braindir}, $chatid),
|
||||||
order => 3
|
order => 3
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -151,7 +154,9 @@ sub __on_msg {
|
|||||||
# simple commands
|
# simple commands
|
||||||
if (substr($text, 0, 1) eq $c->{telegrambot}->{csign}) {
|
if (substr($text, 0, 1) eq $c->{telegrambot}->{csign}) {
|
||||||
if (substr($text, 1) eq "help") {
|
if (substr($text, 1) eq "help") {
|
||||||
$reply = '```
|
return unless ($can_talk);
|
||||||
|
my $send_args;
|
||||||
|
$send_args->{text} = '```
|
||||||
!help | !помощь - список команд
|
!help | !помощь - список команд
|
||||||
!w город | !п город - погода в указанном городе
|
!w город | !п город - погода в указанном городе
|
||||||
!ping | !пинг - попинговать бота
|
!ping | !пинг - попинговать бота
|
||||||
@@ -159,6 +164,10 @@ sub __on_msg {
|
|||||||
Но на самом деле я бот больше для общения, чем для исполнения команд.
|
Но на самом деле я бот больше для общения, чем для исполнения команд.
|
||||||
Поговоришь со мной?
|
Поговоришь со мной?
|
||||||
';
|
';
|
||||||
|
$send_args->{parse_mode} = 'Markdown';
|
||||||
|
$send_args->{chat_id} = $chatid;
|
||||||
|
Telegram::Bot::Brain::sendMessage($self, $send_args);
|
||||||
|
return;
|
||||||
} elsif (substr($text, 1) eq "ping") {
|
} elsif (substr($text, 1) eq "ping") {
|
||||||
$reply = "Pong.";
|
$reply = "Pong.";
|
||||||
} elsif (substr($text, 1) eq "пинг") {
|
} elsif (substr($text, 1) eq "пинг") {
|
||||||
|
|||||||
Reference in New Issue
Block a user