FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tdesktop/Telegram/SourceFiles/chat_helpers/bot_command.cpp at dev · dmitry/tdesktop · GitHub
dmitry
tdesktop
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
chat_helpers
/
bot_command.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (43 loc) · 1.27 KB
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
chat_helpers
/
bot_command.cpp
Copy path
File metadata and controls
49 lines (43 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#
include
"
chat_helpers/bot_command.h
"
#
include
"
data/data_channel.h
"
#
include
"
data/data_chat.h
"
#
include
"
data/data_peer.h
"
#
include
"
data/data_user.h
"
#
include
"
data/data_session.h
"
#
include
"
history/history_item.h
"
namespace
Bot
{
QString
WrapCommandInChat
(
not_null<PeerData*> peer,
const
QString &command,
const
FullMsgId &context) {
auto
result = command;
if
(
const
auto
item = peer->
owner
().
message
(context)) {
if
(
const
auto
user = item->
fromOriginal
()->
asUser
()) {
return
WrapCommandInChat
(peer, command, user);
}
}
return
result;
}
QString
WrapCommandInChat
(
not_null<PeerData*> peer,
const
QString &command,
not_null<UserData*> bot) {
if
(!bot->
isBot
() || bot->
username
().
isEmpty
()) {
return
command;
}
const
auto
botStatus = peer->
isChat
()
? peer->
asChat
()->
botStatus
: peer->
isMegagroup
()
? peer->
asChannel
()->
mgInfo
->
botStatus
: Data::BotStatus::NoBots;
return
((command.
indexOf
(
'
@
'
) <
2
) && (botStatus != Data::BotStatus::NoBots))
? command +
'
@
'
+ bot->
username
()
: command;
}
}
//
namespace Bot
Back
|
FazBrowse Home
|
New Git URL