Commit 6d35657a authored by MBoretto's avatar MBoretto

Fixing new bot participant bug

parent 2be7b3c3
...@@ -122,4 +122,13 @@ abstract class Command ...@@ -122,4 +122,13 @@ abstract class Command
{ {
return $this->public; return $this->public;
} }
public function tryMention(User $user)
{
if (!is_null($participant->getUsername())) {
return '@'.$participant->getUsername();
} else {
return $participant->getFirstName();
}
}
} }
...@@ -33,14 +33,10 @@ class NewchatparticipantCommand extends Command ...@@ -33,14 +33,10 @@ class NewchatparticipantCommand extends Command
$data = array(); $data = array();
$data['chat_id'] = $chat_id; $data['chat_id'] = $chat_id;
if ($participant->getUsername() == $this->getTelegram()->getBotName()) { if (strtolower($participant->getUsername()) == strtolower($this->getTelegram()->getBotName())) {
$text = 'Hi there'; $text = 'Hi there';
} else { } else {
if ($participant->getUsername()) { $text = 'Hi '.$this->tryMention($partecipant);
$text = 'Hi @'.$participant->getUsername();
} else {
$text = 'Hi '.$participant->getFirstName();
}
} }
$data['text'] = $text; $data['text'] = $text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment