mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-02 18:21:53 +00:00
Initial stake dice game implementation.
This commit is contained in:
@@ -347,7 +347,7 @@ bool SendDice(MessageToSend &message) {
|
||||
|| !message.textWithTags.tags.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
auto &config = message.action.history->session().appConfig();
|
||||
//auto &config = message.action.history->session().appConfig();
|
||||
static const auto hardcoded = std::vector<QString>{
|
||||
Stickers::DicePacks::kDiceString,
|
||||
Stickers::DicePacks::kDartString,
|
||||
@@ -356,9 +356,9 @@ bool SendDice(MessageToSend &message) {
|
||||
Stickers::DicePacks::kFballString + QChar(0xFE0F),
|
||||
Stickers::DicePacks::kBballString,
|
||||
};
|
||||
const auto list = config.get<std::vector<QString>>(
|
||||
const auto list = hardcoded/*config.get<std::vector<QString>>(
|
||||
"emojies_send_dice",
|
||||
hardcoded);
|
||||
hardcoded)*/; AssertIsDebug();
|
||||
const auto emoji = full.toString();
|
||||
if (!ranges::contains(list, emoji)) {
|
||||
return false;
|
||||
@@ -372,7 +372,6 @@ bool SendDice(MessageToSend &message) {
|
||||
message.action.clearDraft = false;
|
||||
message.action.generateLocal = true;
|
||||
|
||||
|
||||
auto &action = message.action;
|
||||
api->sendAction(action);
|
||||
|
||||
@@ -428,6 +427,11 @@ bool SendDice(MessageToSend &message) {
|
||||
|
||||
session->data().registerMessageRandomId(randomId, newId);
|
||||
|
||||
auto seed = QByteArray(32, Qt::Uninitialized);
|
||||
base::RandomFill(bytes::make_detached_span(seed));
|
||||
const auto stake = action.options.stakeSeedHash.isEmpty()
|
||||
? 0
|
||||
: action.options.stakeNanoTon;
|
||||
history->addNewLocalMessage({
|
||||
.id = newId.msg,
|
||||
.flags = flags,
|
||||
@@ -440,10 +444,12 @@ bool SendDice(MessageToSend &message) {
|
||||
.effectId = action.options.effectId,
|
||||
.suggest = HistoryMessageSuggestInfo(action.options),
|
||||
}, TextWithEntities(), MTP_messageMediaDice(
|
||||
MTP_flags(0),
|
||||
MTP_flags(stake
|
||||
? MTPDmessageMediaDice::Flag::f_game_outcome
|
||||
: MTPDmessageMediaDice::Flag()),
|
||||
MTP_int(0),
|
||||
MTP_string(emoji),
|
||||
MTPmessages_EmojiGameOutcome()));
|
||||
MTP_messages_emojiGameOutcome(MTP_bytes(seed), MTP_long(0))));
|
||||
histories.sendPreparedMessage(
|
||||
history,
|
||||
action.replyTo,
|
||||
@@ -452,7 +458,12 @@ bool SendDice(MessageToSend &message) {
|
||||
MTP_flags(sendFlags),
|
||||
peer->input(),
|
||||
Data::Histories::ReplyToPlaceholder(),
|
||||
MTP_inputMediaDice(MTP_string(emoji)),
|
||||
(stake
|
||||
? MTP_inputMediaStakeDice(
|
||||
MTP_bytes(action.options.stakeSeedHash),
|
||||
MTP_long(stake),
|
||||
MTP_bytes(seed))
|
||||
: MTP_inputMediaDice(MTP_string(emoji))),
|
||||
MTP_string(),
|
||||
MTP_long(randomId),
|
||||
MTPReplyMarkup(),
|
||||
|
||||
Reference in New Issue
Block a user