Commit 9179a987 authored by MBoretto's avatar MBoretto

methods with file implemented

parent f4b203bd
...@@ -34,9 +34,9 @@ class NewchatparticipantCommand extends Command ...@@ -34,9 +34,9 @@ class NewchatparticipantCommand extends Command
$data['chat_id'] = $chat_id; $data['chat_id'] = $chat_id;
if (strtolower($participant->getUsername()) == strtolower($this->getTelegram()->getBotName())) { if (strtolower($participant->getUsername()) == strtolower($this->getTelegram()->getBotName())) {
$text = 'Hi there'; $text = 'Hi there!';
} else { } else {
$text = 'Hi '.$this->tryMention($partecipant); $text = 'Hi '.$this->tryMention($partecipant).' !';
} }
$data['text'] = $text; $data['text'] = $text;
......
...@@ -201,12 +201,95 @@ class Request ...@@ -201,12 +201,95 @@ class Request
} }
//TODO forwardMessage //TODO forwardMessage
//sendPhoto
//sendAudio protected static function encodeFile($file)
//sendDocument {
//sendSticker return new \CURLFile($file);
//sendVideo }
//sendVoice
public static function sendPhoto(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['photo'] = self::encodeFile($file);
}
$result = self::send('sendPhoto', $data);
return $result;
}
public static function sendAudio(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['audio'] = self::encodeFile($file);
}
$result = self::send('sendAudio', $data);
return $result;
}
public static function sendDocument(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['document'] = self::encodeFile($file);
}
$result = self::send('sendDocument', $data);
return $result;
}
public static function sendSticker(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['sticker'] = self::encodeFile($file);
}
$result = self::send('sendSticker', $data);
return $result;
}
public static function sendVideo(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['video'] = self::encodeFile($file);
}
$result = self::send('sendVideo', $data);
return $result;
}
public static function sendVoice(array $data, $file = null)
{
if (empty($data)) {
throw new TelegramException('Data is empty!');
}
if (!is_null($file)) {
$data['voice'] = self::encodeFile($file);
}
$result = self::send('sendVoice', $data);
return $result;
}
public static function sendLocation(array $data) public static function sendLocation(array $data)
{ {
if (empty($data)) { if (empty($data)) {
......
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