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
1513e971
Commit
1513e971
authored
Jul 01, 2016
by
Marco Boretto
Committed by
GitHub
Jul 01, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #236 from MBoretto/develop
various
parents
ea01d341
edd902d6
Changes
62
Hide whitespace changes
Inline
Side-by-side
Showing
62 changed files
with
367 additions
and
60 deletions
+367
-60
BotanDB.php
src/BotanDB.php
+6
-3
SendtochannelCommand.php
src/Commands/AdminCommands/SendtochannelCommand.php
+4
-5
Command.php
src/Commands/Command.php
+9
-11
CancelCommand.php
src/Commands/UserCommands/CancelCommand.php
+1
-1
DateCommand.php
src/Commands/UserCommands/DateCommand.php
+1
-1
SurveyCommand.php
src/Commands/UserCommands/SurveyCommand.php
+1
-2
ConversationDB.php
src/ConversationDB.php
+0
-2
DB.php
src/DB.php
+14
-17
Audio.php
src/Entities/Audio.php
+5
-0
CallbackQuery.php
src/Entities/CallbackQuery.php
+5
-0
Chat.php
src/Entities/Chat.php
+5
-0
ChatMember.php
src/Entities/ChatMember.php
+5
-0
ChosenInlineResult.php
src/Entities/ChosenInlineResult.php
+5
-0
Contact.php
src/Entities/Contact.php
+5
-0
Document.php
src/Entities/Document.php
+5
-0
File.php
src/Entities/File.php
+5
-0
ForceReply.php
src/Entities/ForceReply.php
+5
-0
InlineKeyboardButton.php
src/Entities/InlineKeyboardButton.php
+5
-0
InlineKeyboardMarkup.php
src/Entities/InlineKeyboardMarkup.php
+5
-0
InlineQuery.php
src/Entities/InlineQuery.php
+5
-0
InlineQueryResult.php
src/Entities/InlineQueryResult.php
+5
-0
InlineQueryResultArticle.php
src/Entities/InlineQueryResultArticle.php
+5
-0
InlineQueryResultAudio.php
src/Entities/InlineQueryResultAudio.php
+5
-0
InlineQueryResultCachedAudio.php
src/Entities/InlineQueryResultCachedAudio.php
+5
-0
InlineQueryResultCachedDocument.php
src/Entities/InlineQueryResultCachedDocument.php
+5
-0
InlineQueryResultCachedGif.php
src/Entities/InlineQueryResultCachedGif.php
+5
-0
InlineQueryResultCachedMpeg4Gif.php
src/Entities/InlineQueryResultCachedMpeg4Gif.php
+5
-0
InlineQueryResultCachedPhoto.php
src/Entities/InlineQueryResultCachedPhoto.php
+5
-0
InlineQueryResultCachedSticker.php
src/Entities/InlineQueryResultCachedSticker.php
+5
-0
InlineQueryResultCachedVideo.php
src/Entities/InlineQueryResultCachedVideo.php
+5
-0
InlineQueryResultCachedVoice.php
src/Entities/InlineQueryResultCachedVoice.php
+5
-0
InlineQueryResultContact.php
src/Entities/InlineQueryResultContact.php
+5
-0
InlineQueryResultDocument.php
src/Entities/InlineQueryResultDocument.php
+5
-0
InlineQueryResultGif.php
src/Entities/InlineQueryResultGif.php
+5
-0
InlineQueryResultLocation.php
src/Entities/InlineQueryResultLocation.php
+5
-0
InlineQueryResultMpeg4Gif.php
src/Entities/InlineQueryResultMpeg4Gif.php
+5
-0
InlineQueryResultPhoto.php
src/Entities/InlineQueryResultPhoto.php
+5
-0
InlineQueryResultVenue.php
src/Entities/InlineQueryResultVenue.php
+5
-0
InlineQueryResultVideo.php
src/Entities/InlineQueryResultVideo.php
+5
-0
InlineQueryResultVoice.php
src/Entities/InlineQueryResultVoice.php
+5
-0
InputContactMessageContent.php
src/Entities/InputContactMessageContent.php
+5
-0
InputLocationMessageContent.php
src/Entities/InputLocationMessageContent.php
+5
-0
InputTextMessageContent.php
src/Entities/InputTextMessageContent.php
+5
-0
InputVenueMessageContent.php
src/Entities/InputVenueMessageContent.php
+5
-0
KeyboardButton.php
src/Entities/KeyboardButton.php
+5
-0
Location.php
src/Entities/Location.php
+5
-0
Message.php
src/Entities/Message.php
+61
-2
MessageEntity.php
src/Entities/MessageEntity.php
+6
-0
PhotoSize.php
src/Entities/PhotoSize.php
+6
-2
ReplyKeyboardHide.php
src/Entities/ReplyKeyboardHide.php
+5
-2
ReplyKeyboardMarkup.php
src/Entities/ReplyKeyboardMarkup.php
+5
-0
ReplyToMessage.php
src/Entities/ReplyToMessage.php
+6
-2
ServerResponse.php
src/Entities/ServerResponse.php
+6
-2
Sticker.php
src/Entities/Sticker.php
+5
-0
Update.php
src/Entities/Update.php
+6
-0
User.php
src/Entities/User.php
+5
-0
UserProfilePhotos.php
src/Entities/UserProfilePhotos.php
+5
-0
Venue.php
src/Entities/Venue.php
+5
-0
Video.php
src/Entities/Video.php
+5
-0
Voice.php
src/Entities/Voice.php
+5
-3
Request.php
src/Request.php
+2
-2
Telegram.php
src/Telegram.php
+8
-3
No files found.
src/BotanDB.php
View file @
1513e971
...
...
@@ -10,7 +10,6 @@
namespace
Longman\TelegramBot
;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Exception\TelegramException
;
/**
...
...
@@ -33,8 +32,10 @@ class BotanDB extends DB
*
* @param $user_id
* @param $url
*
@return bool|string
*
* @throws TelegramException
*
* @return bool|string
*/
public
static
function
selectShortUrl
(
$user_id
,
$url
)
{
...
...
@@ -65,8 +66,10 @@ class BotanDB extends DB
* @param $user_id
* @param $url
* @param $short_url
*
@return bool
*
* @throws TelegramException
*
* @return bool
*/
public
static
function
insertShortUrl
(
$user_id
,
$url
,
$short_url
)
{
...
...
src/Commands/AdminCommands/SendtochannelCommand.php
View file @
1513e971
...
...
@@ -33,7 +33,7 @@ class SendtochannelCommand extends AdminCommand
/**
* Conversation Object
*
* @var Longman\TelegramBot\Conversation
* @var
\
Longman\TelegramBot\Conversation
*/
protected
$conversation
;
...
...
@@ -128,7 +128,6 @@ class SendtochannelCommand extends AdminCommand
$this
->
conversation
->
notes
[
'last_message_id'
]
=
$message
->
getMessageId
();
$this
->
conversation
->
notes
[
'message'
]
=
$message
->
reflect
();
$this
->
conversation
->
notes
[
'message_type'
]
=
$type
;
// no break
case
2
:
if
(
$this
->
conversation
->
notes
[
'last_message_id'
]
==
$message
->
getMessageId
()
||
!
(
$text
==
'Yes'
||
$text
==
'No'
))
{
...
...
@@ -258,7 +257,7 @@ class SendtochannelCommand extends AdminCommand
/**
* Publish a message to a channel and return success or failure message
*
* @param Entities\Message $message
* @param
\Longman\TelegramBot\
Entities\Message $message
* @param int $channel
* @param string|null $caption
*
...
...
@@ -292,10 +291,10 @@ class SendtochannelCommand extends AdminCommand
* @todo This method will be moved at an higher level maybe in AdminCommand or Command
* @todo Looking for a more significative name
*
* @param Entities\Message $message
* @param
\Longman\TelegramBot\
Entities\Message $message
* @param array $data
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
protected
function
sendBack
(
Message
$message
,
array
$data
)
{
...
...
src/Commands/Command.php
View file @
1513e971
...
...
@@ -13,9 +13,7 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Telegram
;
use
Longman\TelegramBot\Entities\Chat
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\User
;
/**
* Abstract Command Class
...
...
@@ -32,14 +30,14 @@ abstract class Command
/**
* Update object
*
* @var Entities\Update
* @var
\Longman\TelegramBot\
Entities\Update
*/
protected
$update
;
/**
* Message object
*
* @var Entities\Message
* @var
\Longman\TelegramBot\
Entities\Message
*/
protected
$message
;
...
...
@@ -96,7 +94,7 @@ abstract class Command
* Constructor
*
* @param Telegram $telegram
* @param Entities\Update $update
* @param
\Longman\TelegramBot\
Entities\Update $update
*/
public
function
__construct
(
Telegram
$telegram
,
Update
$update
=
null
)
{
...
...
@@ -108,7 +106,7 @@ abstract class Command
/**
* Set update object
*
* @param Entities\Update $update
* @param
\Longman\TelegramBot\
Entities\Update $update
* @return Command
*/
public
function
setUpdate
(
Update
$update
=
null
)
...
...
@@ -123,7 +121,7 @@ abstract class Command
/**
* Pre-execute command
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
public
function
preExecute
()
{
...
...
@@ -136,14 +134,14 @@ abstract class Command
/**
* Execute command
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
abstract
public
function
execute
();
/**
* Execution if MySQL is required but not available
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
public
function
executeNoDb
()
{
...
...
@@ -162,7 +160,7 @@ abstract class Command
/**
* Get update object
*
* @return Entities\Update
* @return
\Longman\TelegramBot\
Entities\Update
*/
public
function
getUpdate
()
{
...
...
@@ -172,7 +170,7 @@ abstract class Command
/**
* Get message object
*
* @return Entities\Message
* @return
\Longman\TelegramBot\
Entities\Message
*/
public
function
getMessage
()
{
...
...
src/Commands/UserCommands/CancelCommand.php
View file @
1513e971
...
...
@@ -68,7 +68,7 @@ class CancelCommand extends UserCommand
*
* @param string $text
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
private
function
hideKeyboard
(
$text
)
{
...
...
src/Commands/UserCommands/DateCommand.php
View file @
1513e971
...
...
@@ -202,7 +202,7 @@ class DateCommand extends UserCommand
if
(
empty
(
$location
))
{
$text
=
'You must specify location in format: /date <city>'
;
}
else
{
$text
=
$this
->
get
f
ormattedDate
(
$location
);
$text
=
$this
->
get
F
ormattedDate
(
$location
);
}
$data
=
[
...
...
src/Commands/UserCommands/SurveyCommand.php
View file @
1513e971
...
...
@@ -35,7 +35,7 @@ class SurveyCommand extends UserCommand
/**
* Conversation Object
*
* @var Longman\TelegramBot\Conversation
* @var
\
Longman\TelegramBot\Conversation
*/
protected
$conversation
;
...
...
@@ -57,7 +57,6 @@ class SurveyCommand extends UserCommand
$data
=
[];
if
(
$chat
->
isGroupChat
()
||
$chat
->
isSuperGroup
())
{
//reply to message id is applied by default
$data
[
'reply_to_message_id'
]
=
$message_id
;
//Force reply is applied by default to so can work with privacy on
$data
[
'reply_markup'
]
=
new
ForceReply
([
'selective'
=>
true
]);
}
...
...
src/ConversationDB.php
View file @
1513e971
...
...
@@ -10,7 +10,6 @@
namespace
Longman\TelegramBot
;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Exception\TelegramException
;
/**
...
...
@@ -49,7 +48,6 @@ class ConversationDB extends DB
$query
.=
'AND `chat_id` = :chat_id '
;
$query
.=
'AND `user_id` = :user_id '
;
$tokens
=
[
':chat_id'
=>
$chat_id
,
':user_id'
=>
$user_id
];
if
(
!
is_null
(
$limit
))
{
$query
.=
' LIMIT :limit'
;
}
...
...
src/DB.php
View file @
1513e971
...
...
@@ -199,7 +199,7 @@ class DB
$sth_select_telegram_update
->
bindParam
(
':limit'
,
$limit
,
\PDO
::
PARAM_INT
);
$sth_select_telegram_update
->
execute
();
$results
=
$sth_select_telegram_update
->
fetchAll
(
\PDO
::
FETCH_ASSOC
);
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
...
...
@@ -234,7 +234,7 @@ class DB
$sth
->
bindParam
(
':limit'
,
$limit
,
\PDO
::
PARAM_INT
);
$sth
->
execute
();
$results
=
$sth
->
fetchAll
(
\PDO
::
FETCH_ASSOC
);
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
...
...
@@ -299,7 +299,7 @@ class DB
$sth_insert_telegram_update
->
bindParam
(
':edited_message_id'
,
$edited_message_id
,
\PDO
::
PARAM_INT
);
return
$sth_insert_telegram_update
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -344,7 +344,7 @@ class DB
$sth1
->
bindParam
(
':date'
,
$date
,
\PDO
::
PARAM_STR
);
$status
=
$sth1
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
...
...
@@ -364,7 +364,7 @@ class DB
$sth3
->
bindParam
(
':chat_id'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$status
=
$sth3
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -418,7 +418,7 @@ class DB
$sth2
->
bindParam
(
':date'
,
$date
,
\PDO
::
PARAM_STR
);
return
$sth2
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -523,7 +523,7 @@ class DB
$sth_insert_inline_query
->
bindParam
(
':created_at'
,
$date
,
\PDO
::
PARAM_STR
);
return
$sth_insert_inline_query
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -574,7 +574,7 @@ class DB
$sth_insert_chosen_inline_result
->
bindParam
(
':created_at'
,
$date
,
\PDO
::
PARAM_STR
);
return
$sth_insert_chosen_inline_result
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -644,7 +644,7 @@ class DB
$sth_insert_callback_query
->
bindParam
(
':created_at'
,
$date
,
\PDO
::
PARAM_STR
);
return
$sth_insert_callback_query
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -685,18 +685,15 @@ class DB
//Insert user and the relation with the chat
self
::
insertUser
(
$from
,
$date
,
$chat
);
//Forwarded object
if
(
$forward_from
||
$forward_from_chat
)
{
$forward_date
=
self
::
getTimestamp
(
$message
->
getForwardDate
());
}
//Insert the forwarded message user in users table
if
(
is_object
(
$forward_from
))
{
$forward_date
=
self
::
getTimestamp
(
$message
->
getForwardDate
());
self
::
insertUser
(
$forward_from
,
$forward_date
);
$forward_from
=
$forward_from
->
getId
();
}
if
(
is_object
(
$forward_from_chat
))
{
$forward_date
=
self
::
getTimestamp
(
$message
->
getForwardDate
());
self
::
insertChat
(
$forward_from_chat
,
$forward_date
);
$forward_from_chat
=
$forward_from_chat
->
getId
();
}
...
...
@@ -841,7 +838,7 @@ class DB
$sth
->
bindParam
(
':pinned_message'
,
$pinned_message
,
\PDO
::
PARAM_INT
);
return
$sth
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -911,7 +908,7 @@ class DB
$sth
->
bindParam
(
':caption'
,
$caption
,
\PDO
::
PARAM_STR
);
return
$sth
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
}
...
...
@@ -1027,7 +1024,7 @@ class DB
$sth
->
execute
(
$tokens
);
$result
=
$sth
->
fetchAll
(
\PDO
::
FETCH_ASSOC
);
}
catch
(
PDOException
$e
)
{
}
catch
(
\
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
...
...
src/Entities/Audio.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class Audio extends Entity
protected
$mime_type
;
protected
$file_size
;
/**
* Audio constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
...
...
src/Entities/CallbackQuery.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class CallbackQuery extends Entity
protected
$inline_message_id
;
protected
$data
;
/**
* CallbackQuery constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
id
=
isset
(
$data
[
'id'
])
?
$data
[
'id'
]
:
null
;
...
...
src/Entities/Chat.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class Chat extends Entity
protected
$first_name
;
protected
$last_name
;
/**
* Chat constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
id
=
isset
(
$data
[
'id'
])
?
$data
[
'id'
]
:
null
;
...
...
src/Entities/ChatMember.php
View file @
1513e971
...
...
@@ -15,6 +15,11 @@ class ChatMember extends Entity
protected
$user
;
protected
$status
;
/**
* ChatMember constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
user
=
isset
(
$data
[
'user'
])
?
$data
[
'user'
]
:
null
;
...
...
src/Entities/ChosenInlineResult.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class ChosenInlineResult extends Entity
protected
$inline_message_id
;
protected
$query
;
/**
* ChosenInlineResult constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
result_id
=
isset
(
$data
[
'result_id'
])
?
$data
[
'result_id'
]
:
null
;
...
...
src/Entities/Contact.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class Contact extends Entity
protected
$last_name
;
protected
$user_id
;
/**
* Contact constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
phone_number
=
isset
(
$data
[
'phone_number'
])
?
$data
[
'phone_number'
]
:
null
;
...
...
src/Entities/Document.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class Document extends Entity
protected
$mime_type
;
protected
$file_size
;
/**
* Document constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
...
...
src/Entities/File.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class File extends Entity
protected
$file_size
;
protected
$file_path
;
/**
* File constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
file_id
=
isset
(
$data
[
'file_id'
])
?
$data
[
'file_id'
]
:
null
;
...
...
src/Entities/ForceReply.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class ForceReply extends Entity
protected
$force_reply
;
protected
$selective
;
/**
* ForceReply constructor.
*
* @param array|null $data
*/
public
function
__construct
(
array
$data
=
null
)
{
$this
->
force_reply
=
true
;
...
...
src/Entities/InlineKeyboardButton.php
View file @
1513e971
...
...
@@ -19,8 +19,13 @@ class InlineKeyboardButton extends Entity
protected
$callback_data
;
protected
$switch_inline_query
;
/**
* InlineKeyboardButton constructor.
*
* @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
*
* @param array $data
*/
public
function
__construct
(
$data
=
array
())
{
...
...
src/Entities/InlineKeyboardMarkup.php
View file @
1513e971
...
...
@@ -16,6 +16,11 @@ class InlineKeyboardMarkup extends Entity
{
protected
$inline_keyboard
;
/**
* InlineKeyboardMarkup constructor.
*
* @param array $data
*/
public
function
__construct
(
$data
=
array
())
{
if
(
isset
(
$data
[
'inline_keyboard'
]))
{
...
...
src/Entities/InlineQuery.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class InlineQuery extends Entity
protected
$query
;
protected
$offset
;
/**
* InlineQuery constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
id
=
isset
(
$data
[
'id'
])
?
$data
[
'id'
]
:
null
;
...
...
src/Entities/InlineQueryResult.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResult extends Entity
protected
$input_message_content
;
protected
$reply_markup
;
/**
* InlineQueryResult constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
type
=
null
;
...
...
src/Entities/InlineQueryResultArticle.php
View file @
1513e971
...
...
@@ -23,6 +23,11 @@ class InlineQueryResultArticle extends InlineQueryResult
protected
$thumb_width
;
protected
$thumb_height
;
/**
* InlineQueryResultArticle constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultAudio.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultAudio extends InlineQueryResult
protected
$performer
;
protected
$audio_duration
;
/**
* InlineQueryResultAudio constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedAudio.php
View file @
1513e971
...
...
@@ -16,6 +16,11 @@ class InlineQueryResultCachedAudio extends InlineQueryResult
{
protected
$audio_file_id
;
/**
* InlineQueryResultCachedAudio constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedDocument.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultCachedDocument extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultCachedDocument constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedGif.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultCachedGif extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultCachedGif constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedMpeg4Gif.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult
protected
$title
;
protected
$caption
;
/**
* InlineQueryResultCachedMpeg4Gif constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedPhoto.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultCachedPhoto constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedSticker.php
View file @
1513e971
...
...
@@ -16,6 +16,11 @@ class InlineQueryResultCachedSticker extends InlineQueryResult
{
protected
$sticker_file_id
;
/**
* InlineQueryResultCachedSticker constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedVideo.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultCachedVideo extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultCachedVideo constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultCachedVoice.php
View file @
1513e971
...
...
@@ -19,6 +19,11 @@ class InlineQueryResultCachedVoice extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultCachedVoice constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultContact.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class InlineQueryResultContact extends InlineQueryResult
protected
$thumb_width
;
protected
$thumb_height
;
/**
* InlineQueryResultContact constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultDocument.php
View file @
1513e971
...
...
@@ -23,6 +23,11 @@ class InlineQueryResultDocument extends InlineQueryResult
protected
$thumb_width
;
protected
$thumb_height
;
/**
* InlineQueryResultDocument constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultGif.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class InlineQueryResultGif extends InlineQueryResult
protected
$title
;
protected
$caption
;
/**
* InlineQueryResultGif constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultLocation.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class InlineQueryResultLocation extends InlineQueryResult
protected
$thumb_width
;
protected
$thumb_height
;
/**
* InlineQueryResultLocation constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultMpeg4Gif.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult
protected
$title
;
protected
$caption
;
/**
* InlineQueryResultMpeg4Gif constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultPhoto.php
View file @
1513e971
...
...
@@ -22,6 +22,11 @@ class InlineQueryResultPhoto extends InlineQueryResult
protected
$description
;
protected
$caption
;
/**
* InlineQueryResultPhoto constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultVenue.php
View file @
1513e971
...
...
@@ -23,6 +23,11 @@ class InlineQueryResultVenue extends InlineQueryResult
protected
$thumb_width
;
protected
$thumb_height
;
/**
* InlineQueryResultVenue constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultVideo.php
View file @
1513e971
...
...
@@ -24,6 +24,11 @@ class InlineQueryResultVideo extends InlineQueryResult
protected
$video_duration
;
protected
$description
;
/**
* InlineQueryResultVideo constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InlineQueryResultVoice.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class InlineQueryResultVoice extends InlineQueryResult
protected
$title
;
protected
$voice_duration
;
/**
* InlineQueryResultVoice constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
parent
::
__construct
(
$data
);
...
...
src/Entities/InputContactMessageContent.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class InputContactMessageContent extends InputMessageContent
protected
$first_name
;
protected
$last_name
;
/**
* InputContactMessageContent constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
phone_number
=
isset
(
$data
[
'phone_number'
])
?
$data
[
'phone_number'
]
:
null
;
...
...
src/Entities/InputLocationMessageContent.php
View file @
1513e971
...
...
@@ -17,6 +17,11 @@ class InputLocationMessageContent extends InputMessageContent
protected
$latitude
;
protected
$longitude
;
/**
* InputLocationMessageContent constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
latitude
=
isset
(
$data
[
'latitude'
])
?
$data
[
'latitude'
]
:
null
;
...
...
src/Entities/InputTextMessageContent.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class InputTextMessageContent extends InputMessageContent
protected
$parse_mode
;
protected
$disable_web_page_preview
;
/**
* InputTextMessageContent constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
message_text
=
isset
(
$data
[
'message_text'
])
?
$data
[
'message_text'
]
:
null
;
...
...
src/Entities/InputVenueMessageContent.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class InputVenueMessageContent extends InputMessageContent
protected
$address
;
protected
$foursquare_id
;
/**
* InputVenueMessageContent constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
latitude
=
isset
(
$data
[
'latitude'
])
?
$data
[
'latitude'
]
:
null
;
...
...
src/Entities/KeyboardButton.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class KeyboardButton extends Entity
protected
$request_contact
;
protected
$request_location
;
/**
* KeyboardButton constructor.
*
* @param array $data
*/
public
function
__construct
(
$data
=
array
())
{
$this
->
text
=
isset
(
$data
[
'text'
])
?
$data
[
'text'
]
:
null
;
...
...
src/Entities/Location.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class Location extends Entity
protected
$longitude
;
protected
$latitude
;
/**
* Location constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/Message.php
View file @
1513e971
...
...
@@ -82,6 +82,12 @@ class Message extends Entity
private
$type
;
/**
* Message constructor.
*
* @param array $data
* @param $bot_name
*/
public
function
__construct
(
array
$data
,
$bot_name
)
{
...
...
@@ -334,6 +340,11 @@ class Message extends Entity
return
$this
->
message_id
;
}
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\User
*/
public
function
getFrom
()
{
return
$this
->
from
;
...
...
@@ -344,16 +355,31 @@ class Message extends Entity
return
$this
->
date
;
}
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\Chat
*/
public
function
getChat
()
{
return
$this
->
chat
;
}
/**
* Get User object related to the forwarded message
*
* @return \Longman\TelegramBot\Entities\User
*/
public
function
getForwardFrom
()
{
return
$this
->
forward_from
;
}
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\Chat
*/
public
function
getForwardFromChat
()
{
return
$this
->
forward_from_chat
;
...
...
@@ -388,30 +414,48 @@ class Message extends Entity
return
$text
;
}
/**
* @return \Longman\TelegramBot\Entities\Audio
*/
public
function
getAudio
()
{
return
$this
->
audio
;
}
/**
* @return \Longman\TelegramBot\Entities\Document
*/
public
function
getDocument
()
{
return
$this
->
document
;
}
/**
* @return array
*/
public
function
getPhoto
()
{
return
$this
->
photo
;
}
/**
* @return \Longman\TelegramBot\Entities\Sticker
*/
public
function
getSticker
()
{
return
$this
->
sticker
;
}
/**
* @return \Longman\TelegramBot\Entities\Video
*/
public
function
getVideo
()
{
return
$this
->
video
;
}
/**
* @return \Longman\TelegramBot\Entities\Voice
*/
public
function
getVoice
()
{
return
$this
->
voice
;
...
...
@@ -422,11 +466,17 @@ class Message extends Entity
return
$this
->
caption
;
}
/**
* @return \Longman\TelegramBot\Entities\Contact
*/
public
function
getContact
()
{
return
$this
->
contact
;
}
/**
* @return \Longman\TelegramBot\Entities\Location
*/
public
function
getLocation
()
{
return
$this
->
location
;
...
...
@@ -446,12 +496,21 @@ class Message extends Entity
{
return
$this
->
left_chat_member
;
}
/**
* Get User object related to the new member
*
* @return \Longman\TelegramBot\Entities\User
*/
public
function
getNewChatMember
()
{
return
$this
->
new_chat_member
;
}
/**
* Get User object related to the left member
*
* @return \Longman\TelegramBot\Entities\User
*/
public
function
getLeftChatMember
()
{
return
$this
->
left_chat_member
;
...
...
src/Entities/MessageEntity.php
View file @
1513e971
...
...
@@ -10,6 +10,8 @@
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
MessageEntity
extends
Entity
{
protected
$type
;
...
...
@@ -19,7 +21,11 @@ class MessageEntity extends Entity
protected
$user
;
/**
* MessageEntity constructor.
*
* @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/PhotoSize.php
View file @
1513e971
...
...
@@ -18,8 +18,12 @@ class PhotoSize extends Entity
protected
$width
;
protected
$height
;
protected
$file_size
;
/**
* PhotoSize constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/ReplyKeyboardHide.php
View file @
1513e971
...
...
@@ -12,13 +12,16 @@
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ReplyKeyboardHide
extends
Entity
{
protected
$hide_keyboard
;
protected
$selective
;
/**
* ReplyKeyboardHide constructor.
*
* @param array|null $data
*/
public
function
__construct
(
array
$data
=
null
)
{
$this
->
hide_keyboard
=
true
;
...
...
src/Entities/ReplyKeyboardMarkup.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class ReplyKeyboardMarkup extends Entity
protected
$one_time_keyboard
;
protected
$selective
;
/**
* ReplyKeyboardMarkup constructor.
*
* @param array $data
*/
public
function
__construct
(
$data
=
array
())
{
if
(
isset
(
$data
[
'keyboard'
]))
{
...
...
src/Entities/ReplyToMessage.php
View file @
1513e971
...
...
@@ -10,11 +10,15 @@
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ReplyToMessage
extends
Message
{
/**
* ReplyToMessage constructor.
*
* @param array $data
* @param $bot_name
*/
public
function
__construct
(
array
$data
,
$bot_name
)
{
...
...
src/Entities/ServerResponse.php
View file @
1513e971
...
...
@@ -10,8 +10,6 @@
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Exception\TelegramException
;
class
ServerResponse
extends
Entity
{
protected
$ok
;
...
...
@@ -19,6 +17,12 @@ class ServerResponse extends Entity
protected
$error_code
;
protected
$description
;
/**
* ServerResponse constructor.
*
* @param array $data
* @param $bot_name
*/
public
function
__construct
(
array
$data
,
$bot_name
)
{
if
(
isset
(
$data
[
'ok'
])
&
isset
(
$data
[
'result'
]))
{
...
...
src/Entities/Sticker.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class Sticker extends Entity
protected
$emoji
;
protected
$file_size
;
/**
* Sticker constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/Update.php
View file @
1513e971
...
...
@@ -24,6 +24,12 @@ class Update extends Entity
private
$update_type
;
/**
* Update constructor.
*
* @param array $data
* @param $bot_name
*/
public
function
__construct
(
array
$data
,
$bot_name
)
{
...
...
src/Entities/User.php
View file @
1513e971
...
...
@@ -20,6 +20,11 @@ class User extends Entity
protected
$last_name
;
protected
$username
;
/**
* User constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/UserProfilePhotos.php
View file @
1513e971
...
...
@@ -18,6 +18,11 @@ class UserProfilePhotos extends Entity
protected
$total_count
;
protected
$photos
;
/**
* UserProfilePhotos constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/Venue.php
View file @
1513e971
...
...
@@ -21,6 +21,11 @@ class Venue extends Entity
protected
$address
;
protected
$foursquare_id
;
/**
* Venue constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
$this
->
location
=
isset
(
$data
[
'location'
])
?
$data
[
'location'
]
:
null
;
...
...
src/Entities/Video.php
View file @
1513e971
...
...
@@ -22,6 +22,11 @@ class Video extends Entity
protected
$mime_type
;
protected
$file_size
;
/**
* Video constructor.
*
* @param array $data
*/
public
function
__construct
(
array
$data
)
{
...
...
src/Entities/Voice.php
View file @
1513e971
...
...
@@ -19,10 +19,13 @@ class Voice extends Entity
protected
$mime_type
;
protected
$file_size
;
/**
* Voice constructor.
*
* @param array $data
*/
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!'
);
...
...
@@ -35,7 +38,6 @@ class Voice extends Entity
$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
()
...
...
src/Request.php
View file @
1513e971
...
...
@@ -239,7 +239,7 @@ class Request
*
* @param string $file
*
* @return CURLFile
* @return
\
CURLFile
*/
protected
static
function
encodeFile
(
$file
)
{
...
...
@@ -308,7 +308,7 @@ class Request
$string_len_utf8
=
mb_strlen
(
$text
,
'UTF-8'
);
if
(
$string_len_utf8
>
4096
)
{
$data
[
'text'
]
=
mb_substr
(
$text
,
0
,
4096
);
$result
=
self
::
send
(
'sendMessage'
,
$data
);
self
::
send
(
'sendMessage'
,
$data
);
$data
[
'text'
]
=
mb_substr
(
$text
,
4096
,
$string_len_utf8
);
return
self
::
sendMessage
(
$data
);
}
...
...
src/Telegram.php
View file @
1513e971
...
...
@@ -171,7 +171,7 @@ class Telegram
/**
* Initialize Database external connection
*
* @param PDO $external_pdo_connection PDO database object
* @param
/
PDO $external_pdo_connection PDO database object
* @param string $table_prefix
*/
public
function
enableExternalMysql
(
$external_pdo_connection
,
$table_prefix
=
null
)
...
...
@@ -230,7 +230,7 @@ class Telegram
*
* @param string $command
*
* @return
Entitie
s\Command|null
* @return
\Longman\TelegramBot\Command
s\Command|null
*/
public
function
getCommandObject
(
$command
)
{
...
...
@@ -445,8 +445,13 @@ class Telegram
return
$this
->
last_command_response
;
}
/**
* @todo Complete DocBlock
* Sanitize Command
*
* @param string $command
*
* @return string
*/
protected
function
sanitizeCommand
(
$command
)
{
...
...
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