Commit 68a8418b authored by MBoretto's avatar MBoretto

Added some message type

parent ce0bbdcd
......@@ -60,7 +60,6 @@ class Message extends Entity
protected $delete_chat_photo;
protected $group_chat_created;
//TODO new items
protected $supergroup_chat_created;
......@@ -91,7 +90,7 @@ class Message extends Entity
{
$this->bot_name = $bot_name;
$this->type = 'text';
$this->type = 'Message';
$this->message_id = isset($data['message_id']) ? $data['message_id'] : null;
if (empty($this->message_id)) {
......@@ -130,11 +129,13 @@ class Message extends Entity
$this->audio = isset($data['audio']) ? $data['audio'] : null;
if (!empty($this->audio)) {
$this->audio = new Audio($this->audio);
$this->type = 'Audio';
}
$this->document = isset($data['document']) ? $data['document'] : null;
if (!empty($this->document)) {
$this->document = new Document($this->document);
$this->type = 'Document';
}
$this->photo = isset($data['photo']) ? $data['photo'] : null; //array of photosize
......@@ -145,21 +146,25 @@ class Message extends Entity
}
}
$this->photo = $photos;
$this->type = 'Photo';
}
$this->sticker = isset($data['sticker']) ? $data['sticker'] : null;
if (!empty($this->sticker)) {
$this->sticker = new Sticker($this->sticker);
$this->type = 'Sticker';
}
$this->video = isset($data['video']) ? $data['video'] : null;
if (!empty($this->video)) {
$this->video = new Video($this->video);
$this->type = 'Video';
}
$this->voice = isset($data['voice']) ? $data['voice'] : null;
if (!empty($this->voice)) {
$this->voice = new Voice($this->voice);
$this->type = 'Voice';
}
$this->caption = isset($data['caption']) ? $data['caption'] : null;//string
......@@ -172,6 +177,7 @@ class Message extends Entity
$this->location = isset($data['location']) ? $data['location'] : null;
if (!empty($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;
......
......@@ -127,10 +127,12 @@ class Telegram
*
* @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
*
......@@ -179,6 +181,8 @@ class Telegram
public function enableMySQL(array $credential, $table_prefix = null)
{
$this->pdo = DB::initialize($credential, $table_prefix);
TrackingDB::initializeTracking();
$this->mysql_enabled = true;
}
......@@ -190,7 +194,7 @@ class Telegram
public function getCommandsList()
{
$commands = array();
$commands = [];
try {
$files = new \DirectoryIterator(BASE_PATH . '/Commands');
} catch (\Exception $e) {
......@@ -421,7 +425,14 @@ class Telegram
switch ($type) {
default:
case 'text':
case 'Message':
case 'Photo':
case 'Audio':
case 'Document':
case 'Sticker':
case 'Video':
case 'Voice':
case 'Location':
return $this->executeCommand('Genericmessage', $update);
break;
case 'command':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment