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
a6f664f5
Commit
a6f664f5
authored
Dec 24, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing Super groups
parent
56bf8fc8
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
200 additions
and
32 deletions
+200
-32
README.md
README.md
+9
-6
ChatsCommand.php
src/Admin/ChatsCommand.php
+13
-7
SendtoallCommand.php
src/Admin/SendtoallCommand.php
+2
-1
ChannelchatcreatedCommand.php
src/Commands/ChannelchatcreatedCommand.php
+35
-0
EchoCommand.php
src/Commands/EchoCommand.php
+1
-1
SupergroupchatcreatedCommand.php
src/Commands/SupergroupchatcreatedCommand.php
+43
-0
DB.php
src/DB.php
+35
-11
Message.php
src/Entities/Message.php
+43
-1
Request.php
src/Request.php
+3
-2
Telegram.php
src/Telegram.php
+10
-2
structure.sql
structure.sql
+6
-1
No files found.
README.md
View file @
a6f664f5
...
@@ -21,7 +21,8 @@ Bot aims to provide a platform where one could simply write a plugin
...
@@ -21,7 +21,8 @@ Bot aims to provide a platform where one could simply write a plugin
and have interactions in a matter of minutes.
and have interactions in a matter of minutes.
The Bot can:
The Bot can:
-
retrive update with webhook and getUpdate methods.
-
retrive update with webhook and getUpdate methods.
-
supports all types and methods according to Telegram API (2015 October 28).
-
supports all types and methods according to Telegram API (2015 November).
-
supports supergroups.
-
handle commands in chat with other bots.
-
handle commands in chat with other bots.
-
manage Channel from the bot admin interface (
**new!**
)
-
manage Channel from the bot admin interface (
**new!**
)
...
@@ -206,10 +207,10 @@ then run
...
@@ -206,10 +207,10 @@ then run
./getUpdateCLI.php
./getUpdateCLI.php
```
```
### Types
### Types
All types implemented according to Telegram API (2015
October 28
).
All types implemented according to Telegram API (2015
November
).
### Methods
### Methods
All methods implemented according to Telegram API (2015
October 28
).
All methods implemented according to Telegram API (2015
November
).
####Send Photo
####Send Photo
To send a local photo provide the file path as second param:
To send a local photo provide the file path as second param:
...
@@ -282,11 +283,13 @@ All methods implemented can be used to manage channels.
...
@@ -282,11 +283,13 @@ All methods implemented can be used to manage channels.
The bot is able to recognise commands in chat with multiple bot (/command@mybot ).
The bot is able to recognise commands in chat with multiple bot (/command@mybot ).
It can execute command triggering a chat event. Here's the list:
It can execute command triggering a chat event. Here's the list:
-
Group chat created (
**GroupchatcreatedCommand.php**
)
-
New chat participant (
**NewchatparticipantCommand.php**
)
-
New chat participant (
**NewchatparticipantCommand.php**
)
-
Delete chat photo (
**DeletechatphotoCommand.php**
)
-
New chat title (
**NewchattitleCommand.php**
)
-
Left chat participant (
**LeftchatparticipantCommand.php**
)
-
Left chat participant (
**LeftchatparticipantCommand.php**
)
-
New chat title (
**NewchattitleCommand.php**
)
-
Delete chat photo (
**DeletechatphotoCommand.php**
)
-
Group chat created (
**GroupchatcreatedCommand.php**
)
-
Super group chat created (
**SupergroupchatcreatedCommand.php**
)
-
Channel chat created (
**ChannelchatcreatedCommand.php**
)
**GenericCommand.php**
let you handle commands that don't exist or to
**GenericCommand.php**
let you handle commands that don't exist or to
use commands as a variable:
use commands as a variable:
...
...
src/Admin/ChatsCommand.php
View file @
a6f664f5
...
@@ -49,7 +49,8 @@ class ChatsCommand extends Command
...
@@ -49,7 +49,8 @@ class ChatsCommand extends Command
$text
=
$message
->
getText
(
true
);
$text
=
$message
->
getText
(
true
);
$results
=
DB
::
selectChats
(
$results
=
DB
::
selectChats
(
true
,
//Send to chats (group chat)
true
,
//Send to groups (group chat)
true
,
//Send to supergroups (single chat)
true
,
//Send to users (single chat)
true
,
//Send to users (single chat)
null
,
//'yyyy-mm-dd hh:mm:ss' date range from
null
,
//'yyyy-mm-dd hh:mm:ss' date range from
null
//'yyyy-mm-dd hh:mm:ss' date range to
null
//'yyyy-mm-dd hh:mm:ss' date range to
...
@@ -57,6 +58,7 @@ class ChatsCommand extends Command
...
@@ -57,6 +58,7 @@ class ChatsCommand extends Command
$user_chats
=
0
;
$user_chats
=
0
;
$group_chats
=
0
;
$group_chats
=
0
;
$super_group_chats
=
0
;
$text
=
"List of bot chats:
\n
"
;
$text
=
"List of bot chats:
\n
"
;
foreach
(
$results
as
$result
)
{
foreach
(
$results
as
$result
)
{
...
@@ -66,20 +68,24 @@ class ChatsCommand extends Command
...
@@ -66,20 +68,24 @@ class ChatsCommand extends Command
$chat
=
new
Chat
(
$result
);
$chat
=
new
Chat
(
$result
);
if
(
$chat
->
isPrivateChat
())
{
if
(
$chat
->
isPrivateChat
())
{
$text
.=
'-
U
'
.
$this
->
tryMentionChat
(
$chat
)
.
"
\n
"
;
$text
.=
'-
P
'
.
$this
->
tryMentionChat
(
$chat
)
.
"
\n
"
;
++
$user_chats
;
++
$user_chats
;
}
else
{
}
else
if
(
$chat
->
isGroupChat
())
{
$text
.=
'- G '
.
$chat
->
getTitle
()
.
"
\n
"
;
$text
.=
'- G '
.
$chat
->
getTitle
()
.
"
\n
"
;
++
$group_chats
;
++
$group_chats
;
}
elseif
(
$chat
->
isSuperGroup
())
{
$text
.=
'- S '
.
$chat
->
getTitle
()
.
"
\n
"
;
++
$super_group_chats
;
}
}
}
}
if
((
$group_chats
+
$user_chats
)
==
0
)
{
if
((
$group_chats
+
$user_chats
+
$super_group_chats
)
==
0
)
{
$text
=
"No chats found.."
;
$text
=
"No chats found.."
;
}
else
{
}
else
{
$text
.=
"
\n
User Chats: "
.
$user_chats
;
$text
.=
"
\n
Private Chats: "
.
$user_chats
;
$text
.=
"
\n
Group Chats: "
.
$group_chats
;
$text
.=
"
\n
Group: "
.
$group_chats
;
$text
.=
"
\n
Tot: "
.
(
$group_chats
+
$user_chats
);
$text
.=
"
\n
Super Group: "
.
$super_group_chats
;
$text
.=
"
\n
Tot: "
.
(
$group_chats
+
$user_chats
+
$super_group_chats
);
}
}
$data
=
[];
$data
=
[];
...
...
src/Admin/SendtoallCommand.php
View file @
a6f664f5
...
@@ -54,7 +54,8 @@ class SendtoallCommand extends Command
...
@@ -54,7 +54,8 @@ class SendtoallCommand extends Command
$results
=
Request
::
sendToActiveChats
(
$results
=
Request
::
sendToActiveChats
(
'sendMessage'
,
//callback function to execute (see Request.php methods)
'sendMessage'
,
//callback function to execute (see Request.php methods)
array
(
'text'
=>
$text
),
//Param to evaluate the request
array
(
'text'
=>
$text
),
//Param to evaluate the request
true
,
//Send to chats (group chat)
true
,
//Send to groups (group chat)
true
,
//Send to super groups chats (super group chat)
true
,
//Send to users (single chat)
true
,
//Send to users (single chat)
null
,
//'yyyy-mm-dd hh:mm:ss' date range from
null
,
//'yyyy-mm-dd hh:mm:ss' date range from
null
//'yyyy-mm-dd hh:mm:ss' date range to
null
//'yyyy-mm-dd hh:mm:ss' date range to
...
...
src/Commands/ChannelchatcreatedCommand.php
0 → 100644
View file @
a6f664f5
<?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\Commands
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
class
ChannelchatcreatedCommand
extends
Command
{
protected
$name
=
'Channelchatcreated'
;
protected
$description
=
'Channel chat created'
;
protected
$usage
=
'/'
;
protected
$version
=
'1.0.0'
;
protected
$enabled
=
true
;
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$channel_chat_created
=
$message
->
getChannelChatCreated
();
// temporary do nothing
}
}
src/Commands/EchoCommand.php
View file @
a6f664f5
...
@@ -31,7 +31,7 @@ class EchoCommand extends Command
...
@@ -31,7 +31,7 @@ class EchoCommand extends Command
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$text
=
$message
->
getText
(
true
);
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
$text
;
$data
[
'text'
]
=
$text
;
...
...
src/Commands/SupergroupchatcreatedCommand.php
0 → 100644
View file @
a6f664f5
<?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\Commands
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
class
SupergroupchatcreatedCommand
extends
Command
{
protected
$name
=
'Supergroupchatcreated'
;
protected
$description
=
'Super group chat created'
;
protected
$usage
=
'/'
;
protected
$version
=
'1.0.0'
;
protected
$enabled
=
true
;
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$text
=
''
;
if
(
$message
->
getSuperGroupChatCreated
())
{
$text
=
"Your group has become a Supergroup!
\n
"
;
$text
.=
'Chat id has changed from'
.
$message
->
getMigrateFromChatId
()
.
' to '
.
$message
->
getMigrateToChatId
();
}
$data
=
[];
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
$text
;
$result
=
Request
::
sendMessage
(
$data
);
return
$result
;
}
}
src/DB.php
View file @
a6f664f5
...
@@ -239,11 +239,16 @@ class DB
...
@@ -239,11 +239,16 @@ class DB
$new_chat_photo
=
$message
->
getNewChatPhoto
();
$new_chat_photo
=
$message
->
getNewChatPhoto
();
$left_chat_participant
=
$message
->
getLeftChatParticipant
();
$left_chat_participant
=
$message
->
getLeftChatParticipant
();
$migrate_from_chat_id
=
$message
->
getMigrateFromChatId
();
if
(
is_null
(
$migrate_from_chat_id
))
{
$migrate_from_chat_id
=
0
;
}
try
{
try
{
//chats table
//chats table
$sth2
=
self
::
$pdo
->
prepare
(
'INSERT INTO `'
.
TB_CHATS
.
'`
$sth2
=
self
::
$pdo
->
prepare
(
'INSERT INTO `'
.
TB_CHATS
.
'`
(`id`, `type`, `title`, `created_at` ,`updated_at`)
(`id`, `type`, `title`, `created_at` ,`updated_at`
, `old_id`
)
VALUES (:id, :type, :title, :date, :date)
VALUES (:id, :type, :title, :date, :date
, :oldid
)
ON DUPLICATE KEY UPDATE `title`=:title, `updated_at`=:date'
);
ON DUPLICATE KEY UPDATE `title`=:title, `updated_at`=:date'
);
$chat_title
=
$chat
->
getTitle
();
$chat_title
=
$chat
->
getTitle
();
...
@@ -253,6 +258,7 @@ class DB
...
@@ -253,6 +258,7 @@ class DB
$sth2
->
bindParam
(
':type'
,
$type
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':type'
,
$type
,
\PDO
::
PARAM_INT
);
$sth2
->
bindParam
(
':title'
,
$chat_title
,
\PDO
::
PARAM_STR
,
255
);
$sth2
->
bindParam
(
':title'
,
$chat_title
,
\PDO
::
PARAM_STR
,
255
);
$sth2
->
bindParam
(
':date'
,
$date
,
\PDO
::
PARAM_STR
);
$sth2
->
bindParam
(
':date'
,
$date
,
\PDO
::
PARAM_STR
);
$sth2
->
bindParam
(
':oldid'
,
$migrate_from_chat_id
,
\PDO
::
PARAM_INT
);
$status
=
$sth2
->
execute
();
$status
=
$sth2
->
execute
();
...
@@ -297,13 +303,17 @@ class DB
...
@@ -297,13 +303,17 @@ class DB
`forward_date`, `reply_to_message`, `text`, `audio`, `document`,
`forward_date`, `reply_to_message`, `text`, `audio`, `document`,
`photo`, `sticker`, `video`, `voice`, `caption`, `contact`,
`photo`, `sticker`, `video`, `voice`, `caption`, `contact`,
`location`, `new_chat_participant`, `left_chat_participant`,
`location`, `new_chat_participant`, `left_chat_participant`,
`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`,
`migrate_from_chat_id`, `migrate_to_chat_id`
)
)
VALUES (:update_id, :message_id, :user_id, :date, :chat_id, :forward_from,
VALUES (:update_id, :message_id, :user_id, :date, :chat_id, :forward_from,
:forward_date, :reply_to_message, :text, :audio, :document,
:forward_date, :reply_to_message, :text, :audio, :document,
:photo, :sticker, :video, :voice, :caption, :contact,
:photo, :sticker, :video, :voice, :caption, :contact,
:location, :new_chat_participant, :left_chat_participant,
:location, :new_chat_participant, :left_chat_participant,
: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,
:migrate_from_chat_id, :migrate_to_chat_id
)'
);
)'
);
$update_id
=
$update
->
getUpdateId
();
$update_id
=
$update
->
getUpdateId
();
...
@@ -322,6 +332,9 @@ class DB
...
@@ -322,6 +332,9 @@ class DB
$new_chat_title
=
$message
->
getNewChatTitle
();
$new_chat_title
=
$message
->
getNewChatTitle
();
$delete_chat_photo
=
$message
->
getDeleteChatPhoto
();
$delete_chat_photo
=
$message
->
getDeleteChatPhoto
();
$group_chat_created
=
$message
->
getGroupChatCreated
();
$group_chat_created
=
$message
->
getGroupChatCreated
();
$supergroup_chat_created
=
$message
->
getSupergroupChatCreated
();
$channel_chat_created
=
$message
->
getChannelChatCreated
();
$migrate_from_chat_id
=
$message
->
getMigrateFromChatId
();
$sth
->
bindParam
(
':update_id'
,
$update_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':update_id'
,
$update_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':message_id'
,
$message_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':message_id'
,
$message_id
,
\PDO
::
PARAM_INT
);
...
@@ -372,7 +385,10 @@ class DB
...
@@ -372,7 +385,10 @@ class DB
$sth
->
bindParam
(
':new_chat_photo'
,
$new_chat_photo
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':new_chat_photo'
,
$new_chat_photo
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':delete_chat_photo'
,
$delete_chat_photo
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':delete_chat_photo'
,
$delete_chat_photo
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':group_chat_created'
,
$group_chat_created
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':group_chat_created'
,
$group_chat_created
,
\PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':supergroup_chat_created'
,
$migrate_from_chat_id
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':channel_chat_created'
,
$supergroup_chat_created
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_from_chat_id'
,
$channel_chat_created
,
\PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':migrate_to_chat_id'
,
$migrate_from_chat_id
,
\PDO
::
PARAM_INT
);
$status
=
$sth
->
execute
();
$status
=
$sth
->
execute
();
}
catch
(
PDOException
$e
)
{
}
catch
(
PDOException
$e
)
{
...
@@ -391,7 +407,8 @@ class DB
...
@@ -391,7 +407,8 @@ class DB
* @return array selected rows
* @return array selected rows
*/
*/
public
static
function
selectChats
(
public
static
function
selectChats
(
$select_chats
=
true
,
$select_groups
=
true
,
$select_super_groups
=
true
,
$select_users
=
true
,
$select_users
=
true
,
$date_from
=
null
,
$date_from
=
null
,
$date_to
=
null
$date_to
=
null
...
@@ -400,7 +417,7 @@ class DB
...
@@ -400,7 +417,7 @@ class DB
return
false
;
return
false
;
}
}
if
(
!
$select_
chats
&
!
$select_user
s
)
{
if
(
!
$select_
groups
&
!
$select_users
&
!
$select_super_group
s
)
{
return
false
;
return
false
;
}
}
try
{
try
{
...
@@ -415,10 +432,17 @@ class DB
...
@@ -415,10 +432,17 @@ class DB
$chat_or_user
=
''
;
$chat_or_user
=
''
;
$where
=
[];
$where
=
[];
$tokens
=
[];
$tokens
=
[];
if
(
$select_chats
&
!
$select_users
)
{
$where
[]
=
TB_CHATS
.
'.`id` < 0'
;
if
(
!
$select_groups
||
!
$select_users
||
!
$select_super_groups
)
{
}
elseif
(
!
$select_chats
&
$select_users
)
{
if
(
$select_groups
)
{
$where
[]
=
TB_CHATS
.
'.`id` > 0'
;
$where
[]
=
TB_CHATS
.
'.`type` = "group"'
;
}
if
(
$select_super_groups
)
{
$where
[]
=
TB_CHATS
.
'.`type` = "supergroup"'
;
}
if
(
$select_users
)
{
$where
[]
=
TB_CHATS
.
'.`type` = "private"'
;
}
}
}
if
(
!
is_null
(
$date_from
))
{
if
(
!
is_null
(
$date_from
))
{
...
...
src/Entities/Message.php
View file @
a6f664f5
...
@@ -60,6 +60,16 @@ class Message extends Entity
...
@@ -60,6 +60,16 @@ class Message extends Entity
protected
$delete_chat_photo
;
protected
$delete_chat_photo
;
protected
$group_chat_created
;
protected
$group_chat_created
;
//TODO new items
protected
$supergroup_chat_created
;
protected
$channel_chat_created
;
protected
$migrate_to_chat_id
;
protected
$migrate_from_chat_id
;
private
$command
;
private
$command
;
...
@@ -177,7 +187,7 @@ class Message extends Entity
...
@@ -177,7 +187,7 @@ class Message extends Entity
}
}
$this
->
new_chat_title
=
isset
(
$data
[
'new_chat_title'
])
?
$data
[
'new_chat_title'
]
:
null
;
$this
->
new_chat_title
=
isset
(
$data
[
'new_chat_title'
])
?
$data
[
'new_chat_title'
]
:
null
;
if
(
$this
->
new_chat_title
)
{
if
(
!
is_null
(
$this
->
new_chat_title
)
)
{
$this
->
type
=
'new_chat_title'
;
$this
->
type
=
'new_chat_title'
;
}
}
...
@@ -201,6 +211,19 @@ class Message extends Entity
...
@@ -201,6 +211,19 @@ class Message extends Entity
$this
->
type
=
'group_chat_created'
;
$this
->
type
=
'group_chat_created'
;
}
}
$this
->
supergroup_chat_created
=
isset
(
$data
[
'supergroup_chat_created'
])
?
$data
[
'supergroup_chat_created'
]
:
null
;
if
(
$this
->
supergroup_chat_created
)
{
$this
->
type
=
'supergroup_chat_created'
;
}
$this
->
channel_chat_created
=
isset
(
$data
[
'channel_chat_created'
])
?
$data
[
'channel_chat_created'
]
:
null
;
if
(
$this
->
channel_chat_created
)
{
$this
->
type
=
'channel_chat_created'
;
}
$this
->
migrate_to_chat_id
=
isset
(
$data
[
'migrate_to_chat_id'
])
?
$data
[
'migrate_to_chat_id'
]
:
null
;
$this
->
migrate_from_chat_id
=
isset
(
$data
[
'migrate_from_chat_id'
])
?
$data
[
'migrate_from_chat_id'
]
:
null
;
}
}
//return the entire command like /echo or /echo@bot1 if specified
//return the entire command like /echo or /echo@bot1 if specified
...
@@ -373,6 +396,25 @@ class Message extends Entity
...
@@ -373,6 +396,25 @@ class Message extends Entity
return
$this
->
group_chat_created
;
return
$this
->
group_chat_created
;
}
}
public
function
getSupergroupChatCreated
()
{
return
$this
->
supergroup_chat_created
;
}
public
function
getChannelChatCreated
()
{
return
$this
->
channel_chat_created
;
}
public
function
getMigrateToChatId
()
{
return
$this
->
migrate_to_chat_id
;
}
public
function
getMigrateFromChatId
()
{
return
$this
->
migrate_from_chat_id
;
}
public
function
botAddedInChat
()
public
function
botAddedInChat
()
{
{
...
...
src/Request.php
View file @
a6f664f5
...
@@ -424,7 +424,8 @@ class Request
...
@@ -424,7 +424,8 @@ class Request
public
static
function
sendToActiveChats
(
public
static
function
sendToActiveChats
(
$callback_function
,
$callback_function
,
array
$data
,
array
$data
,
$send_chats
=
true
,
$send_groups
=
true
,
$send_super_groups
=
true
,
$send_users
=
true
,
$send_users
=
true
,
$date_from
=
null
,
$date_from
=
null
,
$date_to
=
null
$date_to
=
null
...
@@ -435,7 +436,7 @@ class Request
...
@@ -435,7 +436,7 @@ class Request
throw
new
TelegramException
(
'Methods: '
.
$callback_function
.
' not found in class Request.'
);
throw
new
TelegramException
(
'Methods: '
.
$callback_function
.
' not found in class Request.'
);
}
}
$chats
=
DB
::
selectChats
(
$send_
chat
s
,
$send_users
,
$date_from
,
$date_to
);
$chats
=
DB
::
selectChats
(
$send_
groups
,
$send_super_group
s
,
$send_users
,
$date_from
,
$date_to
);
$results
=
[];
$results
=
[];
foreach
(
$chats
as
$row
)
{
foreach
(
$chats
as
$row
)
{
...
...
src/Telegram.php
View file @
a6f664f5
...
@@ -29,7 +29,7 @@ class Telegram
...
@@ -29,7 +29,7 @@ class Telegram
*
*
* @var string
* @var string
*/
*/
protected
$version
=
'0.2
4
.0'
;
protected
$version
=
'0.2
5
.0'
;
/**
/**
* Telegram API key
* Telegram API key
...
@@ -57,7 +57,7 @@ class Telegram
...
@@ -57,7 +57,7 @@ class Telegram
*
*
* @var array
* @var array
*/
*/
protected
$commands_dir
=
array
()
;
protected
$commands_dir
=
[]
;
/**
/**
* Update object
* Update object
...
@@ -449,6 +449,14 @@ class Telegram
...
@@ -449,6 +449,14 @@ class Telegram
// trigger group_chat_created
// trigger group_chat_created
return
$this
->
executeCommand
(
'Groupchatcreated'
,
$update
);
return
$this
->
executeCommand
(
'Groupchatcreated'
,
$update
);
break
;
break
;
case
'supergroup_chat_created'
:
// trigger super_group_chat_created
return
$this
->
executeCommand
(
'Supergroupchatcreated'
,
$update
);
break
;
case
'channel_chat_created'
:
// trigger channel_chat_created
return
$this
->
executeCommand
(
'Channelchatcreated'
,
$update
);
break
;
}
}
}
}
...
...
structure.sql
View file @
a6f664f5
...
@@ -23,6 +23,10 @@ CREATE TABLE `messages` (
...
@@ -23,6 +23,10 @@ CREATE TABLE `messages` (
`new_chat_photo`
TEXT
DEFAULT
''
COMMENT
'Array of PhotoSize objects. A group photo was change to this value'
,
`new_chat_photo`
TEXT
DEFAULT
''
COMMENT
'Array of PhotoSize objects. A group photo was change to this value'
,
`delete_chat_photo`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the group photo was deleted'
,
`delete_chat_photo`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the group photo was deleted'
,
`group_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the group has been created'
,
`group_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the group has been created'
,
`supergroup_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the supergroup has been created'
,
`channel_chat_created`
tinyint
(
1
)
DEFAULT
0
COMMENT
'Informs that the channel chat has been created'
,
`migrate_from_chat_id`
bigint
NOT
NULL
DEFAULT
'0'
COMMENT
'Migrate from chat identifier.'
,
`migrate_to_chat_id`
bigint
NOT
NULL
DEFAULT
'0'
COMMENT
'Migrate to chat identifier.'
,
PRIMARY
KEY
(
`update_id`
),
PRIMARY
KEY
(
`update_id`
),
KEY
`message_id`
(
`message_id`
),
KEY
`message_id`
(
`message_id`
),
KEY
`user_id`
(
`user_id`
)
KEY
`user_id`
(
`user_id`
)
...
@@ -41,10 +45,11 @@ CREATE TABLE `users` (
...
@@ -41,10 +45,11 @@ CREATE TABLE `users` (
CREATE
TABLE
`chats`
(
CREATE
TABLE
`chats`
(
`id`
bigint
NOT
NULL
DEFAULT
'0'
COMMENT
'Unique user or chat identifier'
,
`id`
bigint
NOT
NULL
DEFAULT
'0'
COMMENT
'Unique user or chat identifier'
,
`type`
CHAR
(
10
)
DEFAULT
''
COMMENT
'chat type private group, supergroup or channel'
,
`type`
CHAR
(
10
)
DEFAULT
''
COMMENT
'chat type private
,
group, supergroup or channel'
,
`title`
CHAR
(
255
)
DEFAULT
''
COMMENT
'chat title null if case of single chat with the bot'
,
`title`
CHAR
(
255
)
DEFAULT
''
COMMENT
'chat title null if case of single chat with the bot'
,
`created_at`
timestamp
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
COMMENT
'Entry date creation'
,
`created_at`
timestamp
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
COMMENT
'Entry date creation'
,
`updated_at`
timestamp
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
COMMENT
'Entry date update'
,
`updated_at`
timestamp
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
COMMENT
'Entry date update'
,
`old_id`
bigint
NOT
NULL
DEFAULT
'0'
COMMENT
'Unique chat identifieri this is filled when a chat is converted to a superchat'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
=
utf8_general_ci
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
=
utf8_general_ci
;
...
...
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