2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Update API scheme to layer 167.

Support quote offset passing to API.
Support simple phrases in giveaway results message.
This commit is contained in:
John Preston
2023-11-10 13:27:47 +04:00
parent f442d69cb6
commit dcc326e17f
44 changed files with 389 additions and 303 deletions

View File

@@ -1316,9 +1316,9 @@ ServiceAction ParseServiceAction(
}, [&](const MTPDmessageActionSetChatWallPaper &data) {
auto content = ActionSetChatWallPaper();
// #TODO wallpapers
content.same = data.is_same();
content.both = data.is_for_both();
result.content = content;
}, [&](const MTPDmessageActionSetSameChatWallPaper &data) {
result.content = ActionSetSameChatWallPaper();
}, [&](const MTPDmessageActionRequestedPeer &data) {
auto content = ActionRequestedPeer();
content.peerId = ParsePeerId(data.vpeer());
@@ -1334,9 +1334,14 @@ ServiceAction ParseServiceAction(
content.months = data.vmonths().v;
content.code = data.vslug().v;
result.content = content;
}, [&](const MTPDmessageActionGiveawayLaunch &) {
}, [&](const MTPDmessageActionGiveawayLaunch &data) {
auto content = ActionGiveawayLaunch();
result.content = content;
}, [&](const MTPDmessageActionGiveawayResults &data) {
auto content = ActionGiveawayResults();
content.winners = data.vwinners_count().v;
content.unclaimed = data.vunclaimed_count().v;
result.content = content;
}, [](const MTPDmessageActionEmpty &data) {});
return result;
}

View File

@@ -533,12 +533,11 @@ struct ActionSuggestProfilePhoto {
};
struct ActionSetChatWallPaper {
bool same = false;
bool both = false;
// #TODO wallpapers
};
struct ActionSetSameChatWallPaper {
};
struct ActionGiftCode {
QByteArray code;
PeerId boostPeerId = 0;
@@ -555,6 +554,11 @@ struct ActionRequestedPeer {
struct ActionGiveawayLaunch {
};
struct ActionGiveawayResults {
int winners = 0;
int unclaimed = 0;
};
struct ServiceAction {
std::variant<
v::null_t,
@@ -593,9 +597,9 @@ struct ServiceAction {
ActionSuggestProfilePhoto,
ActionRequestedPeer,
ActionSetChatWallPaper,
ActionSetSameChatWallPaper,
ActionGiftCode,
ActionGiveawayLaunch> content;
ActionGiveawayLaunch,
ActionGiveawayResults> content;
};
ServiceAction ParseServiceAction(

View File

@@ -1273,12 +1273,12 @@ auto HtmlWriter::Wrap::pushMessage(
}, [&](const ActionRequestedPeer &data) {
return "requested: "_q/* + data.peerId*/;
}, [&](const ActionSetChatWallPaper &data) {
return serviceFrom + " set a new background for this chat";
}, [&](const ActionSetSameChatWallPaper &data) {
return serviceFrom
+ " set "
+ wrapReplyToLink("the same background")
+ " for this chat";
+ (data.same
? (" set "
+ wrapReplyToLink("the same background")
+ " for this chat")
: " set a new background for this chat");
}, [&](const ActionGiftCode &data) {
return data.unclaimed
? ("This is an unclaimed Telegram Premium for "
@@ -1297,6 +1297,10 @@ auto HtmlWriter::Wrap::pushMessage(
}, [&](const ActionGiveawayLaunch &data) {
return serviceFrom + " just started a giveaway "
"of Telegram Premium subscriptions to its followers.";
}, [&](const ActionGiveawayResults &data) {
return QByteArray::number(data.winners)
+ " of the giveaway were randomly selected by Telegram "
"and received private messages with giftcodes.";
}, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) {

View File

@@ -604,12 +604,15 @@ QByteArray SerializeMessage(
push("via_giveaway", data.viaGiveaway);
}, [&](const ActionGiveawayLaunch &data) {
pushAction("giveaway_launch");
}, [&](const ActionGiveawayResults &data) {
pushAction("giveaway_results");
push("winners", data.winners);
push("unclaimed", data.unclaimed);
}, [&](const ActionSetChatWallPaper &data) {
pushActor();
pushAction("set_chat_wallpaper");
}, [&](const ActionSetSameChatWallPaper &data) {
pushActor();
pushAction("set_same_chat_wallpaper");
pushAction(data.same
? "set_same_chat_wallpaper"
: "set_chat_wallpaper");
pushReplyToMsgId("message_id");
}, [](v::null_t) {});