Commit 03e1ac14 authored by MBoretto's avatar MBoretto

merge conflicts resolved

parents 6a131d3c 18f9215b
<?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\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Migrate from chat id command
*/
class MigratefromchatidCommand extends SystemCommand
{
/**#@+
* {@inheritdoc}
*/
protected $name = 'Migratefromchatid';
protected $description = 'Migrate from chat id';
protected $version = '1.0.1';
/**#@-*/
/**
* {@inheritdoc}
*/
/*public function execute()
{
//$message = $this->getMessage();
//$migrate_from_chat_id = $message->getMigrateFromChatId();
}*/
}
<?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\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Migrate to chat id command
*/
class MigratetochatidCommand extends SystemCommand
{
/**#@+
* {@inheritdoc}
*/
protected $name = 'Migratetochatid';
protected $description = 'Migrate to chat id';
protected $version = '1.0.1';
/**#@-*/
/**
* {@inheritdoc}
*/
/*public function execute()
{
//$message = $this->getMessage();
//$migrate_to_chat_id = $message->getMigrateToChatId();
}*/
}
......@@ -11,7 +11,6 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Super group chat created command
......@@ -29,23 +28,9 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$text = '';
if ($message->getSuperGroupChatCreated()) {
$text = 'Your group has become a Supergroup!' . "\n";
$text .= 'Chat id has changed from ' . $message->getMigrateFromChatId() . ' to ' . $message->getMigrateToChatId();
}
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
}
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
}*/
}
......@@ -506,6 +506,7 @@ class DB
$left_chat_participant = $message->getLeftChatParticipant();
$migrate_from_chat_id = $message->getMigrateFromChatId();
$migrate_to_chat_id = $message->getMigrateToChatId();
try {
//chat table
......@@ -522,11 +523,22 @@ class DB
$chat_title = $chat->getTitle();
$type = $chat->getType();
$sth2->bindParam(':id', $chat_id, \PDO::PARAM_INT);
$sth2->bindParam(':type', $type, \PDO::PARAM_STR);
if ($migrate_to_chat_id) {
$type = 'supergroup';
$sth2->bindParam(':id', $migrate_to_chat_id, \PDO::PARAM_INT);
$sth2->bindParam(':oldid', $chat_id, \PDO::PARAM_INT);
} else {
$sth2->bindParam(':id', $chat_id, \PDO::PARAM_INT);
$sth2->bindParam(':oldid', $migrate_to_chat_id, \PDO::PARAM_INT);
}
$sth2->bindParam(':type', $type, \PDO::PARAM_INT);
$sth2->bindParam(':title', $chat_title, \PDO::PARAM_STR, 255);
$sth2->bindParam(':date', $date, \PDO::PARAM_STR);
$sth2->bindParam(':oldid', $migrate_from_chat_id, \PDO::PARAM_INT);
$status = $sth2->execute();
......@@ -543,7 +555,7 @@ class DB
self::insertUser($forward_from, $forward_date);
$forward_from = $forward_from->getId();
}
if ($new_chat_participant) {
//Insert the new chat user
self::insertUser($new_chat_participant, $date, $chat);
......@@ -603,6 +615,7 @@ class DB
$supergroup_chat_created = $message->getSupergroupChatCreated();
$channel_chat_created = $message->getChannelChatCreated();
$migrate_from_chat_id = $message->getMigrateFromChatId();
$migrate_to_chat_id = $message->getMigrateToChatId();
$sth->bindParam(':message_id', $message_id, \PDO::PARAM_INT);
$sth->bindParam(':user_id', $from_id, \PDO::PARAM_INT);
......@@ -652,10 +665,10 @@ class DB
$sth->bindParam(':new_chat_photo', $new_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(':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);
$sth->bindParam(':supergroup_chat_created', $supergroup_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_to_chat_id', $migrate_to_chat_id, \PDO::PARAM_INT);
$status = $sth->execute();
} catch (PDOException $e) {
......
......@@ -229,7 +229,13 @@ class Message extends Entity
}
$this->migrate_to_chat_id = isset($data['migrate_to_chat_id']) ? $data['migrate_to_chat_id'] : null;
if ($this->migrate_to_chat_id) {
$this->type = 'migrate_to_chat_id';
}
$this->migrate_from_chat_id = isset($data['migrate_from_chat_id']) ? $data['migrate_from_chat_id'] : null;
if ($this->migrate_from_chat_id) {
$this->type = 'migrate_from_chat_id';
}
}
......
......@@ -468,6 +468,8 @@ class Telegram
'delete_chat_photo',
'group_chat_created',
'left_chat_participant',
'migrate_from_chat_id',
'migrate_to_chat_id',
'new_chat_participant',
'new_chat_photo',
'new_chat_title',
......
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