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

Commit c107eed

Browse files
committed
More statements for Thingsbot
1 parent 8d8d3d9 commit c107eed

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

docs/style.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ Nodeogram's functions can fail at any time - querying the API, attempting to sen
2525
bot was kicked out, etc - and not handling errors properly might result in unexpected behaviours or worse - getting
2626
your bot or IP address tempbanned from Telegram's server could really ruin your day.
2727

28+
*******
29+
Parsing
30+
*******
31+
32+
This documentation **does not feature any attribute that is also made available by the upstream Telegram API**. Please refer
33+
to the `Telegram documentation <https://core.telegram.org/bots/api>`_ if you need information about them.
34+
35+
.. note::
36+
37+
This object inherits some properties from the corresponding `Telegram object <https://core.telegram.org/bots/api>`_.
38+
39+
If an object's documentation features this note, it means that some of its attributes were parsed from the original API
40+
into a Nodeogram object. This applies to pretty much any of the library's objects.
41+
2842
==============
2943
Best practices
3044
==============

examples/thingsbot/thingsbot.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ function statements(data) {
123123
if (claims.P1590) data._statements.casualties = claims.P1590[0].mainsnak.datavalue.value.amount;
124124
if (claims.P580) data._statements.start = date(claims.P580[0].mainsnak.datavalue.value.time);
125125
if (claims.P582) data._statements.end = date(claims.P582[0].mainsnak.datavalue.value.time);
126+
if (claims.P585) data._statements.time = date(claims.P585[0].mainsnak.datavalue.value.time);
127+
if (claims.P1867) data._statements.voters = claims.P1867[0].mainsnak.datavalue.value.amount;
128+
if (claims.P1868) data._statements.ballots = claims.P1868[0].mainsnak.datavalue.value.amount;
129+
if (claims.P1346) data._statements.winner = claims.P1346[0].mainsnak.datavalue.value["numeric-id"];
130+
if (claims.P991) data._statements.winner_candidate = claims.P991;
131+
if (claims.P726) data._statements.candidates = claims.P726;
132+
if (claims.P2002) data._statements.twitter = claims.P2002[0].mainsnak.datavalue.value;
133+
if (claims.P2003) data._statements.instagram = claims.P2003[0].mainsnak.datavalue.value;
134+
if (claims.P2013) data._statements.facebook = claims.P2003[0].mainsnak.datavalue.value;
135+
if (claims.P2847) data._statements.plus = claims.P2847[0].mainsnak.datavalue.value;
126136

127137

128138
} catch (err) {
@@ -257,8 +267,17 @@ function message(data) {
257267
if (data._statements.casualties) text += `*${data._statements.casualties}* casualties\n`;
258268
if (data._statements.start) text += `Beginning date: *${data._statements.start}*\n`;
259269
if (data._statements.end) text += `Ending date: *${data._statements.end}*\n`;
270+
if (data._statements.time) text += `Date: *${data._statements.time}*\n`;
271+
if (data._statements.voters) text += `*${data._statements.voters}* eligible voters\n`;
272+
if (data._statements.ballots) text += `*${data._statements.ballots}* ballots cast\n`;
273+
if (data._statements.candidates) text += `Candidates: *${data._statements.candidates.join(", ")}*\n`;
274+
if (data._statements.winner) text += `Winner: *${data._statements.winner}*\n`;
275+
if (data._statements.winner_candidate) text += `Successful candidate(s): *${data._statements.winner_candidate.join(", ")}*\n`;
260276

261-
277+
if (data._statements.twitter) text += `📘 [Facebook profile](http://facebook.com/${data._statements.twitter})\n`;
278+
if (data._statements.plus) text += `➕ [${data._statements.plus}](http://plus.google.com/${data._statements.plus}) on Google+\n`;
279+
if (data._statements.twitter) text += `🐦 [@${data._statements.twitter}](http://twitter.com/${data._statements.twitter}) on Twitter\n`;
280+
if (data._statements.instagram) text += `📷 [${data._statements.instagram}](http://instagram.com/${data._statements.instagram}) on Instagram\n`;
262281
if (data._statements.streaming) text += `📡 [Available via streaming](${data._statements.streaming})\n`;
263282
if (data._statements.stackexchange) text += `☝ [StackExchange Tag](${data._statements.stackexchange})\n`;
264283
if (data._statements.bugs) text += `🐛 [Bug Tracking](${data._statements.bugs})\n`;

0 commit comments

Comments
 (0)