@@ -89,26 +89,37 @@ To fetch images sent to your Bot::
89
89
>>> updates = bot.getUpdates()
90
90
>>> print [u.message.photo for u in updates if u.message.photo]
91
91
92
- To post a text message ( you'll always need chat_id to reply users) ::
92
+ To reply messages you'll always need the chat_id ::
93
93
94
94
>>> chat_id = bot.getUpdates()[-1].message.chat_id
95
+
96
+ To post a text message::
97
+
95
98
>>> bot.sendMessage(chat_id=chat_id, text="I'm sorry Dave I'm afraid I can't do that.")
96
99
97
100
To post an Emoji (special thanks to `Tim Whitlock <http://apps.timwhitlock.info/emoji/tables/unicode >`_)::
98
101
99
- >>> chat_id = bot.getUpdates()[-1].message.chat_id
100
102
>>> bot.sendMessage(chat_id=chat_id, text=telegram.Emoji.PILE_OF_POO)
101
103
102
- To post a audio file (you'll always need chat_id to reply users) ::
104
+ To post a audio file::
103
105
104
- >>> chat_id = bot.getUpdates()[-1].message.chat_id
105
106
>>> bot.sendAudio(chat_id=chat_id, audio=open('tests/telegram.ogg', 'rb'))
106
107
107
108
To tell the user that something is happening on bot's side::
108
109
109
- >>> chat_id = bot.getUpdates()[-1].message.chat_id
110
110
>>> bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
111
111
112
+ To create `Custom Keyboards <https://core.telegram.org/bots#keyboards>_ `::
113
+
114
+ >>> custom_keyboard = [[ telegram.Emoji.THUMBS_UP_SIGN, telegram.Emoji.THUMBS_DOWN_SIGN ]]
115
+ >>> reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
116
+ >>> bot.sendMessage(chat_id=chat_id, text="Stay here, I'll be back.", reply_markup=reply_markup)
117
+
118
+ To hide `Custom Keyboards <https://core.telegram.org/bots#keyboards>_ `::
119
+
120
+ >>> reply_markup = telegram.ReplyKeyboardHide()
121
+ >>> bot.sendMessage(chat_id=chat_id, text="I'm back.", reply_markup=reply_markup)
122
+
112
123
There are many more API methods, to read the full API documentation::
113
124
114
125
$ pydoc telegram.Bot
0 commit comments