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
8d3d8f13
Commit
8d3d8f13
authored
Jan 01, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moving tryMention in entities
parent
cc66da85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
25 deletions
+28
-25
ChatsCommand.php
src/Admin/ChatsCommand.php
+1
-1
Command.php
src/Command.php
+0
-22
NewchatparticipantCommand.php
src/Commands/NewchatparticipantCommand.php
+2
-2
Chat.php
src/Entities/Chat.php
+14
-0
User.php
src/Entities/User.php
+11
-0
No files found.
src/Admin/ChatsCommand.php
View file @
8d3d8f13
...
...
@@ -68,7 +68,7 @@ class ChatsCommand extends Command
$chat
=
new
Chat
(
$result
);
if
(
$chat
->
isPrivateChat
())
{
$text
.=
'- P '
.
$
this
->
tryMentionChat
(
$chat
)
.
"
\n
"
;
$text
.=
'- P '
.
$
chat
->
tryMentionChat
(
)
.
"
\n
"
;
++
$user_chats
;
}
elseif
(
$chat
->
isGroupChat
())
{
$text
.=
'- G '
.
$chat
->
getTitle
()
.
"
\n
"
;
...
...
src/Command.php
View file @
8d3d8f13
...
...
@@ -125,26 +125,4 @@ abstract class Command
{
return
$this
->
public
;
}
public
function
tryMention
(
User
$user
)
{
if
(
!
is_null
(
$user
->
getUsername
()))
{
return
'@'
.
$user
->
getUsername
();
}
else
{
return
$user
->
getFirstName
();
}
}
public
function
tryMentionChat
(
Chat
$chat
)
{
if
(
$chat
->
isGroupChat
())
{
return
$chat
->
getTitle
();
}
else
{
if
(
!
is_null
(
$chat
->
getUsername
()))
{
return
'@'
.
$chat
->
getUsername
();
}
else
{
return
$chat
->
getFirstName
();
}
}
}
}
src/Commands/NewchatparticipantCommand.php
View file @
8d3d8f13
...
...
@@ -30,13 +30,13 @@ class NewchatparticipantCommand extends Command
$participant
=
$message
->
getNewChatParticipant
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
if
(
strtolower
(
$participant
->
getUsername
())
==
strtolower
(
$this
->
getTelegram
()
->
getBotName
()))
{
$text
=
'Hi there!'
;
}
else
{
$text
=
'Hi '
.
$
this
->
tryMention
(
$participant
)
.
' !'
;
$text
=
'Hi '
.
$
participant
->
tryMention
(
)
.
' !'
;
}
$data
[
'text'
]
=
$text
;
...
...
src/Entities/Chat.php
View file @
8d3d8f13
...
...
@@ -121,4 +121,18 @@ class Chat extends Entity
return
$this
->
username
;
}
public
function
tryMention
()
{
if
(
$chat
->
isPrivateChat
())
{
if
(
is_null
(
$this
->
username
))
{
if
(
!
is_null
(
$this
->
last_name
))
{
return
$this
->
first_name
.
' '
.
$this
->
last_name
;
}
return
$this
->
first_name
;
}
return
'@'
.
$this
->
username
;
}
return
$chat
->
getTitle
();
}
}
src/Entities/User.php
View file @
8d3d8f13
...
...
@@ -59,4 +59,15 @@ class User extends Entity
{
return
$this
->
username
;
}
public
function
tryMention
()
{
if
(
is_null
(
$this
->
username
))
{
if
(
!
is_null
(
$this
->
last_name
))
{
return
$this
->
first_name
.
' '
.
$this
->
last_name
;
}
return
$this
->
first_name
;
}
return
'@'
.
$this
->
username
;
}
}
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