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
193aa44c
Commit
193aa44c
authored
May 18, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/akalongman/php-telegram-bot
into develop
parents
7147b12f
2bdd0d12
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
485 additions
and
61 deletions
+485
-61
CREDITS
CREDITS
+5
-0
SendtoallCommand.php
src/Commands/AdminCommands/SendtoallCommand.php
+1
-3
SendtochannelCommand.php
src/Commands/AdminCommands/SendtochannelCommand.php
+3
-3
Audio.php
src/Entities/Audio.php
+2
-3
Chat.php
src/Entities/Chat.php
+0
-7
ChosenInlineResult.php
src/Entities/ChosenInlineResult.php
+0
-2
Contact.php
src/Entities/Contact.php
+0
-2
Document.php
src/Entities/Document.php
+4
-6
Entity.php
src/Entities/Entity.php
+0
-2
File.php
src/Entities/File.php
+2
-4
InlineKeyboardButton.php
src/Entities/InlineKeyboardButton.php
+4
-5
InlineKeyboardMarkup.php
src/Entities/InlineKeyboardMarkup.php
+1
-1
InlineQuery.php
src/Entities/InlineQuery.php
+4
-2
InlineQueryResult.php
src/Entities/InlineQueryResult.php
+11
-0
InlineQueryResultArticle.php
src/Entities/InlineQueryResultArticle.php
+0
-1
InlineQueryResultCachedAudio.php
src/Entities/InlineQueryResultCachedAudio.php
+35
-0
InlineQueryResultCachedDocument.php
src/Entities/InlineQueryResultCachedDocument.php
+61
-0
InlineQueryResultCachedGif.php
src/Entities/InlineQueryResultCachedGif.php
+51
-0
InlineQueryResultCachedMpeg4Gif.php
src/Entities/InlineQueryResultCachedMpeg4Gif.php
+50
-0
InlineQueryResultCachedPhoto.php
src/Entities/InlineQueryResultCachedPhoto.php
+57
-0
InlineQueryResultCachedSticker.php
src/Entities/InlineQueryResultCachedSticker.php
+35
-0
InlineQueryResultCachedVideo.php
src/Entities/InlineQueryResultCachedVideo.php
+61
-0
InlineQueryResultCachedVoice.php
src/Entities/InlineQueryResultCachedVoice.php
+61
-0
InlineQueryResultGif.php
src/Entities/InlineQueryResultGif.php
+5
-2
InlineQueryResultMpeg4Gif.php
src/Entities/InlineQueryResultMpeg4Gif.php
+5
-2
InlineQueryResultPhoto.php
src/Entities/InlineQueryResultPhoto.php
+6
-2
InlineQueryResultVideo.php
src/Entities/InlineQueryResultVideo.php
+8
-1
InputContactMessageContent.php
src/Entities/InputContactMessageContent.php
+0
-2
InputLocationMessageContent.php
src/Entities/InputLocationMessageContent.php
+0
-2
InputTextMessageContent.php
src/Entities/InputTextMessageContent.php
+0
-2
InputVenueMessageContent.php
src/Entities/InputVenueMessageContent.php
+0
-2
Message.php
src/Entities/Message.php
+0
-1
MessageEntity.php
src/Entities/MessageEntity.php
+6
-3
ReplyKeyboardMarkup.php
src/Entities/ReplyKeyboardMarkup.php
+1
-1
Telegram.php
src/Telegram.php
+6
-0
No files found.
CREDITS
View file @
193aa44c
...
...
@@ -21,3 +21,8 @@ N: Armando Lüscher
E: armando@noplanman.ch
W: http://noplanman.ch
D: Maintainer and Collaborator
N: Jack'lul (alias)
E: jacklul@jacklul.com
W: http://jacklul.com
D: Maintainer and Collaborator
src/Commands/AdminCommands/SendtoallCommand.php
View file @
193aa44c
...
...
@@ -31,8 +31,6 @@ class SendtoallCommand extends AdminCommand
/**
* Execute command
*
* @todo Don't use empty, as a string of '0' is regarded to be empty
*
* @return boolean
*/
public
function
execute
()
...
...
@@ -42,7 +40,7 @@ class SendtoallCommand extends AdminCommand
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
if
(
empty
(
$text
)
)
{
if
(
$text
===
''
)
{
$text
=
'Write the message to send: /sendtoall <message>'
;
}
else
{
$results
=
Request
::
sendToActiveChats
(
...
...
src/Commands/AdminCommands/SendtochannelCommand.php
View file @
193aa44c
...
...
@@ -67,7 +67,7 @@ class SendtochannelCommand extends AdminCommand
switch
(
$state
)
{
case
-
1
:
// getConfig has not been configured asking for channel to administer
if
(
$type
!=
'Message'
||
empty
(
$text
)
)
{
if
(
$type
!=
'Message'
||
$text
===
''
)
{
$this
->
conversation
->
notes
[
'state'
]
=
-
1
;
$this
->
conversation
->
update
();
...
...
@@ -116,7 +116,7 @@ class SendtochannelCommand extends AdminCommand
// no break
case
1
:
insert
:
if
(
$this
->
conversation
->
notes
[
'last_message_id'
]
==
$message
->
getMessageId
()
||
(
$type
==
'Message'
&&
empty
(
$text
)
))
{
if
(
$this
->
conversation
->
notes
[
'last_message_id'
]
==
$message
->
getMessageId
()
||
(
$type
==
'Message'
&&
$text
===
''
))
{
$this
->
conversation
->
notes
[
'state'
]
=
1
;
$this
->
conversation
->
update
();
...
...
@@ -245,7 +245,7 @@ class SendtochannelCommand extends AdminCommand
$data
=
[];
$data
[
'chat_id'
]
=
$chat_id
;
if
(
empty
(
$text
)
)
{
if
(
$text
===
''
)
{
$data
[
'text'
]
=
'Usage: /sendtochannel <text>'
;
}
else
{
$channels
=
(
array
)
$this
->
getConfig
(
'your_channel'
);
...
...
src/Entities/Audio.php
View file @
193aa44c
...
...
@@ -21,10 +21,8 @@ class Audio extends Entity
protected
$mime_type
;
protected
$file_size
;
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
if
(
empty
(
$this
->
file_id
))
{
throw
new
TelegramException
(
'file_id is empty!'
);
...
...
@@ -40,7 +38,6 @@ class Audio extends Entity
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
mime_type
=
isset
(
$data
[
'mime_type'
])
?
$data
[
'mime_type'
]
:
null
;
$this
->
file_size
=
isset
(
$data
[
'file_size'
])
?
$data
[
'file_size'
]
:
null
;
}
public
function
getFileId
()
...
...
@@ -57,10 +54,12 @@ class Audio extends Entity
{
return
$this
->
performer
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getMimeType
()
{
return
$this
->
mime_type
;
...
...
src/Entities/Chat.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
Chat
extends
Entity
{
protected
$id
;
protected
$type
;
protected
$title
;
...
...
@@ -81,37 +80,31 @@ class Chat extends Entity
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getType
()
{
return
$this
->
type
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getFirstName
()
{
return
$this
->
first_name
;
}
public
function
getLastName
()
{
return
$this
->
last_name
;
}
public
function
getUsername
()
{
return
$this
->
username
;
}
...
...
src/Entities/ChosenInlineResult.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
ChosenInlineResult
extends
Entity
{
protected
$result_id
;
protected
$from
;
protected
$location
;
...
...
@@ -23,7 +22,6 @@ class ChosenInlineResult extends Entity
public
function
__construct
(
array
$data
)
{
$this
->
result_id
=
isset
(
$data
[
'result_id'
])
?
$data
[
'result_id'
]
:
null
;
if
(
empty
(
$this
->
result_id
))
{
throw
new
TelegramException
(
'result_id is empty!'
);
...
...
src/Entities/Contact.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
Contact
extends
Entity
{
protected
$phone_number
;
protected
$first_name
;
protected
$last_name
;
...
...
@@ -22,7 +21,6 @@ class Contact extends Entity
public
function
__construct
(
array
$data
)
{
$this
->
phone_number
=
isset
(
$data
[
'phone_number'
])
?
$data
[
'phone_number'
]
:
null
;
if
(
empty
(
$this
->
phone_number
))
{
throw
new
TelegramException
(
'phone_number is empty!'
);
...
...
src/Entities/Document.php
View file @
193aa44c
...
...
@@ -22,7 +22,6 @@ class Document extends Entity
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
if
(
empty
(
$this
->
file_id
))
{
throw
new
TelegramException
(
'file_id is empty!'
);
...
...
@@ -36,7 +35,6 @@ class Document extends Entity
$this
->
file_name
=
isset
(
$data
[
'file_name'
])
?
$data
[
'file_name'
]
:
null
;
$this
->
mime_type
=
isset
(
$data
[
'mime_type'
])
?
$data
[
'mime_type'
]
:
null
;
$this
->
file_size
=
isset
(
$data
[
'file_size'
])
?
$data
[
'file_size'
]
:
null
;
}
public
function
getFileId
()
...
...
@@ -46,21 +44,21 @@ class Document extends Entity
public
function
getThumb
()
{
return
$this
->
thumb
;
return
$this
->
thumb
;
}
public
function
getFileName
()
{
return
$this
->
file_name
;
return
$this
->
file_name
;
}
public
function
getMimeType
()
{
return
$this
->
mime_type
;
return
$this
->
mime_type
;
}
public
function
getFileSize
()
{
return
$this
->
file_size
;
return
$this
->
file_size
;
}
}
src/Entities/Entity.php
View file @
193aa44c
...
...
@@ -14,10 +14,8 @@ class Entity
{
protected
$bot_name
;
public
function
getBotName
()
{
return
$this
->
bot_name
;
}
...
...
src/Entities/File.php
View file @
193aa44c
...
...
@@ -20,7 +20,6 @@ class File extends Entity
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
if
(
empty
(
$this
->
file_id
))
{
throw
new
TelegramException
(
'file_id is empty!'
);
...
...
@@ -29,7 +28,6 @@ class File extends Entity
$this
->
file_size
=
isset
(
$data
[
'file_size'
])
?
$data
[
'file_size'
]
:
null
;
$this
->
file_path
=
isset
(
$data
[
'file_path'
])
?
$data
[
'file_path'
]
:
null
;
}
public
function
getFileId
()
...
...
@@ -39,11 +37,11 @@ class File extends Entity
public
function
getFileSize
()
{
return
$this
->
file_size
;
return
$this
->
file_size
;
}
public
function
getFilePath
()
{
return
$this
->
file_path
;
return
$this
->
file_path
;
}
}
src/Entities/InlineKeyboardButton.php
View file @
193aa44c
...
...
@@ -19,6 +19,9 @@ class InlineKeyboardButton extends Entity
protected
$callback_data
;
protected
$switch_inline_query
;
/**
* @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used
*/
public
function
__construct
(
$data
=
array
())
{
$this
->
text
=
isset
(
$data
[
'text'
])
?
$data
[
'text'
]
:
null
;
...
...
@@ -30,12 +33,8 @@ class InlineKeyboardButton extends Entity
$this
->
callback_data
=
isset
(
$data
[
'callback_data'
])
?
$data
[
'callback_data'
]
:
null
;
$this
->
switch_inline_query
=
isset
(
$data
[
'switch_inline_query'
])
?
$data
[
'switch_inline_query'
]
:
null
;
if
(
empty
(
$this
->
url
)
&&
empty
(
$this
->
callback_data
)
&&
empty
(
$this
->
switch_inline_query
)
)
{
if
(
$this
->
url
===
''
&&
$this
->
callback_data
===
''
&&
$this
->
switch_inline_query
===
''
)
{
throw
new
TelegramException
(
'You must use at least one of these fields: url, callback_data, switch_inline_query!'
);
}
/*
* @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used
*/
}
}
src/Entities/InlineKeyboardMarkup.php
View file @
193aa44c
...
...
@@ -16,7 +16,7 @@ class InlineKeyboardMarkup extends Entity
{
protected
$inline_keyboard
;
/*
/*
*
* @todo check for InlineKeyboardButton elements
*/
public
function
__construct
(
$data
=
array
())
...
...
src/Entities/InlineQuery.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineQuery
extends
Entity
{
protected
$id
;
protected
$from
;
protected
$location
;
...
...
@@ -23,7 +22,6 @@ class InlineQuery extends Entity
public
function
__construct
(
array
$data
)
{
$this
->
id
=
isset
(
$data
[
'id'
])
?
$data
[
'id'
]
:
null
;
if
(
empty
(
$this
->
id
))
{
throw
new
TelegramException
(
'id is empty!'
);
...
...
@@ -48,18 +46,22 @@ class InlineQuery extends Entity
{
return
$this
->
id
;
}
public
function
getFrom
()
{
return
$this
->
from
;
}
public
function
getLocation
()
{
return
$this
->
location
;
}
public
function
getQuery
()
{
return
$this
->
query
;
}
public
function
getOffset
()
{
return
$this
->
offset
;
...
...
src/Entities/InlineQueryResult.php
View file @
193aa44c
...
...
@@ -35,8 +35,19 @@ class InlineQueryResult extends Entity
{
return
$this
->
type
;
}
public
function
getId
()
{
return
$this
->
id
;
}
public
function
getInputMessageContent
()
{
return
$this
->
input_message_content
;
}
public
function
getReplyMarkup
()
{
return
$this
->
reply_markup
;
}
}
src/Entities/InlineQueryResultArticle.php
View file @
193aa44c
...
...
@@ -45,7 +45,6 @@ class InlineQueryResultArticle extends InlineQueryResult
$this
->
thumb_url
=
isset
(
$data
[
'thumb_url'
])
?
$data
[
'thumb_url'
]
:
null
;
$this
->
thumb_width
=
isset
(
$data
[
'thumb_width'
])
?
$data
[
'thumb_width'
]
:
null
;
$this
->
thumb_height
=
isset
(
$data
[
'thumb_height'
])
?
$data
[
'thumb_height'
]
:
null
;
}
public
function
getTitle
()
...
...
src/Entities/InlineQueryResultCachedAudio.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedAudio
extends
InlineQueryResult
{
protected
$audio_file_id
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'audio'
;
$this
->
audio_file_id
=
isset
(
$data
[
'audio_file_id'
])
?
$data
[
'audio_file_id'
]
:
null
;
if
(
empty
(
$this
->
audio_file_id
))
{
throw
new
TelegramException
(
'audio_file_id is empty!'
);
}
}
public
function
getAudioFileId
()
{
return
$this
->
audio_file_id
;
}
}
src/Entities/InlineQueryResultCachedDocument.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedDocument
extends
InlineQueryResult
{
protected
$document_file_id
;
protected
$title
;
protected
$description
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'document'
;
$this
->
document_file_id
=
isset
(
$data
[
'document_file_id'
])
?
$data
[
'document_file_id'
]
:
null
;
if
(
empty
(
$this
->
document_file_id
))
{
throw
new
TelegramException
(
'document_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
if
(
empty
(
$this
->
title
))
{
throw
new
TelegramException
(
'title is empty!'
);
}
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getDocumentFileId
()
{
return
$this
->
document_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultCachedGif.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedGif
extends
InlineQueryResult
{
protected
$gif_file_id
;
protected
$title
;
protected
$description
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'gif'
;
$this
->
gif_file_id
=
isset
(
$data
[
'gif_file_id'
])
?
$data
[
'gif_file_id'
]
:
null
;
if
(
empty
(
$this
->
gif_file_id
))
{
throw
new
TelegramException
(
'gif_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getGifFileId
()
{
return
$this
->
gif_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultCachedMpeg4Gif.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedMpeg4Gif
extends
InlineQueryResult
{
protected
$mpeg4_file_id
;
protected
$title
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'mpeg4_gif'
;
$this
->
mpeg4_file_id
=
isset
(
$data
[
'mpeg4_file_id'
])
?
$data
[
'mpeg4_file_id'
]
:
null
;
if
(
empty
(
$this
->
mpeg4_file_id
))
{
throw
new
TelegramException
(
'mpeg4_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getMpeg4FileId
()
{
return
$this
->
mpeg4_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultCachedPhoto.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedPhoto
extends
InlineQueryResult
{
protected
$photo_file_id
;
protected
$title
;
protected
$description
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'photo'
;
$this
->
photo_file_id
=
isset
(
$data
[
'photo_file_id'
])
?
$data
[
'photo_file_id'
]
:
null
;
if
(
empty
(
$this
->
photo_file_id
))
{
throw
new
TelegramException
(
'photo_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getPhotoFileId
()
{
return
$this
->
photo_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultCachedSticker.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedSticker
extends
InlineQueryResult
{
protected
$sticker_file_id
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'sticker'
;
$this
->
photo_file_id
=
isset
(
$data
[
'sticker_file_id'
])
?
$data
[
'sticker_file_id'
]
:
null
;
if
(
empty
(
$this
->
sticker_file_id
))
{
throw
new
TelegramException
(
'sticker_file_id is empty!'
);
}
}
public
function
getStickerFileId
()
{
return
$this
->
sticker_file_id
;
}
}
src/Entities/InlineQueryResultCachedVideo.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedVideo
extends
InlineQueryResult
{
protected
$video_file_id
;
protected
$title
;
protected
$description
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'photo'
;
$this
->
video_file_id
=
isset
(
$data
[
'video_file_id'
])
?
$data
[
'video_file_id'
]
:
null
;
if
(
empty
(
$this
->
video_file_id
))
{
throw
new
TelegramException
(
'video_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
if
(
empty
(
$this
->
title
))
{
throw
new
TelegramException
(
'title is empty!'
);
}
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getVideoFileId
()
{
return
$this
->
video_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultCachedVoice.php
0 → 100644
View file @
193aa44c
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
InlineQueryResultCachedVoice
extends
InlineQueryResult
{
protected
$voice_file_id
;
protected
$title
;
protected
$description
;
protected
$caption
;
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
$this
->
type
=
'voice'
;
$this
->
voice_file_id
=
isset
(
$data
[
'voice_file_id'
])
?
$data
[
'voice_file_id'
]
:
null
;
if
(
empty
(
$this
->
voice_file_id
))
{
throw
new
TelegramException
(
'voice_file_id is empty!'
);
}
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
if
(
empty
(
$this
->
title
))
{
throw
new
TelegramException
(
'title is empty!'
);
}
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getVoiceFileId
()
{
return
$this
->
voice_file_id
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
}
src/Entities/InlineQueryResultGif.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineQueryResultGif
extends
InlineQueryResult
{
protected
$gif_url
;
protected
$gif_width
;
protected
$gif_height
;
...
...
@@ -43,29 +42,33 @@ class InlineQueryResultGif extends InlineQueryResult
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getGifUrl
()
{
return
$this
->
gif_url
;
}
public
function
getGifWidth
()
{
return
$this
->
gif_width
;
}
public
function
getGifHeight
()
{
return
$this
->
gif_height
;
}
public
function
getThumbUrl
()
{
return
$this
->
thumb_url
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
...
...
src/Entities/InlineQueryResultMpeg4Gif.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineQueryResultMpeg4Gif
extends
InlineQueryResult
{
protected
$mpeg4_url
;
protected
$mpeg4_width
;
protected
$mpeg4_height
;
...
...
@@ -43,29 +42,33 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getMpeg4Url
()
{
return
$this
->
mpeg4_url
;
}
public
function
getMpeg4Width
()
{
return
$this
->
mpeg4_width
;
}
public
function
getMpeg4Height
()
{
return
$this
->
mpeg4_height
;
}
public
function
getThumbUrl
()
{
return
$this
->
thumb_url
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
...
...
src/Entities/InlineQueryResultPhoto.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineQueryResultPhoto
extends
InlineQueryResult
{
protected
$photo_url
;
protected
$photo_width
;
protected
$photo_height
;
...
...
@@ -45,33 +44,38 @@ class InlineQueryResultPhoto extends InlineQueryResult
$this
->
title
=
isset
(
$data
[
'title'
])
?
$data
[
'title'
]
:
null
;
$this
->
description
=
isset
(
$data
[
'description'
])
?
$data
[
'description'
]
:
null
;
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
}
public
function
getPhotoUrl
()
{
return
$this
->
photo_url
;
}
public
function
getPhotoWidth
()
{
return
$this
->
photo_width
;
}
public
function
getPhotoHeight
()
{
return
$this
->
photo_height
;
}
public
function
getThumbUrl
()
{
return
$this
->
thumb_url
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getDescription
()
{
return
$this
->
description
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
...
...
src/Entities/InlineQueryResultVideo.php
View file @
193aa44c
...
...
@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class
InlineQueryResultVideo
extends
InlineQueryResult
{
protected
$video_url
;
protected
$mime_type
;
protected
$thumb_url
;
...
...
@@ -56,34 +55,42 @@ class InlineQueryResultVideo extends InlineQueryResult
{
return
$this
->
video_url
;
}
public
function
getMimeType
()
{
return
$this
->
mime_type
;
}
public
function
getThumbUrl
()
{
return
$this
->
thumb_url
;
}
public
function
getTitle
()
{
return
$this
->
title
;
}
public
function
getCaption
()
{
return
$this
->
caption
;
}
public
function
getVideoWidth
()
{
return
$this
->
video_width
;
}
public
function
getVideoHeight
()
{
return
$this
->
video_height
;
}
public
function
getVideoDuration
()
{
return
$this
->
video_duration
;
}
public
function
getDescription
()
{
return
$this
->
description
;
...
...
src/Entities/InputContactMessageContent.php
View file @
193aa44c
...
...
@@ -20,8 +20,6 @@ class InputContactMessageContent extends InputMessageContent
public
function
__construct
(
array
$data
)
{
//parent::__construct($data);
$this
->
phone_number
isset
(
$data
[
'phone_number'
])
?
$data
[
'phone_number'
]
:
null
;
if
(
empty
(
$this
->
phone_number
))
{
throw
new
TelegramException
(
'phone_number is empty!'
);
...
...
src/Entities/InputLocationMessageContent.php
View file @
193aa44c
...
...
@@ -19,8 +19,6 @@ class InputLocationMessageContent extends InputMessageContent
public
function
__construct
(
array
$data
)
{
//parent::__construct($data);
$this
->
latitude
isset
(
$data
[
'latitude'
])
?
$data
[
'latitude'
]
:
null
;
if
(
empty
(
$this
->
latitude
))
{
throw
new
TelegramException
(
'latitude is empty!'
);
...
...
src/Entities/InputTextMessageContent.php
View file @
193aa44c
...
...
@@ -20,8 +20,6 @@ class InputTextMessageContent extends InputMessageContent
public
function
__construct
(
array
$data
)
{
//parent::__construct($data);
$this
->
message_text
isset
(
$data
[
'message_text'
])
?
$data
[
'message_text'
]
:
null
;
if
(
empty
(
$this
->
message_text
))
{
throw
new
TelegramException
(
'message_text is empty!'
);
...
...
src/Entities/InputVenueMessageContent.php
View file @
193aa44c
...
...
@@ -22,8 +22,6 @@ class InputVenueMessageContent extends InputMessageContent
public
function
__construct
(
array
$data
)
{
//parent::__construct($data);
$this
->
latitude
isset
(
$data
[
'latitude'
])
?
$data
[
'latitude'
]
:
null
;
if
(
empty
(
$this
->
latitude
))
{
throw
new
TelegramException
(
'latitude is empty!'
);
...
...
src/Entities/Message.php
View file @
193aa44c
...
...
@@ -122,7 +122,6 @@ class Message extends Entity
$this
->
forward_from
=
isset
(
$data
[
'forward_from'
])
?
$data
[
'forward_from'
]
:
null
;
if
(
!
empty
(
$this
->
forward_from
))
{
$this
->
forward_from
=
new
User
(
$this
->
forward_from
);
}
$this
->
forward_from_chat
=
isset
(
$data
[
'forward_from_chat'
])
?
$data
[
'forward_from_chat'
]
:
null
;
...
...
src/Entities/MessageEntity.php
View file @
193aa44c
...
...
@@ -17,20 +17,23 @@ class MessageEntity extends Entity
protected
$length
;
protected
$url
;
/**
* @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity
*/
public
function
__construct
(
array
$data
)
{
$this
->
type
=
isset
(
$data
[
'type'
])
?
$data
[
'type'
]
:
null
;
if
(
empty
(
$this
->
type
))
{
// @todo check for value from this list: https://core.telegram.org/bots/api#messageentity
if
(
empty
(
$this
->
type
))
{
throw
new
TelegramException
(
'type is empty!'
);
}
$this
->
offset
=
isset
(
$data
[
'offset'
])
?
$data
[
'offset'
]
:
null
;
if
(
empty
(
$this
->
offset
)
&&
$this
->
offset
!=
0
)
{
// @todo this is not an ideal solution?
if
(
$this
->
offset
===
''
)
{
throw
new
TelegramException
(
'offset is empty!'
);
}
$this
->
length
=
isset
(
$data
[
'length'
])
?
$data
[
'length'
]
:
null
;
if
(
empty
(
$this
->
length
)
&&
$this
->
offset
!=
0
)
{
// @todo this is not an ideal solution?
if
(
$this
->
length
===
''
)
{
throw
new
TelegramException
(
'length is empty!'
);
}
...
...
src/Entities/ReplyKeyboardMarkup.php
View file @
193aa44c
...
...
@@ -21,7 +21,7 @@ class ReplyKeyboardMarkup extends Entity
protected
$one_time_keyboard
;
protected
$selective
;
/*
/*
*
* @todo check for KeyboardButton elements
*/
public
function
__construct
(
$data
=
array
())
...
...
src/Telegram.php
View file @
193aa44c
...
...
@@ -568,6 +568,12 @@ class Telegram
if
(
$user_id
===
null
&&
$this
->
update
!==
null
)
{
if
((
$message
=
$this
->
update
->
getMessage
())
&&
(
$from
=
$message
->
getFrom
()))
{
$user_id
=
$from
->
getId
();
}
elseif
((
$inline_query
=
$this
->
update
->
getInlineQuery
())
&&
(
$from
=
$inline_query
->
getFrom
()))
{
$user_id
=
$from
->
getId
();
}
elseif
((
$callback_query
=
$this
->
update
->
getCallbackQuery
())
&&
(
$from
=
$callback_query
->
getFrom
()))
{
$user_id
=
$from
->
getId
();
}
elseif
((
$chosen_inline_result
=
$this
->
update
->
getChosenInlineResult
())
&&
(
$from
=
$chosen_inline_result
->
getFrom
()))
{
$user_id
=
$from
->
getId
();
}
}
...
...
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