Telegram supports sending animated dice emojis.
This is implemented by using the dice constructors:
inputMediaDice#e66fbf7b emoticon:string = InputMedia;
messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia;
inputStickerSetDice#e67f520e emoticon:string = InputStickerSet;
messages.stickerSet#6e153f16 set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = messages.StickerSet;
---functions---
messages.sendMedia#72ccc23d flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates;
messages.getStickerSet#c8a0ec74 stickerset:InputStickerSet hash:int = messages.StickerSet;
help.getAppConfig#61e3f854 hash:int = help.AppConfig;
On startup, clients should fetch app configuration using help.getAppConfig.
Then, for each dice emoji contained in the emojies_send_dice
field, clients should fetch the dice emoji stickerset by calling the messages.getStickerSet method, providing the properly populated inputStickerSetDice to the stickerset
field.
The returned stickerset will contain a set of animated stickers, one for each of the dice outcomes, plus a first looping sticker that should be shown as preview to the user before actually sending the dice.
If a user attempts to send a single emoji from the ones specified in emojies_send_dice
, the dice should be sent using messages.sendMedia, providing the dice emoji to the emoticon
field.
Incoming dice stickers will be received as a messageMediaDice constructor, along with a randomly generated server-side value, ranging from 1 to the maximum allowed value for this type of dice.
Clients should display the correct dice animated sticker for the specified value: since dice values start from 1, and the first animated sticker in dice stickerset is the preview, value
can be used to directly index the documents
sticker array from the animated stickerset.
The emojies_send_dice_success
configuration parameter contains more info about dice emojis other than the basic :
"emojies_send_dice_success": {
"\ud83c\udfaf": {
"value": 6,
"frame_start": 62
},
"\ud83c\udfc0": {
"value": 5,
"frame_start": 110
}
}
For each of the dice emojis, a maximum "winning" value is specified, along with the frame number at which to show the fireworks .
Please note that dice animated stickers should loop only once, right after being sent/received for the first time; clicking on the dice sticker should bring up a popup, inviting the user to send a new dice of the same type.
Slot machine dice stickers are implemented a bit differently: the value
isn't used to directly index the stickers array, but is instead used as follows.
The value
is composed of three 2-bit values, each indicating the animated sticker to show in the three slots, incremented by one.
The stickers
array is composed as follows:
How to play the animation (all involved stickers are to be directly overlaid on top of each other, no special placing is required):
0
)2
) once8
, 14
, 20
) oncevalue == 64
:3
9
15
map := [1, 2, 3, 0]
:4 + map[(value-1) & 3]
10 + map[((value-1) >> 2) & 3]
16 + map[((value-1) >> 4) & 3]
value=64
, replace the background (0
) with 1
.Example implementation: tdesktop.