mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-12-13 10:21:08 +01:00
174 lines
14 KiB
HTML
174 lines
14 KiB
HTML
<!DOCTYPE html>
|
||
<html class="">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Games</title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta property="description" content="Bots can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats.">
|
||
<meta property="og:title" content="Games">
|
||
<meta property="og:image" content="">
|
||
<meta property="og:description" content="Bots can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats.">
|
||
<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?240" 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/bots%2Fgames" >Games</a></li></ul></div>
|
||
<h1 id="dev_page_title">Games</h1>
|
||
|
||
<div id="dev_page_content"><!-- scroll_nav -->
|
||
|
||
<p>Bots can offer users <a href="/bots/games">HTML5 games</a> to play solo or to compete against each other in groups and one-on-one chats. </p>
|
||
<h3><a class="anchor" href="#sending-a-game" id="sending-a-game" name="sending-a-game"><i class="anchor-icon"></i></a>Sending a game</h3>
|
||
<pre><code><a href='/constructor/inputUserSelf'>inputUserSelf</a>#f7c1b13f = <a href='/type/InputUser'>InputUser</a>;
|
||
|
||
<a href='/constructor/inputGameID'>inputGameID</a>#32c3e77 id:<a href='/type/long'>long</a> access_hash:<a href='/type/long'>long</a> = <a href='/type/InputGame'>InputGame</a>;
|
||
<a href='/constructor/inputGameShortName'>inputGameShortName</a>#c331e80a bot_id:<a href='/type/InputUser'>InputUser</a> short_name:<a href='/type/string'>string</a> = <a href='/type/InputGame'>InputGame</a>;
|
||
|
||
<a href='/constructor/inputMediaGame'>inputMediaGame</a>#d33f43f3 id:<a href='/type/InputGame'>InputGame</a> = <a href='/type/InputMedia'>InputMedia</a>;
|
||
|
||
<a href='/constructor/game'>game</a>#bdf9653b flags:<a href='/type/%23'>#</a> id:<a href='/type/long'>long</a> access_hash:<a href='/type/long'>long</a> short_name:<a href='/type/string'>string</a> title:<a href='/type/string'>string</a> description:<a href='/type/string'>string</a> photo:<a href='/type/Photo'>Photo</a> document:flags.0?<a href='/type/Document'>Document</a> = <a href='/type/Game'>Game</a>;
|
||
<a href='/constructor/messageMediaGame'>messageMediaGame</a>#fdb19008 game:<a href='/type/Game'>Game</a> = <a href='/type/MessageMedia'>MessageMedia</a>;
|
||
|
||
---functions---
|
||
|
||
<a href='/method/messages.sendMedia'>messages.sendMedia</a>#7852834e 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> update_stickersets_order:flags.15?<a href='/constructor/true'>true</a> invert_media:flags.16?<a href='/constructor/true'>true</a> peer:<a href='/type/InputPeer'>InputPeer</a> reply_to:flags.0?<a href='/type/InputReplyTo'>InputReplyTo</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><<a href='/type/MessageEntity'>MessageEntity</a>> schedule_date:flags.10?<a href='/type/int'>int</a> send_as:flags.13?<a href='/type/InputPeer'>InputPeer</a> quick_reply_shortcut:flags.17?<a href='/type/InputQuickReplyShortcut'>InputQuickReplyShortcut</a> effect:flags.18?<a href='/type/long'>long</a> = <a href='/type/Updates'>Updates</a>;</code></pre>
|
||
<p>Bots can directly send a game using <a href="/method/messages.sendMedia">messages.sendMedia</a>, providing:</p>
|
||
<ul>
|
||
<li>The game's short name obtained from <a href="https://t.me/botfather">@BotFather</a> or from a <a href="/api/links#game-links">game link »</a> to <code>inputGameShortName.short_name</code></li>
|
||
<li>The current bot's info to <code>inputGameShortName.bot_id</code></li>
|
||
</ul>
|
||
<p>The sent message will contain a <a href="/constructor/messageMediaGame">messageMediaGame</a> with a <a href="/constructor/game">game</a>, that can then be used by users to forward the game using sendMedia with <a href="/constructor/inputGameID">inputGameID</a>.</p>
|
||
<h3><a class="anchor" href="#starting-a-game" id="starting-a-game" name="starting-a-game"><i class="anchor-icon"></i></a>Starting a game</h3>
|
||
<p>Games are started clicking on the button, which triggers an callback query that returns the game URL, for more info <a href="/api/bots/buttons#callback-queries">see here »</a>.<br>
|
||
The game should then be opened in a WebView or in native UI (specified by the <code>native_ui</code> flag), exposing the <a href="/api/web-events">appropriate HTML5 APIs</a> in order to receive various JS game events directly from the code of the game, as described <a href="/api/web-events">here »</a>. </p>
|
||
<h3><a class="anchor" href="#setting-highscores" id="setting-highscores" name="setting-highscores"><i class="anchor-icon"></i></a>Setting highscores</h3>
|
||
<pre><code>---functions---
|
||
|
||
<a href='/method/messages.setGameScore'>messages.setGameScore</a>#8ef8ecc0 flags:<a href='/type/%23'>#</a> edit_message:flags.0?<a href='/constructor/true'>true</a> force:flags.1?<a href='/constructor/true'>true</a> peer:<a href='/type/InputPeer'>InputPeer</a> id:<a href='/type/int'>int</a> user_id:<a href='/type/InputUser'>InputUser</a> score:<a href='/type/int'>int</a> = <a href='/type/Updates'>Updates</a>;
|
||
<a href='/method/messages.setInlineGameScore'>messages.setInlineGameScore</a>#15ad9f64 flags:<a href='/type/%23'>#</a> edit_message:flags.0?<a href='/constructor/true'>true</a> force:flags.1?<a href='/constructor/true'>true</a> id:<a href='/type/InputBotInlineMessageID'>InputBotInlineMessageID</a> user_id:<a href='/type/InputUser'>InputUser</a> score:<a href='/type/int'>int</a> = <a href='/type/Bool'>Bool</a>;</code></pre>
|
||
<p>Games are supposed to report back to the MTProto API every time the user looses a game with a new highscore.<br>
|
||
Since games run in the browser, they cannot directly report data to the API using the bot token, which must be kept secret.<br>
|
||
Instead, they should send highscores to an intermediate server, that will then report scores using <a href="/method/messages.setGameScore">messages.setGameScore</a> or <a href="/method/messages.setInlineGameScore">messages.setInlineGameScore</a>, depending on the source of the game. </p>
|
||
<ul>
|
||
<li>The <code>edit_message</code> flag should be set if the game message should be automatically edited to include the current scoreboard</li>
|
||
<li>The <code>force</code> flag should be set if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.</li>
|
||
</ul>
|
||
<h3><a class="anchor" href="#getting-highscores" id="getting-highscores" name="getting-highscores"><i class="anchor-icon"></i></a>Getting highscores</h3>
|
||
<pre><code><a href='/constructor/messageActionGameScore'>messageActionGameScore</a>#92a72876 game_id:<a href='/type/long'>long</a> score:<a href='/type/int'>int</a> = <a href='/type/MessageAction'>MessageAction</a>;
|
||
|
||
<a href='/constructor/messageService'>messageService</a>#2b085862 flags:<a href='/type/%23'>#</a> out:flags.1?<a href='/constructor/true'>true</a> mentioned:flags.4?<a href='/constructor/true'>true</a> media_unread:flags.5?<a href='/constructor/true'>true</a> silent:flags.13?<a href='/constructor/true'>true</a> post:flags.14?<a href='/constructor/true'>true</a> legacy:flags.19?<a href='/constructor/true'>true</a> id:<a href='/type/int'>int</a> from_id:flags.8?<a href='/type/Peer'>Peer</a> peer_id:<a href='/type/Peer'>Peer</a> reply_to:flags.3?<a href='/type/MessageReplyHeader'>MessageReplyHeader</a> date:<a href='/type/int'>int</a> action:<a href='/type/MessageAction'>MessageAction</a> ttl_period:flags.25?<a href='/type/int'>int</a> = <a href='/type/Message'>Message</a>;
|
||
|
||
<a href='/constructor/highScore'>highScore</a>#73a379eb pos:<a href='/type/int'>int</a> user_id:<a href='/type/long'>long</a> score:<a href='/type/int'>int</a> = <a href='/type/HighScore'>HighScore</a>;
|
||
|
||
<a href='/constructor/messages.highScores'>messages.highScores</a>#9a3bfd99 scores:<a href='/type/Vector%20t'>Vector</a><<a href='/type/HighScore'>HighScore</a>> users:<a href='/type/Vector%20t'>Vector</a><<a href='/type/User'>User</a>> = <a href='/type/messages.HighScores'>messages.HighScores</a>;
|
||
|
||
---functions---
|
||
|
||
<a href='/method/messages.getGameHighScores'>messages.getGameHighScores</a>#e822649d peer:<a href='/type/InputPeer'>InputPeer</a> id:<a href='/type/int'>int</a> user_id:<a href='/type/InputUser'>InputUser</a> = <a href='/type/messages.HighScores'>messages.HighScores</a>;
|
||
<a href='/method/messages.getInlineGameHighScores'>messages.getInlineGameHighScores</a>#f635e1b id:<a href='/type/InputBotInlineMessageID'>InputBotInlineMessageID</a> user_id:<a href='/type/InputUser'>InputUser</a> = <a href='/type/messages.HighScores'>messages.HighScores</a>;</code></pre>
|
||
<p>Every time a highscore is reached, and the <code>edit_message</code> flag is set when reporting the score, a <a href="/constructor/messageService">messageService</a> with a <a href="/constructor/messageActionGameScore">messageActionGameScore</a> is generated, indicating that the highscore of a certain game has changed, thanks to a certain <code>user_id</code>.<br>
|
||
Our own current position of the scoreboard is also reported as <code>pos</code>. </p>
|
||
<p>When receiving such an update, graphical clients should refetch the scoreboard using <a href="/method/messages.getGameHighScores">messages.getGameHighScores</a> or <a href="/method/messages.getInlineGameHighScores">messages.getInlineGameHighScores</a>.</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/privacy">Privacy</a></li>
|
||
<li><a href="//telegram.org/press">Press</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/android">Android</a></li>
|
||
<li><a href="//telegram.org/dl/web">Mobile Web</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="//telegram.org/press">Press</a></h5>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="/js/main.js?47"></script>
|
||
<script src="/js/jquery.min.js?1"></script>
|
||
<script src="/js/bootstrap.min.js?1"></script>
|
||
|
||
<script>window.initDevPageNav&&initDevPageNav();
|
||
backToTopInit("Go up");
|
||
removePreloadInit();
|
||
</script>
|
||
</body>
|
||
</html>
|
||
|