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
7bd31911
Commit
7bd31911
authored
Apr 15, 2016
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed DB::selectChats(), small text update in whoiscommand
parent
28bd0f91
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
12 deletions
+29
-12
WhoisCommand.php
src/Commands/AdminCommands/WhoisCommand.php
+1
-1
DB.php
src/DB.php
+28
-11
No files found.
src/Commands/AdminCommands/WhoisCommand.php
View file @
7bd31911
...
...
@@ -143,7 +143,7 @@ class WhoisCommand extends AdminCommand
$text
=
'Chat ID: '
.
$user_id
.
(
!
empty
(
$old_id
)
?
' (previously: '
.
$old_id
.
')'
:
''
)
.
"
\n
"
;
$text
.=
'Type: '
.
ucfirst
(
$chat
->
getType
())
.
"
\n
"
;
$text
.=
'Title: '
.
$chat
->
getTitle
()
.
"
\n
"
;
$text
.=
'
Bot
added to group: '
.
$created_at
.
"
\n
"
;
$text
.=
'
First time
added to group: '
.
$created_at
.
"
\n
"
;
$text
.=
'Last activity: '
.
$updated_at
.
"
\n
"
;
}
}
elseif
(
is_array
(
$results
)
&&
count
(
$results
)
>
1
)
{
...
...
src/DB.php
View file @
7bd31911
...
...
@@ -691,8 +691,6 @@ class DB
/**
* Select Group and single Chats
*
* @todo Seems to not return anything when $select_users = false
*
* @param bool $select_groups
* @param bool $select_super_groups
* @param bool $select_users
...
...
@@ -722,26 +720,39 @@ class DB
$query
=
'SELECT * ,
'
.
TB_CHAT
.
'.`id` AS `chat_id`,
'
.
TB_CHAT
.
'.`created_at` AS `chat_created_at`,
'
.
TB_CHAT
.
'.`updated_at` AS `chat_updated_at`
,
'
.
TB_USER
.
'.`id` AS `user_id`
FROM `'
.
TB_CHAT
.
'` LEFT JOIN `'
.
TB_USER
.
'`
ON '
.
TB_CHAT
.
'.`id`='
.
TB_USER
.
'.`id`'
;
'
.
TB_CHAT
.
'.`updated_at` AS `chat_updated_at`
'
.
((
$select_users
)
?
', '
.
TB_USER
.
'.`id` AS `user_id`
FROM `'
.
TB_CHAT
.
'` LEFT JOIN `'
.
TB_USER
.
'`
ON '
.
TB_CHAT
.
'.`id`='
.
TB_USER
.
'.`id`'
:
'FROM `'
.
TB_CHAT
.
'`'
)
;
//Building parts of query
$chat_or_user
=
''
;
$where
=
[];
$tokens
=
[];
if
(
!
$select_groups
||
!
$select_users
||
!
$select_super_groups
)
{
$chat_or_user
=
''
;
if
(
$select_groups
)
{
$
where
[]
=
TB_CHAT
.
'.`type` = "group"'
;
$
chat_or_user
.
=
TB_CHAT
.
'.`type` = "group"'
;
}
if
(
$select_super_groups
)
{
$where
[]
=
TB_CHAT
.
'.`type` = "supergroup"'
;
if
(
!
empty
(
$chat_or_user
))
{
$chat_or_user
.=
' OR '
;
}
$chat_or_user
.=
TB_CHAT
.
'.`type` = "supergroup"'
;
}
if
(
$select_users
)
{
$where
[]
=
TB_CHAT
.
'.`type` = "private"'
;
if
(
!
empty
(
$chat_or_user
))
{
$chat_or_user
.=
' OR '
;
}
$chat_or_user
.=
TB_CHAT
.
'.`type` = "private"'
;
}
$where
[]
=
'('
.
$chat_or_user
.
')'
;
}
if
(
!
is_null
(
$date_from
))
{
...
...
@@ -760,7 +771,12 @@ class DB
}
if
(
!
is_null
(
$text
))
{
if
(
$select_users
)
{
$where
[]
=
'(LOWER('
.
TB_CHAT
.
'.`title`) LIKE :text OR LOWER('
.
TB_USER
.
'.`first_name`) LIKE :text OR LOWER('
.
TB_USER
.
'.`last_name`) LIKE :text OR LOWER('
.
TB_USER
.
'.`username`) LIKE :text)'
;
}
else
{
$where
[]
=
'LOWER('
.
TB_CHAT
.
'.`title`) LIKE :text'
;
}
$tokens
[
':text'
]
=
'%'
.
strtolower
(
$text
)
.
'%'
;
}
...
...
@@ -788,3 +804,4 @@ class DB
return
$result
;
}
}
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