Commit a5189471 authored by Jack'lul's avatar Jack'lul

Small changes!

parent 68acdec2
...@@ -166,11 +166,7 @@ class Botan ...@@ -166,11 +166,7 @@ class Botan
} }
// In case there is no from field assign id = 0 // In case there is no from field assign id = 0
if (isset($data['from']['id'])) { $uid = (isset($data['from']['id'])) ? $data['from']['id'] : 0;
$uid = $data['from']['id'];
} else {
$uid = 0;
}
try { try {
$response = self::$client->post( $response = self::$client->post(
...@@ -222,7 +218,7 @@ class Botan ...@@ -222,7 +218,7 @@ class Botan
throw new TelegramException('User id is empty!'); throw new TelegramException('User id is empty!');
} }
if ($cached = BotanDB::selectShortUrl($user_id, $url)) { if ($cached = BotanDB::selectShortUrl($url, $user_id)) {
return $cached; return $cached;
} }
...@@ -240,7 +236,7 @@ class Botan ...@@ -240,7 +236,7 @@ class Botan
$result = $e->getMessage(); $result = $e->getMessage();
} finally { } finally {
if (filter_var($result, FILTER_VALIDATE_URL) !== false) { if (filter_var($result, FILTER_VALIDATE_URL) !== false) {
BotanDB::insertShortUrl($user_id, $url, $result); BotanDB::insertShortUrl($url, $user_id, $result);
return $result; return $result;
} else { } else {
TelegramLog::debug('Botan.io URL shortening failed for \'' . $url . '\': ' . ($result ?: 'empty response') . "\n\n"); TelegramLog::debug('Botan.io URL shortening failed for \'' . $url . '\': ' . ($result ?: 'empty response') . "\n\n");
......
...@@ -32,13 +32,13 @@ class BotanDB extends DB ...@@ -32,13 +32,13 @@ class BotanDB extends DB
/** /**
* Select cached shortened URL from the database * Select cached shortened URL from the database
* *
* @param $user_id * @param string $url
* @param $url * @param integer $user_id
* *
* @return array|bool * @return array|bool
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function selectShortUrl($user_id, $url) public static function selectShortUrl($url, $user_id)
{ {
if (!self::isDbConnected()) { if (!self::isDbConnected()) {
return false; return false;
...@@ -65,14 +65,14 @@ class BotanDB extends DB ...@@ -65,14 +65,14 @@ class BotanDB extends DB
/** /**
* Insert shortened URL into the database * Insert shortened URL into the database
* *
* @param $user_id * @param string $url
* @param $url * @param integer $user_id
* @param $short_url * @param string $short_url
* *
* @return bool * @return bool
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function insertShortUrl($user_id, $url, $short_url) public static function insertShortUrl($url, $user_id, $short_url)
{ {
if (!self::isDbConnected()) { if (!self::isDbConnected()) {
return false; return false;
......
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