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

Small changes!

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