You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+50-1Lines changed: 50 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,13 @@ View the last release API documentation at: https://core.telegram.org/bots/api
51
51
API
52
52
---
53
53
54
-
The API is exposed via the ``telegram.Bot`` class::
54
+
The API is exposed via the ``telegram.Bot`` class.
55
+
56
+
To generate an Access Token you have to talk to `BotFather https://telegram.me/botfather`_ and follow a few simple steps (described `here https://core.telegram.org/bots#botfather`_).
57
+
58
+
For full details see the `Bots: An introduction for developers <https://core.telegram.org/bots>`_.
59
+
60
+
To create an instance of the ``telegram.Bot``::
55
61
56
62
>>> import telegram
57
63
>>> bot = telegram.Bot(token='token')
@@ -62,3 +68,46 @@ To see if your credentials are successful::
**NOTE**: much more than the small sample given here will print
71
+
72
+
Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use ``telegram.me/<bot_username>`` links or username search to find your bot.
73
+
74
+
To fetch text messages sent to your Bot::
75
+
76
+
>>> updates = bot.getUpdates()
77
+
>>> print [u.message.text for u in updates]
78
+
79
+
To fetch images sent to your Bot::
80
+
81
+
>>> updates = bot.getUpdates()
82
+
>>> print [u.message.photo for u in updates if u.message.photo]
83
+
84
+
To post a text message (you'll always need chat_id to reply users)::
There are many more API methods, to read the full API documentation::
100
+
101
+
$ pydoc telegram.Bot
102
+
103
+
----
104
+
TODO
105
+
----
106
+
107
+
Patches and bug reports are `welcome <https://github.com/leandrotoledo/python-telegram-bot/issues/new>`_, just please keep the style consistent with the original source.
0 commit comments