mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Send start in bots auto in existing bot chats.
This commit is contained in:
parent
10f1ae152d
commit
3957fea5e4
4 changed files with 32 additions and 5 deletions
|
@ -86,6 +86,7 @@ constexpr auto SpecialMsgIdShift = EndStoryMsgId.bare;
|
||||||
constexpr auto ShowAtTheEndMsgId = MsgId(SpecialMsgIdShift + 1);
|
constexpr auto ShowAtTheEndMsgId = MsgId(SpecialMsgIdShift + 1);
|
||||||
constexpr auto SwitchAtTopMsgId = MsgId(SpecialMsgIdShift + 2);
|
constexpr auto SwitchAtTopMsgId = MsgId(SpecialMsgIdShift + 2);
|
||||||
constexpr auto ShowAndStartBotMsgId = MsgId(SpecialMsgIdShift + 4);
|
constexpr auto ShowAndStartBotMsgId = MsgId(SpecialMsgIdShift + 4);
|
||||||
|
constexpr auto ShowAndMaybeStartBotMsgId = MsgId(SpecialMsgIdShift + 5);
|
||||||
constexpr auto ShowForChooseMessagesMsgId = MsgId(SpecialMsgIdShift + 6);
|
constexpr auto ShowForChooseMessagesMsgId = MsgId(SpecialMsgIdShift + 6);
|
||||||
|
|
||||||
static_assert(SpecialMsgIdShift + 0xFF < 0);
|
static_assert(SpecialMsgIdShift + 0xFF < 0);
|
||||||
|
|
|
@ -2181,7 +2181,8 @@ void HistoryWidget::showHistory(
|
||||||
|
|
||||||
const auto wasState = controller()->currentDialogsEntryState();
|
const auto wasState = controller()->currentDialogsEntryState();
|
||||||
const auto startBot = (showAtMsgId == ShowAndStartBotMsgId);
|
const auto startBot = (showAtMsgId == ShowAndStartBotMsgId);
|
||||||
if (startBot) {
|
_showAndMaybeSendStart = (showAtMsgId == ShowAndMaybeStartBotMsgId);
|
||||||
|
if (startBot || _showAndMaybeSendStart) {
|
||||||
showAtMsgId = ShowAtTheEndMsgId;
|
showAtMsgId = ShowAtTheEndMsgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2283,8 +2284,8 @@ void HistoryWidget::showHistory(
|
||||||
|
|
||||||
if (const auto user = _peer->asUser()) {
|
if (const auto user = _peer->asUser()) {
|
||||||
if (const auto &info = user->botInfo) {
|
if (const auto &info = user->botInfo) {
|
||||||
if (startBot) {
|
if (startBot || clearMaybeSendStart()) {
|
||||||
if (wasState.key) {
|
if (startBot && wasState.key) {
|
||||||
info->inlineReturnTo = wasState;
|
info->inlineReturnTo = wasState;
|
||||||
}
|
}
|
||||||
sendBotStartCommand();
|
sendBotStartCommand();
|
||||||
|
@ -2519,8 +2520,9 @@ void HistoryWidget::showHistory(
|
||||||
|
|
||||||
if (const auto user = _peer->asUser()) {
|
if (const auto user = _peer->asUser()) {
|
||||||
if (const auto &info = user->botInfo) {
|
if (const auto &info = user->botInfo) {
|
||||||
if (startBot) {
|
if (startBot
|
||||||
if (wasState.key) {
|
|| (!_history->isEmpty() && clearMaybeSendStart())) {
|
||||||
|
if (startBot && wasState.key) {
|
||||||
info->inlineReturnTo = wasState;
|
info->inlineReturnTo = wasState;
|
||||||
}
|
}
|
||||||
sendBotStartCommand();
|
sendBotStartCommand();
|
||||||
|
@ -3582,6 +3584,21 @@ void HistoryWidget::historyLoaded() {
|
||||||
doneShow();
|
doneShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryWidget::clearMaybeSendStart() {
|
||||||
|
if (!_showAndMaybeSendStart) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_showAndMaybeSendStart = false;
|
||||||
|
if (const auto user = _history ? _history->peer->asUser() : nullptr) {
|
||||||
|
if (const auto info = user->botInfo.get()) {
|
||||||
|
if (!info->startToken.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::windowShown() {
|
void HistoryWidget::windowShown() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
@ -3944,6 +3961,11 @@ void HistoryWidget::preloadHistoryIfNeeded() {
|
||||||
preloadHistoryByScroll();
|
preloadHistoryByScroll();
|
||||||
checkReplyReturns();
|
checkReplyReturns();
|
||||||
}
|
}
|
||||||
|
if (_history && _history->loadedAtTop() && _history->loadedAtBottom()) {
|
||||||
|
if (clearMaybeSendStart() && !_history->isDisplayedEmpty()) {
|
||||||
|
sendBotStartCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::preloadHistoryByScroll() {
|
void HistoryWidget::preloadHistoryByScroll() {
|
||||||
|
|
|
@ -391,6 +391,7 @@ private:
|
||||||
void fileChosen(ChatHelpers::FileChosen &&data);
|
void fileChosen(ChatHelpers::FileChosen &&data);
|
||||||
|
|
||||||
void updateFieldSubmitSettings();
|
void updateFieldSubmitSettings();
|
||||||
|
bool clearMaybeSendStart();
|
||||||
|
|
||||||
// Checks if we are too close to the top or to the bottom
|
// Checks if we are too close to the top or to the bottom
|
||||||
// in the scroll area and preloads history if needed.
|
// in the scroll area and preloads history if needed.
|
||||||
|
@ -726,6 +727,7 @@ private:
|
||||||
base::flat_set<MsgId> _topicsRequested;
|
base::flat_set<MsgId> _topicsRequested;
|
||||||
TextWithEntities _showAtMsgHighlightPart;
|
TextWithEntities _showAtMsgHighlightPart;
|
||||||
int _showAtMsgHighlightPartOffsetHint = 0;
|
int _showAtMsgHighlightPartOffsetHint = 0;
|
||||||
|
bool _showAndMaybeSendStart = false;
|
||||||
|
|
||||||
int _firstLoadRequest = 0; // Not real mtpRequestId.
|
int _firstLoadRequest = 0; // Not real mtpRequestId.
|
||||||
int _preloadRequest = 0; // Not real mtpRequestId.
|
int _preloadRequest = 0; // Not real mtpRequestId.
|
||||||
|
|
|
@ -690,6 +690,8 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
? info.messageId
|
? info.messageId
|
||||||
: info.startAutoSubmit
|
: info.startAutoSubmit
|
||||||
? ShowAndStartBotMsgId
|
? ShowAndStartBotMsgId
|
||||||
|
: (bot && !info.startToken.isEmpty())
|
||||||
|
? ShowAndMaybeStartBotMsgId
|
||||||
: ShowAtUnreadMsgId;
|
: ShowAtUnreadMsgId;
|
||||||
const auto attachBotUsername = info.attachBotUsername;
|
const auto attachBotUsername = info.attachBotUsername;
|
||||||
if (bot && bot->botInfo->startToken != info.startToken) {
|
if (bot && bot->botInfo->startToken != info.startToken) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue