Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
8cca79e8
Unverified
Commit
8cca79e8
authored
Mar 13, 2019
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow absolute file paths for InputFile fields.
parent
a9ceaf31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
Request.php
src/Request.php
+29
-0
No files found.
CHANGELOG.md
View file @
8cca79e8
...
...
@@ -6,6 +6,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased]
### Added
-
Helper for sending
`InputMedia`
objects using
`Request::sendMediaGroup()`
and
`Request::editMediaMessage()`
methods.
-
Allow passing absolute file path for InputFile fields, instead of
`Request::encodeFile($path)`
.
### Changed
### Deprecated
-
Botan.io service has been discontinued.
...
...
src/Request.php
View file @
8cca79e8
...
...
@@ -222,6 +222,30 @@ class Request
'getMe'
,
];
/**
* Available fields for InputFile helper
*
* This is basically the list of all fields that allow InputFile objects
* for which input can be simplified by providing local path directly as string.
*
* @var array
*/
private
static
$input_file_fields
=
[
'setWebhook'
=>
[
'certificate'
],
'sendPhoto'
=>
[
'photo'
],
'sendAudio'
=>
[
'audio'
,
'thumb'
],
'sendDocument'
=>
[
'document'
,
'thumb'
],
'sendVideo'
=>
[
'video'
,
'thumb'
],
'sendAnimation'
=>
[
'animation'
,
'thumb'
],
'sendVoice'
=>
[
'voice'
,
'thumb'
],
'sendVideoNote'
=>
[
'video_note'
,
'thumb'
],
'setChatPhoto'
=>
[
'photo'
],
'sendSticker'
=>
[
'sticker'
],
'uploadStickerFile'
=>
[
'png_sticker'
],
'createNewStickerSet'
=>
[
'png_sticker'
],
'addStickerToSet'
=>
[
'png_sticker'
],
];
/**
* Initialize
*
...
...
@@ -327,6 +351,7 @@ class Request
* @param array $data
*
* @return array
* @throws TelegramException
*/
private
static
function
setUpRequestParams
(
array
$data
)
{
...
...
@@ -337,6 +362,10 @@ class Request
if
(
$key
===
'media'
)
{
// Magical media input helper.
$item
=
self
::
mediaInputHelper
(
$item
,
$has_resource
,
$multipart
);
}
elseif
(
array_key_exists
(
self
::
$current_action
,
self
::
$input_file_fields
)
&&
in_array
(
$key
,
self
::
$input_file_fields
[
self
::
$current_action
],
true
))
{
if
(
is_string
(
$item
)
&&
file_exists
(
$item
))
{
$item
=
new
Stream
(
self
::
encodeFile
(
$item
));
}
}
elseif
(
is_array
(
$item
))
{
// Convert any nested arrays into JSON strings.
$item
=
json_encode
(
$item
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment