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

Update readme.

This commit is contained in:
eternnoir 2015-06-26 18:11:11 +08:00
parent d4ef77782c
commit 1bf8b9da09

View File

@ -18,13 +18,18 @@ print tb.send_message(281281, 'gogo power ranger')
* Echo Bot * Echo Bot
```python ```python
mport telebot import telebot
import time import time
TOKEN = '<tonke_string>' TOKEN = '<token_string>'
def listener(*messages): def listener(*messages):
"""
When new message get will call this function.
:param messages:
:return:
"""
for m in messages: for m in messages:
chatid = m.chat.id chatid = m.chat.id
text = m.text text = m.text
@ -33,7 +38,7 @@ def listener(*messages):
tb = telebot.TeleBot(TOKEN) tb = telebot.TeleBot(TOKEN)
tb.get_update() # cache exist message tb.get_update() # cache exist message
tb.set_update_listener(listener) tb.set_update_listener(listener) #register listener
tb.polling(3) tb.polling(3)
while True: while True:
time.sleep(20) time.sleep(20)