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
6b07ca55
Commit
6b07ca55
authored
Apr 15, 2016
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'entities' and 'pinned_message' added, table structure updated, some comments updated
parent
d4ccf64b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
10 deletions
+32
-10
DB.php
src/DB.php
+21
-7
InlineKeyboardMarkup.php
src/Entities/InlineKeyboardMarkup.php
+1
-1
Message.php
src/Entities/Message.php
+3
-0
MessageEntity.php
src/Entities/MessageEntity.php
+2
-2
ReplyKeyboardMarkup.php
src/Entities/ReplyKeyboardMarkup.php
+3
-0
structure.sql
structure.sql
+2
-0
No files found.
src/DB.php
View file @
6b07ca55
...
@@ -572,6 +572,7 @@ class DB
...
@@ -572,6 +572,7 @@ class DB
$forward_date
=
self
::
getTimestamp
(
$message
->
getForwardDate
());
$forward_date
=
self
::
getTimestamp
(
$message
->
getForwardDate
());
$photo
=
$message
->
getPhoto
();
$photo
=
$message
->
getPhoto
();
$entities
=
$message
->
getEntities
();
$new_chat_member
=
$message
->
getNewChatMember
();
$new_chat_member
=
$message
->
getNewChatMember
();
$new_chat_photo
=
$message
->
getNewChatPhoto
();
$new_chat_photo
=
$message
->
getNewChatPhoto
();
...
@@ -596,14 +597,11 @@ class DB
...
@@ -596,14 +597,11 @@ class DB
$type
=
$chat
->
getType
();
$type
=
$chat
->
getType
();
if
(
$migrate_to_chat_id
)
{
if
(
$migrate_to_chat_id
)
{
$type
=
'supergroup'
;
$type
=
'supergroup'
;
$sth2
->
bindParam
(
':id'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':id'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':oldid'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':oldid'
,
$chat_id
,
\PDO
::
PARAM_INT
);
}
else
{
}
else
{
$sth2
->
bindParam
(
':id'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':id'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':oldid'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':oldid'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
}
}
...
@@ -643,21 +641,21 @@ class DB
...
@@ -643,21 +641,21 @@ class DB
$sth
=
self
::
$pdo
->
prepare
(
'INSERT IGNORE INTO `'
.
TB_MESSAGE
.
'`
$sth
=
self
::
$pdo
->
prepare
(
'INSERT IGNORE INTO `'
.
TB_MESSAGE
.
'`
(
(
`id`, `user_id`, `date`, `chat_id`, `forward_from`,
`id`, `user_id`, `date`, `chat_id`, `forward_from`,
`forward_date`, `reply_to_chat`, `reply_to_message`, `text`, `audio`, `document`,
`forward_date`, `reply_to_chat`, `reply_to_message`, `text`, `
entities`, `
audio`, `document`,
`photo`, `sticker`, `video`, `voice`, `caption`, `contact`,
`photo`, `sticker`, `video`, `voice`, `caption`, `contact`,
`location`, `venue`, `new_chat_member`, `left_chat_member`,
`location`, `venue`, `new_chat_member`, `left_chat_member`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`supergroup_chat_created`, `channel_chat_created`,
`supergroup_chat_created`, `channel_chat_created`,
`migrate_from_chat_id`, `migrate_to_chat_id`
`migrate_from_chat_id`, `migrate_to_chat_id`
, `pinned_message`
)
)
VALUES (
VALUES (
:message_id, :user_id, :date, :chat_id, :forward_from,
:message_id, :user_id, :date, :chat_id, :forward_from,
:forward_date, :reply_to_chat, :reply_to_message, :text, :audio, :document,
:forward_date, :reply_to_chat, :reply_to_message, :text, :
entities, :
audio, :document,
:photo, :sticker, :video, :voice, :caption, :contact,
:photo, :sticker, :video, :voice, :caption, :contact,
:location, :venue, :new_chat_member, :left_chat_member,
:location, :venue, :new_chat_member, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:supergroup_chat_created, :channel_chat_created,
:supergroup_chat_created, :channel_chat_created,
:migrate_from_chat_id, :migrate_to_chat_id
:migrate_from_chat_id, :migrate_to_chat_id
, :pinned_message
)'
);
)'
);
$message_id
=
$message
->
getMessageId
();
$message_id
=
$message
->
getMessageId
();
...
@@ -689,6 +687,7 @@ class DB
...
@@ -689,6 +687,7 @@ class DB
$channel_chat_created
=
$message
->
getChannelChatCreated
();
$channel_chat_created
=
$message
->
getChannelChatCreated
();
$migrate_from_chat_id
=
$message
->
getMigrateFromChatId
();
$migrate_from_chat_id
=
$message
->
getMigrateFromChatId
();
$migrate_to_chat_id
=
$message
->
getMigrateToChatId
();
$migrate_to_chat_id
=
$message
->
getMigrateToChatId
();
$pinned_message
=
$message
->
getPinnedMessage
();
$sth
->
bindParam
(
':chat_id'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':chat_id'
,
$chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':message_id'
,
$message_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':message_id'
,
$message_id
,
\PDO
::
PARAM_INT
);
...
@@ -700,9 +699,22 @@ class DB
...
@@ -700,9 +699,22 @@ class DB
if
(
$reply_to_message_id
)
{
if
(
$reply_to_message_id
)
{
$reply_chat_id
=
$chat_id
;
$reply_chat_id
=
$chat_id
;
}
}
$var
=
[];
if
(
is_array
(
$entities
))
{
foreach
(
$entities
as
$elm
)
{
$var
[]
=
json_decode
(
$elm
,
true
);
}
$entities
=
json_encode
(
$var
);
}
else
{
$entities
=
''
;
}
$sth
->
bindParam
(
':reply_to_chat'
,
$reply_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':reply_to_chat'
,
$reply_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':reply_to_message'
,
$reply_to_message_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':reply_to_message'
,
$reply_to_message_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':text'
,
$text
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':text'
,
$text
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':entities'
,
$entities
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':audio'
,
$audio
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':audio'
,
$audio
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':document'
,
$document
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':document'
,
$document
,
\PDO
::
PARAM_STR
);
...
@@ -748,6 +760,8 @@ class DB
...
@@ -748,6 +760,8 @@ class DB
$sth
->
bindParam
(
':channel_chat_created'
,
$channel_chat_created
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':channel_chat_created'
,
$channel_chat_created
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_from_chat_id'
,
$migrate_from_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_from_chat_id'
,
$migrate_from_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_to_chat_id'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_to_chat_id'
,
$migrate_to_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':pinned_message'
,
$pinned_message
,
\PDO
::
PARAM_INT
);
$status
=
$sth
->
execute
();
$status
=
$sth
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
PDOException
$e
)
{
...
...
src/Entities/InlineKeyboardMarkup.php
View file @
6b07ca55
...
@@ -17,7 +17,7 @@ class InlineKeyboardMarkup extends Entity
...
@@ -17,7 +17,7 @@ class InlineKeyboardMarkup extends Entity
protected
$inline_keyboard
;
protected
$inline_keyboard
;
/*
/*
* @todo
:
check for InlineKeyboardButton elements
* @todo check for InlineKeyboardButton elements
*/
*/
public
function
__construct
(
$data
=
array
())
public
function
__construct
(
$data
=
array
())
{
{
...
...
src/Entities/Message.php
View file @
6b07ca55
...
@@ -250,6 +250,9 @@ class Message extends Entity
...
@@ -250,6 +250,9 @@ class Message extends Entity
}
}
$this
->
pinned_message
=
isset
(
$data
[
'pinned_message'
])
?
$data
[
'pinned_message'
]
:
null
;
$this
->
pinned_message
=
isset
(
$data
[
'pinned_message'
])
?
$data
[
'pinned_message'
]
:
null
;
if
(
$this
->
pinned_message
)
{
$this
->
pinned_message
=
new
Message
(
$this
->
pinned_message
,
$this
->
getBotName
());
}
$this
->
entities
=
isset
(
$data
[
'entities'
])
?
$data
[
'entities'
]
:
null
;
$this
->
entities
=
isset
(
$data
[
'entities'
])
?
$data
[
'entities'
]
:
null
;
if
(
!
empty
(
$this
->
entities
))
{
if
(
!
empty
(
$this
->
entities
))
{
...
...
src/Entities/MessageEntity.php
View file @
6b07ca55
...
@@ -20,12 +20,12 @@ class MessageEntity extends Entity
...
@@ -20,12 +20,12 @@ class MessageEntity extends Entity
public
function
__construct
(
array
$data
)
public
function
__construct
(
array
$data
)
{
{
$this
->
type
=
isset
(
$data
[
'type'
])
?
$data
[
'type'
]
:
null
;
$this
->
type
=
isset
(
$data
[
'type'
])
?
$data
[
'type'
]
:
null
;
if
(
empty
(
$this
->
type
))
{
if
(
empty
(
$this
->
type
))
{
// @todo check for value from this list: https://core.telegram.org/bots/api#messageentity
throw
new
TelegramException
(
'type is empty!'
);
throw
new
TelegramException
(
'type is empty!'
);
}
}
$this
->
offset
=
isset
(
$data
[
'offset'
])
?
$data
[
'offset'
]
:
null
;
$this
->
offset
=
isset
(
$data
[
'offset'
])
?
$data
[
'offset'
]
:
null
;
if
(
empty
(
$this
->
offset
)
&&
$this
->
offset
!=
0
)
{
// @todo
:
this is not an ideal solution?
if
(
empty
(
$this
->
offset
)
&&
$this
->
offset
!=
0
)
{
// @todo
this is not an ideal solution?
throw
new
TelegramException
(
'offset is empty!'
);
throw
new
TelegramException
(
'offset is empty!'
);
}
}
...
...
src/Entities/ReplyKeyboardMarkup.php
View file @
6b07ca55
...
@@ -19,6 +19,9 @@ class ReplyKeyboardMarkup extends Entity
...
@@ -19,6 +19,9 @@ class ReplyKeyboardMarkup extends Entity
protected
$one_time_keyboard
;
protected
$one_time_keyboard
;
protected
$selective
;
protected
$selective
;
/*
* @todo check for KeyboardButton elements
*/
public
function
__construct
(
$data
=
array
())
public
function
__construct
(
$data
=
array
())
{
{
if
(
isset
(
$data
[
'keyboard'
]))
{
if
(
isset
(
$data
[
'keyboard'
]))
{
...
...
structure.sql
View file @
6b07ca55
...
@@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS `message` (
...
@@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS `message` (
`reply_to_chat`
bigint
NULL
DEFAULT
NULL
COMMENT
'Chat identifier.'
,
`reply_to_chat`
bigint
NULL
DEFAULT
NULL
COMMENT
'Chat identifier.'
,
`reply_to_message`
bigint
UNSIGNED
DEFAULT
NULL
COMMENT
'Message is a reply to another message.'
,
`reply_to_message`
bigint
UNSIGNED
DEFAULT
NULL
COMMENT
'Message is a reply to another message.'
,
`text`
TEXT
DEFAULT
NULL
COMMENT
'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8'
,
`text`
TEXT
DEFAULT
NULL
COMMENT
'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8'
,
`entities`
TEXT
DEFAULT
NULL
COMMENT
'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text'
,
`audio`
TEXT
DEFAULT
NULL
COMMENT
'Audio object. Message is an audio file, information about the file'
,
`audio`
TEXT
DEFAULT
NULL
COMMENT
'Audio object. Message is an audio file, information about the file'
,
`document`
TEXT
DEFAULT
NULL
COMMENT
'Document object. Message is a general file, information about the file'
,
`document`
TEXT
DEFAULT
NULL
COMMENT
'Document object. Message is a general file, information about the file'
,
`photo`
TEXT
DEFAULT
NULL
COMMENT
'Array of PhotoSize objects. Message is a photo, available sizes of the photo'
,
`photo`
TEXT
DEFAULT
NULL
COMMENT
'Array of PhotoSize objects. Message is a photo, available sizes of the photo'
,
...
@@ -106,6 +107,7 @@ CREATE TABLE IF NOT EXISTS `message` (
...
@@ -106,6 +107,7 @@ CREATE TABLE IF NOT EXISTS `message` (
`channel_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the channel chat has been created'
,
`channel_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the channel chat has been created'
,
`migrate_from_chat_id`
bigint
NULL
DEFAULT
NULL
COMMENT
'Migrate from chat identifier.'
,
`migrate_from_chat_id`
bigint
NULL
DEFAULT
NULL
COMMENT
'Migrate from chat identifier.'
,
`migrate_to_chat_id`
bigint
NULL
DEFAULT
NULL
COMMENT
'Migrate to chat identifier.'
,
`migrate_to_chat_id`
bigint
NULL
DEFAULT
NULL
COMMENT
'Migrate to chat identifier.'
,
`pinned_message`
TEXT
NULL
DEFAULT
NULL
COMMENT
'Pinned message, Message object.'
,
PRIMARY
KEY
(
`chat_id`
,
`id`
),
PRIMARY
KEY
(
`chat_id`
,
`id`
),
KEY
`user_id`
(
`user_id`
),
KEY
`user_id`
(
`user_id`
),
KEY
`forward_from`
(
`forward_from`
),
KEY
`forward_from`
(
`forward_from`
),
...
...
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