1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Add use file_id example

This commit is contained in:
FrankWang 2015-07-15 13:14:46 +08:00
parent d5b7c2b49b
commit 55f6844d1f

View File

@ -59,10 +59,10 @@ def listener(messages):
tb = telebot.TeleBot(TOKEN) tb = telebot.TeleBot(TOKEN)
tb.set_update_listener(listener) #register listener tb.set_update_listener(listener) #register listener
tb.polling() tb.polling()
# polling will not stop when get new message #Use none_stop flag let polling will not stop when get new message occur error.
tb.polling(True) tb.polling(none_stop=True)
# Interval setup. Sleep 3 secs between request new message. # Interval setup. Sleep 3 secs between request new message.
tb.polling(True, 3) tb.polling(interval=3)
while True: # Don't let the main Thread end. while True: # Don't let the main Thread end.
pass pass
@ -96,22 +96,32 @@ tb.forward_message(to_chat_id, from_chat_id, message_id)
# sendPhoto # sendPhoto
photo = open('/tmp/photo.png', 'rb') photo = open('/tmp/photo.png', 'rb')
tb.send_photo(chat_id, photo) tb.send_photo(chat_id, photo)
file_id = 'AAAaaaZZZzzz'
tb.send_photo(chat_id, file_id)
# sendAudio # sendAudio
audio = open('/tmp/audio.ogg', 'rb') audio = open('/tmp/audio.ogg', 'rb')
tb.send_audio(chat_id, audio) tb.send_audio(chat_id, audio)
file_id = 'AAAaaaZZZzzz'
tb.send_audio(chat_id, file_id)
# sendDocument # sendDocument
doc = open('/tmp/file.txt', 'rb') doc = open('/tmp/file.txt', 'rb')
tb.send_document(chat_id, doc) tb.send_document(chat_id, doc)
file_id = 'AAAaaaZZZzzz'
tb.send_document(chat_id, file_id)
# sendSticker # sendSticker
sti = open('/tmp/sti.webp', 'rb') sti = open('/tmp/sti.webp', 'rb')
tb.send_sticker(chat_id, sti) tb.send_sticker(chat_id, sti)
file_id = 'AAAaaaZZZzzz'
tb.send_sticker(chat_id, file_id)
# sendVideo # sendVideo
video = open('/tmp/video.mp4', 'rb') video = open('/tmp/video.mp4', 'rb')
tb.send_video(chat_id, video) tb.send_video(chat_id, video)
file_id = 'AAAaaaZZZzzz'
tb.send_video(chat_id, file_id)
# sendLocation # sendLocation
tb.send_location(chat_id, lat, lon) tb.send_location(chat_id, lat, lon)