telegram-crawler/data/web/blogfork.telegram.org/api/dice.html
2022-05-13 22:37:40 +00:00

152 lines
9.5 KiB
HTML

<!DOCTYPE html>
<html class="">
<head>
<meta charset="utf-8">
<title>Dice</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="Telegram supports sending [animated dice](https://telegram.org/blog/folders#and-one-more-thing) emojis.">
<meta property="og:title" content="Dice">
<meta property="og:image" content="">
<meta property="og:description" content="Telegram supports sending [animated dice](https://telegram.org/blog/folders#and-one-more-thing) emojis.">
<link rel="icon" type="image/svg+xml" href="/img/website_icon.svg?4">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">
<link rel="alternate icon" href="/img/favicon.ico" type="image/x-icon" />
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
<link href="/css/telegram.css?230" rel="stylesheet" media="screen">
<style>
</style>
</head>
<body class="preload">
<div class="dev_page_wrap">
<div class="dev_page_head navbar navbar-static-top navbar-tg">
<div class="navbar-inner">
<div class="container clearfix">
<ul class="nav navbar-nav navbar-right hidden-xs"><li class="navbar-twitter"><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)"><i class="icon icon-twitter"></i><span> Twitter</span></a></li></ul>
<ul class="nav navbar-nav">
<li><a href="//telegram.org/">Home</a></li>
<li class="hidden-xs"><a href="//telegram.org/faq">FAQ</a></li>
<li class="hidden-xs"><a href="//telegram.org/apps">Apps</a></li>
<li class="active"><a href="/api">API</a></li>
<li class=""><a href="/mtproto">Protocol</a></li>
<li class=""><a href="/schema">Schema</a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="dev_page">
<div id="dev_page_content_wrap" class=" ">
<div class="dev_page_bread_crumbs"><ul class="breadcrumb clearfix"><li><a href="/api" >API</a></li><i class="icon icon-breadcrumb-divider"></i><li><a href="/api/dice" >Dice</a></li></ul></div>
<h1 id="dev_page_title">Dice</h1>
<div id="dev_page_content"><p>Telegram supports sending <a href="https://telegram.org/blog/folders#and-one-more-thing">animated dice</a> emojis.<br>
This is implemented by using the dice constructors: </p>
<pre><code><a href='/constructor/inputMediaDice'>inputMediaDice</a>#e66fbf7b emoticon:<a href='/type/string'>string</a> = <a href='/type/InputMedia'>InputMedia</a>;
<a href='/constructor/messageMediaDice'>messageMediaDice</a>#3f7ee58b value:<a href='/type/int'>int</a> emoticon:<a href='/type/string'>string</a> = <a href='/type/MessageMedia'>MessageMedia</a>;
<a href='/constructor/inputStickerSetDice'>inputStickerSetDice</a>#e67f520e emoticon:<a href='/type/string'>string</a> = <a href='/type/InputStickerSet'>InputStickerSet</a>;
<a href='/constructor/messages.stickerSet'>messages.stickerSet</a>#b60a24a6 set:<a href='/type/StickerSet'>StickerSet</a> packs:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/StickerPack'>StickerPack</a>&gt; documents:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/Document'>Document</a>&gt; = <a href='/type/messages.StickerSet'>messages.StickerSet</a>;
---functions---
<a href='/method/messages.sendMedia'>messages.sendMedia</a>#e25ff8e0 flags:<a href='/type/%23'>#</a> silent:flags.5?<a href='/constructor/true'>true</a> background:flags.6?<a href='/constructor/true'>true</a> clear_draft:flags.7?<a href='/constructor/true'>true</a> noforwards:flags.14?<a href='/constructor/true'>true</a> peer:<a href='/type/InputPeer'>InputPeer</a> reply_to_msg_id:flags.0?<a href='/type/int'>int</a> media:<a href='/type/InputMedia'>InputMedia</a> message:<a href='/type/string'>string</a> random_id:<a href='/type/long'>long</a> reply_markup:flags.2?<a href='/type/ReplyMarkup'>ReplyMarkup</a> entities:flags.3?<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/MessageEntity'>MessageEntity</a>&gt; schedule_date:flags.10?<a href='/type/int'>int</a> send_as:flags.13?<a href='/type/InputPeer'>InputPeer</a> = <a href='/type/Updates'>Updates</a>;
<a href='/method/messages.getStickerSet'>messages.getStickerSet</a>#c8a0ec74 stickerset:<a href='/type/InputStickerSet'>InputStickerSet</a> hash:<a href='/type/int'>int</a> = <a href='/type/messages.StickerSet'>messages.StickerSet</a>;
<a href='/method/help.getAppConfig'>help.getAppConfig</a>#98914110 = <a href='/type/JSONValue'>JSONValue</a>;</code></pre>
<p>On startup, clients should fetch <a href="/api/config#client-configuration">app configuration using help.getAppConfig</a>.<br>
Then, for each dice emoji contained in the <code>emojies_send_dice</code> field, clients should fetch the dice emoji stickerset by calling the <a href="/method/messages.getStickerSet">messages.getStickerSet</a> method, providing the properly populated <a href="/constructor/inputStickerSetDice">inputStickerSetDice</a> to the <code>stickerset</code> field.<br>
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. </p>
<p>If a user attempts to send a single emoji from the ones specified in <code>emojies_send_dice</code>, the dice should be sent using <a href="/method/messages.sendMedia">messages.sendMedia</a>, providing the dice emoji to the <code>emoticon</code> field. </p>
<p>Incoming dice stickers will be received as a <a href="/constructor/messageMediaDice">messageMediaDice</a> constructor, along with a randomly generated server-side value, ranging from 1 to the maximum allowed value for this type of dice.<br>
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, <code>value</code> can be used to directly index the <code>documents</code> sticker array from the animated stickerset. </p>
<p>The <code>emojies_send_dice_success</code> configuration parameter contains more info about dice emojis other than the basic <img class="emoji" src="//telegram.org/img/emoji/40/F09F8EB2.png" width="20" height="20" alt="🎲" />: </p>
<pre><code> "emojies_send_dice_success": {
"\ud83c\udfaf": {
"value": 6,
"frame_start": 62
},
"\ud83c\udfc0": {
"value": 5,
"frame_start": 110
}
}</code></pre>
<p>For each of the dice emojis, a maximum "winning" value is specified, along with the frame number at which to show the fireworks <img class="emoji" src="//telegram.org/img/emoji/40/F09F8E86.png" width="20" height="20" alt="🎆" />.<br>
Please note that dice animated stickers should loop only once, right after being sent/received <strong>for the first time</strong>; clicking on the dice sticker should bring up a popup, inviting the user to send a new dice of the same type. </p></div>
</div>
</div>
</div>
<div class="footer_wrap">
<div class="footer_columns_wrap footer_desktop">
<div class="footer_column footer_column_telegram">
<h5>Telegram</h5>
<div class="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
</div>
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
<ul>
<li><a href="//telegram.org/faq">FAQ</a></li>
<li><a href="//telegram.org/blog">Blog</a></li>
<li><a href="//telegram.org/jobs">Jobs</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#mobile-apps">Mobile Apps</a></h5>
<ul>
<li><a href="//telegram.org/dl/ios">iPhone/iPad</a></li>
<li><a href="//telegram.org/dl/android">Android</a></li>
<li><a href="//telegram.org/dl/wp">Windows Phone</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#desktop-apps">Desktop Apps</a></h5>
<ul>
<li><a href="//desktop.telegram.org/">PC/Mac/Linux</a></li>
<li><a href="//macos.telegram.org/">macOS</a></li>
<li><a href="//telegram.org/dl/web">Web-browser</a></li>
</ul>
</div>
<div class="footer_column footer_column_platform">
<h5><a href="/">Platform</a></h5>
<ul>
<li><a href="/api">API</a></li>
<li><a href="//translations.telegram.org/">Translations</a></li>
<li><a href="//instantview.telegram.org/">Instant View</a></li>
</ul>
</div>
</div>
<div class="footer_columns_wrap footer_mobile">
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/blog">Blog</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps">Apps</a></h5>
</div>
<div class="footer_column">
<h5><a href="/">Platform</a></h5>
</div>
<div class="footer_column">
<h5><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)">Twitter</a></h5>
</div>
</div>
</div>
</div>
<script src="/js/main.js?46"></script>
<script>backToTopInit("Go up");
removePreloadInit();
</script>
</body>
</html>