Commit fa88ab2b authored by MBoretto's avatar MBoretto

new table schema works!

parent 820130b0
This diff is collapsed.
...@@ -37,12 +37,12 @@ class ChosenInlineResult extends Entity ...@@ -37,12 +37,12 @@ class ChosenInlineResult extends Entity
$this->offset = isset($data['offset']) ? $data['offset'] : null; $this->offset = isset($data['offset']) ? $data['offset'] : null;
} }
public function getId() public function getResultId()
{ {
return $this->id; return $this->result_id;
} }
public function geFrom() public function getFrom()
{ {
return $this->from; return $this->from;
} }
......
...@@ -21,7 +21,7 @@ class Update extends Entity ...@@ -21,7 +21,7 @@ class Update extends Entity
protected $chosen_inline_result; protected $chosen_inline_result;
private $update_type; private $update_type;
public function __construct(array $data, $bot_name, $let_update_id_empty = 0) public function __construct(array $data, $bot_name)
{ {
$this->bot_name = $bot_name; $this->bot_name = $bot_name;
...@@ -35,11 +35,10 @@ class Update extends Entity ...@@ -35,11 +35,10 @@ class Update extends Entity
$this->update_type = 'message'; $this->update_type = 'message';
} }
if (empty($update_id) && !$let_update_id_empty) { if (empty($update_id)) {
throw new TelegramException('update_id is empty!'); throw new TelegramException('update_id is empty!');
} }
$this->inline_query = isset($data['inline_query']) ? $data['inline_query'] : null; $this->inline_query = isset($data['inline_query']) ? $data['inline_query'] : null;
if (!empty($this->inline_query)) { if (!empty($this->inline_query)) {
$this->inline_query = new InlineQuery($this->inline_query); $this->inline_query = new InlineQuery($this->inline_query);
......
...@@ -29,7 +29,7 @@ class Telegram ...@@ -29,7 +29,7 @@ class Telegram
* *
* @var string * @var string
*/ */
protected $version = '0.25.0'; protected $version = '0.26.0';
/** /**
* Telegram API key * Telegram API key
...@@ -343,11 +343,11 @@ class Telegram ...@@ -343,11 +343,11 @@ class Telegram
public function handleGetUpdates($limit = null, $timeout = null) public function handleGetUpdates($limit = null, $timeout = null)
{ {
//DB Query //DB Query
$last_message = DB::selectMessages(1); $last_update = DB::selectTelegramUpdate(1);
if (isset($last_message[0]['update_id'])) { if (isset($last_update[0]['id'])) {
//As explained in the telegram bot api documentation //As explained in the telegram bot api documentation
$offset = $last_message[0]['update_id']+1; $offset = $last_update[0]['id']+1;
} else { } else {
$offset = null; $offset = null;
} }
...@@ -418,8 +418,6 @@ class Telegram ...@@ -418,8 +418,6 @@ class Telegram
} }
} }
DB::insertRequest($update);
// check type // check type
$message = $update->getMessage(); $message = $update->getMessage();
$type = $message->getType(); $type = $message->getType();
...@@ -475,6 +473,7 @@ class Telegram ...@@ -475,6 +473,7 @@ class Telegram
$command = 'Choseninlineresult'; $command = 'Choseninlineresult';
} }
DB::insertRequest($update);
$result = $this->executeCommand($command, $update); $result = $this->executeCommand($command, $update);
return $result; return $result;
} }
......
This diff is collapsed.
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