Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
a5189471
Commit
a5189471
authored
Dec 29, 2016
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small changes!
parent
68acdec2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
Botan.php
src/Botan.php
+3
-7
BotanDB.php
src/BotanDB.php
+7
-7
No files found.
src/Botan.php
View file @
a5189471
...
...
@@ -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
(
$u
ser_id
,
$url
))
{
if
(
$cached
=
BotanDB
::
selectShortUrl
(
$u
rl
,
$user_id
))
{
return
$cached
;
}
...
...
@@ -240,7 +236,7 @@ class Botan
$result
=
$e
->
getMessage
();
}
finally
{
if
(
filter_var
(
$result
,
FILTER_VALIDATE_URL
)
!==
false
)
{
BotanDB
::
insertShortUrl
(
$u
ser_id
,
$url
,
$result
);
BotanDB
::
insertShortUrl
(
$u
rl
,
$user_id
,
$result
);
return
$result
;
}
else
{
TelegramLog
::
debug
(
'Botan.io URL shortening failed for \''
.
$url
.
'\': '
.
(
$result
?:
'empty response'
)
.
"
\n\n
"
);
...
...
src/BotanDB.php
View file @
a5189471
...
...
@@ -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
(
$u
ser_id
,
$url
)
public
static
function
selectShortUrl
(
$u
rl
,
$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
(
$u
ser_id
,
$url
,
$short_url
)
public
static
function
insertShortUrl
(
$u
rl
,
$user_id
,
$short_url
)
{
if
(
!
self
::
isDbConnected
())
{
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment