From b3c5f402ef90e50092a9d7e4b0f6f3645bc991b4 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sat, 27 Jun 2015 10:25:22 +0800 Subject: [PATCH] Add API usage. --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5863c8e..6338613 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,52 @@ while True: time.sleep(20) ``` +## TeleBot API usage + +***NOTICE*** : Message type only support text now. + +```python +import telebot +import time + +TOKEN = '' +tb = telebot.TeleBot(TOKEN) #create new Telegram Bot object + +# getMe +user = tb.get_me() + +# sendMessage +tb.send_message(chatid, text) + +# forwardMessage +# tb.forward_message(10894,926,3) +tb.forward_message(to_chat_id, from_chat_id, message_id) + +# sendPhoto +photo = open('/tmp/photo.png', 'rb') +tb.send_photo(chat_id, photo) + +# sendAudio +audio = open('/tmp/audio.ogg', 'rb') +tb.send_audio(chat_id, audio) + +# sendDocument +doc = open('/tmp/file.txt', 'rb') +tb.send_document(chat_id, doc) + +# sendSticker +sti = open('/tmp/sti.webp', 'rb') +tb.send_sticker(chat_id, sti) + +# sendVideo +video = open('/tmp/video.mp4', 'rb') +tb.send_video(chat_id, video) + +``` + ## TODO +- [ ] Let message not only support text. - [x] getMe - [x] sendMessage - [x] forwardMessage @@ -73,4 +117,4 @@ while True: - [ ] sendLocation - [ ] sendChatAction - [ ] getUserProfilePhotos -- [x] getUpdates +- [ ] getUpdates (Only text message support now.)