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
68a8418b
Commit
68a8418b
authored
Jan 01, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some message type
parent
ce0bbdcd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
Message.php
src/Entities/Message.php
+8
-2
Telegram.php
src/Telegram.php
+16
-5
No files found.
src/Entities/Message.php
View file @
68a8418b
...
@@ -60,7 +60,6 @@ class Message extends Entity
...
@@ -60,7 +60,6 @@ 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
$supergroup_chat_created
;
...
@@ -91,7 +90,7 @@ class Message extends Entity
...
@@ -91,7 +90,7 @@ class Message extends Entity
{
{
$this
->
bot_name
=
$bot_name
;
$this
->
bot_name
=
$bot_name
;
$this
->
type
=
'
text
'
;
$this
->
type
=
'
Message
'
;
$this
->
message_id
=
isset
(
$data
[
'message_id'
])
?
$data
[
'message_id'
]
:
null
;
$this
->
message_id
=
isset
(
$data
[
'message_id'
])
?
$data
[
'message_id'
]
:
null
;
if
(
empty
(
$this
->
message_id
))
{
if
(
empty
(
$this
->
message_id
))
{
...
@@ -130,11 +129,13 @@ class Message extends Entity
...
@@ -130,11 +129,13 @@ class Message extends Entity
$this
->
audio
=
isset
(
$data
[
'audio'
])
?
$data
[
'audio'
]
:
null
;
$this
->
audio
=
isset
(
$data
[
'audio'
])
?
$data
[
'audio'
]
:
null
;
if
(
!
empty
(
$this
->
audio
))
{
if
(
!
empty
(
$this
->
audio
))
{
$this
->
audio
=
new
Audio
(
$this
->
audio
);
$this
->
audio
=
new
Audio
(
$this
->
audio
);
$this
->
type
=
'Audio'
;
}
}
$this
->
document
=
isset
(
$data
[
'document'
])
?
$data
[
'document'
]
:
null
;
$this
->
document
=
isset
(
$data
[
'document'
])
?
$data
[
'document'
]
:
null
;
if
(
!
empty
(
$this
->
document
))
{
if
(
!
empty
(
$this
->
document
))
{
$this
->
document
=
new
Document
(
$this
->
document
);
$this
->
document
=
new
Document
(
$this
->
document
);
$this
->
type
=
'Document'
;
}
}
$this
->
photo
=
isset
(
$data
[
'photo'
])
?
$data
[
'photo'
]
:
null
;
//array of photosize
$this
->
photo
=
isset
(
$data
[
'photo'
])
?
$data
[
'photo'
]
:
null
;
//array of photosize
...
@@ -145,21 +146,25 @@ class Message extends Entity
...
@@ -145,21 +146,25 @@ class Message extends Entity
}
}
}
}
$this
->
photo
=
$photos
;
$this
->
photo
=
$photos
;
$this
->
type
=
'Photo'
;
}
}
$this
->
sticker
=
isset
(
$data
[
'sticker'
])
?
$data
[
'sticker'
]
:
null
;
$this
->
sticker
=
isset
(
$data
[
'sticker'
])
?
$data
[
'sticker'
]
:
null
;
if
(
!
empty
(
$this
->
sticker
))
{
if
(
!
empty
(
$this
->
sticker
))
{
$this
->
sticker
=
new
Sticker
(
$this
->
sticker
);
$this
->
sticker
=
new
Sticker
(
$this
->
sticker
);
$this
->
type
=
'Sticker'
;
}
}
$this
->
video
=
isset
(
$data
[
'video'
])
?
$data
[
'video'
]
:
null
;
$this
->
video
=
isset
(
$data
[
'video'
])
?
$data
[
'video'
]
:
null
;
if
(
!
empty
(
$this
->
video
))
{
if
(
!
empty
(
$this
->
video
))
{
$this
->
video
=
new
Video
(
$this
->
video
);
$this
->
video
=
new
Video
(
$this
->
video
);
$this
->
type
=
'Video'
;
}
}
$this
->
voice
=
isset
(
$data
[
'voice'
])
?
$data
[
'voice'
]
:
null
;
$this
->
voice
=
isset
(
$data
[
'voice'
])
?
$data
[
'voice'
]
:
null
;
if
(
!
empty
(
$this
->
voice
))
{
if
(
!
empty
(
$this
->
voice
))
{
$this
->
voice
=
new
Voice
(
$this
->
voice
);
$this
->
voice
=
new
Voice
(
$this
->
voice
);
$this
->
type
=
'Voice'
;
}
}
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
//string
$this
->
caption
=
isset
(
$data
[
'caption'
])
?
$data
[
'caption'
]
:
null
;
//string
...
@@ -172,6 +177,7 @@ class Message extends Entity
...
@@ -172,6 +177,7 @@ class Message extends Entity
$this
->
location
=
isset
(
$data
[
'location'
])
?
$data
[
'location'
]
:
null
;
$this
->
location
=
isset
(
$data
[
'location'
])
?
$data
[
'location'
]
:
null
;
if
(
!
empty
(
$this
->
location
))
{
if
(
!
empty
(
$this
->
location
))
{
$this
->
location
=
new
Location
(
$this
->
location
);
$this
->
location
=
new
Location
(
$this
->
location
);
$this
->
type
=
'Location'
;
}
}
$this
->
new_chat_participant
=
isset
(
$data
[
'new_chat_participant'
])
?
$data
[
'new_chat_participant'
]
:
null
;
$this
->
new_chat_participant
=
isset
(
$data
[
'new_chat_participant'
])
?
$data
[
'new_chat_participant'
]
:
null
;
...
...
src/Telegram.php
View file @
68a8418b
...
@@ -127,10 +127,12 @@ class Telegram
...
@@ -127,10 +127,12 @@ class Telegram
*
*
* @var array
* @var array
*/
*/
protected
$message_types
=
array
(
'text'
,
'command'
,
'new_chat_participant'
,
'left_chat_participant'
,
'new_chat_title'
,
'delete_chat_photo'
,
'group_chat_created'
);
protected
$message_types
=
[
'Message'
,
'Photo'
,
'Audio'
,
'Document'
,
'Sticker'
,
'Video'
,
'Voice'
,
'Location'
,
'command'
,
'new_chat_participant'
,
'left_chat_participant'
,
'new_chat_title'
,
'delete_chat_photo'
,
'group_chat_created'
,
'supergroup_chat_created'
,
'channel_chat_created'
,
];
/**
/**
* Admins List
* Admins List
*
*
...
@@ -179,6 +181,8 @@ class Telegram
...
@@ -179,6 +181,8 @@ class Telegram
public
function
enableMySQL
(
array
$credential
,
$table_prefix
=
null
)
public
function
enableMySQL
(
array
$credential
,
$table_prefix
=
null
)
{
{
$this
->
pdo
=
DB
::
initialize
(
$credential
,
$table_prefix
);
$this
->
pdo
=
DB
::
initialize
(
$credential
,
$table_prefix
);
TrackingDB
::
initializeTracking
();
$this
->
mysql_enabled
=
true
;
$this
->
mysql_enabled
=
true
;
}
}
...
@@ -190,7 +194,7 @@ class Telegram
...
@@ -190,7 +194,7 @@ class Telegram
public
function
getCommandsList
()
public
function
getCommandsList
()
{
{
$commands
=
array
()
;
$commands
=
[]
;
try
{
try
{
$files
=
new
\DirectoryIterator
(
BASE_PATH
.
'/Commands'
);
$files
=
new
\DirectoryIterator
(
BASE_PATH
.
'/Commands'
);
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
...
@@ -421,7 +425,14 @@ class Telegram
...
@@ -421,7 +425,14 @@ class Telegram
switch
(
$type
)
{
switch
(
$type
)
{
default
:
default
:
case
'text'
:
case
'Message'
:
case
'Photo'
:
case
'Audio'
:
case
'Document'
:
case
'Sticker'
:
case
'Video'
:
case
'Voice'
:
case
'Location'
:
return
$this
->
executeCommand
(
'Genericmessage'
,
$update
);
return
$this
->
executeCommand
(
'Genericmessage'
,
$update
);
break
;
break
;
case
'command'
:
case
'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