Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Commit a736e91

Browse files
committed
Documentation for the gaming platform and the debug logging
1 parent 8dbb1c5 commit a736e91

File tree

15 files changed

+188
-15
lines changed

15 files changed

+188
-15
lines changed

docs/index.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@ Nodeogram is released under the GNU General Public License 3.0.
7676
:caption: Objects
7777
:glob:
7878

79+
objects/Animation
7980
objects/Bot
80-
objects/Chat
81-
objects/User
82-
objects/Message
83-
objects/Keyboard
8481
objects/CallbackQuery
85-
objects/ChosenInlineResult
82+
objects/Chat
8683
objects/ChatMember
84+
objects/ChosenInlineResult
8785
objects/File
86+
objects/Game
87+
objects/GameHighScore
8888
objects/InlineQuery
89+
objects/Keyboard
90+
objects/Message
91+
objects/User
8992
objects/UserProfilePhotos

docs/objects/Animation.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Animation
2+
=========
3+
4+
This object represents an animation for a Telegram game.
5+
6+
.. note::
7+
8+
This object inherits some properties from the corresponding `Telegram object <https://core.telegram.org/bots/api#animation>`_.
9+
10+
.. js:class:: Animation(object, bot)
11+
12+
.. warning::
13+
14+
This constructor should be for internal use only.
15+
16+
Creates a new Animation object.
17+
18+
.. js:attribute:: Message.photo
19+
20+
Array of :doc:`PhotoSize` objects.

docs/objects/Bot.rst

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ This object represents a Telegram bot.
3434
webhookPort: 8080,
3535
webhookFunction: (req, res) => {...},
3636
// Should the bot automatically fetch/listen for updates?
37-
autoFetch: true
37+
autoFetch: true,
38+
debug: false
3839
}
3940
4041
.. _init:
@@ -117,9 +118,16 @@ This object represents a Telegram bot.
117118
:param object options: *Optional*
118119
:returns: A promise that resolves to a :doc:`Message` object representing what has been sent.
119120

120-
121121
Sends a contact object to the specified chat.
122122

123+
.. js:function:: sendGame(chat_id, game_short_name[, options])
124+
125+
:param string chat_id: Can also be a :doc:`Chat` or a :doc:`User` object
126+
:param string game_short_name: The Telegram identifier for the game
127+
:returns: A promise that resolves to a :doc:`Message` object representing what has been sent.
128+
129+
Sends a game to the specified chat.
130+
123131
.. js:function:: forwardMessage(chat_id, from_chat_id, message_id[, options])
124132

125133
:param string chat_id: Can also be a :doc:`Chat` or a :doc:`User` object
@@ -130,11 +138,10 @@ This object represents a Telegram bot.
130138

131139
Forwards a message to the specified chat,
132140

133-
.. js:function:: answerCallbackQuery(id, text, alert)
141+
.. js:function:: answerCallbackQuery(id, options)
134142

135143
:param string id:
136-
:param string text:
137-
:param boolean alert: Whether the user should be shown an alert
144+
:param object options: **Not optional**
138145
:returns: A promise that resolves to the response (according to Telegram, true on success).
139146

140147
Answers a callback query.
@@ -207,6 +214,28 @@ This object represents a Telegram bot.
207214

208215
Updates the specified message markup in the specified chat.
209216

217+
.. js:function:: setGameScore(id, user_id, score, inline, options, chat_id)
218+
219+
:param string id: The message id
220+
:param string user_id: Can also be a :doc:`User` object
221+
:param number score:
222+
:param boolean inline: Is the message an inline one?
223+
:param object options:
224+
:param string chat_id: Can also be a :doc:`Chat` or a :doc:`User` object
225+
:returns: A promise that resolves to a :doc:`Message` object representing the updated message. True is returned by the promise if the message is an inline one or if the request did not instruct Telegram to edit the original message.
226+
227+
Sets a user's score for a game.
228+
229+
.. js:function:: getGameHighScores(id, user_id, inline, chat_id)
230+
231+
:param string id: The message id
232+
:param string user_id: Can also be a :doc:`User` object
233+
:param boolean inline: Is the message an inline one?
234+
:param string chat_id: Can also be a :doc:`Chat` or a :doc:`User` object
235+
:returns: A promise that resolves to an array of :doc:`GameHighScore` objects.
236+
237+
Returns information about the user's rank and score for a game.
238+
210239
.. js:function:: getChatAdministrators (chat_id)
211240

212241
:param string chat_id: Can also be a :doc:`Chat` object

docs/objects/CallbackQuery.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ This object represents a Telegram callback query.
1515

1616
Creates a new CallbackQuery object.
1717

18-
.. js:function:: answer(text, alert)
18+
.. js:function:: answer(options)
1919

20-
:param string text:
21-
:param boolean alert: Whether the user should be shown an alert
20+
:param object options: **Not optional**
2221
:returns: A promise that resolves to the response (according to Telegram, true on success).
2322

2423
Answers the query.

docs/objects/Chat.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ Creates a new Chat object.
5858

5959
Sends a contact object to the chat.
6060

61+
.. js:function:: sendGame (game_short_name[, options])
62+
63+
:param string game_short_name: The Telegram game identifier.
64+
:param object options: *Optional*
65+
:returns: A promise that resolves to a :doc:`Message` object representing what has been sent.
66+
67+
Sends a Telegram game to the chat.
68+
6169
.. js:function:: forwardMessage(from_chat_id, message_id[, options])
6270

6371
:param string from_chat_id:

docs/objects/Game.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Game
2+
====
3+
4+
This object represents a Telegram game.
5+
6+
.. note::
7+
8+
This object inherits some properties from the corresponding `Telegram object <https://core.telegram.org/bots/api#game>`_.
9+
10+
.. js:class:: Game(object, bot)
11+
12+
.. warning::
13+
14+
This constructor should be for internal use only.
15+
16+
Creates a new Game object.
17+
18+
.. js:attribute:: Game.commands
19+
20+
Array of objects, each one representing a command in the game description.
21+
22+
.. code-block:: javascript
23+
24+
// Recipient is undefined if it's a direct command
25+
{command: '/echo', recipient: 'yourbot', args: ['Many', 'things']}
26+
27+
.. js:attribute:: Game.mentions
28+
29+
Array of strings, each one representing a mention (e.g. @nickname) in the game description.
30+
31+
.. js:attribute:: Game.hashtags
32+
33+
Array of strings, each one representing an hashtag (e.g. #things) in the game description.
34+
35+
.. js:attribute:: Game.links
36+
37+
Array of objects, each one representing a link (both URL and parsed text links) in the game description.
38+
39+
.. code-block:: javascript
40+
41+
// URL
42+
{type: 'url', url: 'http://google.com', text: 'http://google.it'}
43+
44+
// Text link
45+
{type: 'link', url: 'http://google.com', text: 'Google'}
46+
47+
.. js:attribute:: Game.text_mentions
48+
49+
Array of objects, each one representing a text mention (i.e. mentions of users without a nickname) in the game description.
50+
51+
.. code-block:: javascript
52+
53+
{text: 'User', user: <User>}

docs/objects/GameHighScore.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GameHighScore
2+
=============
3+
4+
This object represents an high score for a user on the Telegram gaming platform.
5+
6+
.. note::
7+
8+
This object inherits some properties from the corresponding `Telegram object <https://core.telegram.org/bots/api#gamehighscore>`_.
9+
10+
.. js:class:: GameHighScore(object, bot)
11+
12+
.. warning::
13+
14+
This constructor should be for internal use only.
15+
16+
Creates a new GameHighScore object.

docs/objects/InlineQueryResult.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,10 @@ the objects' properties are directly inherited from the upstream Telegram API.
9090
:param string id:
9191
:param string voice_url:
9292
:param string title:
93+
:param object options: *Optional*.
94+
95+
.. js:class:: InlineQueryResultGame(id, game_short_name[, options])
96+
97+
:param string id:
98+
:param string game_short_name:
9399
:param object options: *Optional*.

docs/objects/Message.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ Creates a new Message object.
5757

5858
Updates the specified message markup.
5959

60+
.. js:function:: setGameScore(user_id, score, inline[, options])
61+
62+
:param string user_id: Can also be a :doc:`User` object
63+
:param number score:
64+
:param boolean inline: Is the message an inline one?
65+
:param object options:
66+
:returns: A promise that resolves to a :doc:`Message` object representing the updated message. True is returned by the promise if the message is an inline one or if the request did not instruct Telegram to edit the original message.
67+
68+
Sets a user's score for a game.
69+
70+
.. js:function:: getGameHighScores(user_id, inline)
71+
72+
:param string user_id: Can also be a :doc:`User` object
73+
:param boolean inline: Is the message an inline one?
74+
:returns: A promise that resolves to an array of :doc:`GameHighScore` objects.
75+
76+
Returns information about the user's rank and score for a game.
77+
6078
.. js:attribute:: Message.commands
6179

6280
Array of objects, each one representing a command in the message.

docs/objects/User.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ Creates a new User object.
7777
:param string action: <String> Must be one of the following: ``typing``, ``upload_photo``, ``record_video``, ``upload_video``, ``record_audio``, ``upload_audio``, ``upload_document``, ``find_location``
7878
:returns: A promise that resolves to the response (true on success).
7979

80+
.. js:function:: sendGame (game_short_name[, options])
81+
82+
:param string game_short_name: The Telegram game identifier.
83+
:param object options: *Optional*
84+
:returns: A promise that resolves to a :doc:`Message` object representing what has been sent.
85+
86+
Sends a Telegram game to the user.
87+
8088
.. js:function:: getProfilePhotos(options)
8189

8290
:param object options: *Optional*

0 commit comments

Comments
 (0)