mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-28 01:11:01 +01:00
Merge pull request #43 from rahiel/master
confirm processed message in examples
This commit is contained in:
commit
92ca92341a
2 changed files with 14 additions and 17 deletions
|
@ -49,9 +49,8 @@ def main():
|
|||
def echo(bot):
|
||||
global LAST_UPDATE_ID
|
||||
|
||||
# Request updates from last updated_id
|
||||
# Request updates after the last updated_id
|
||||
for update in bot.getUpdates(offset=LAST_UPDATE_ID):
|
||||
if LAST_UPDATE_ID < update.update_id:
|
||||
# chat_id is required to reply any message
|
||||
chat_id = update.message.chat_id
|
||||
message = update.message.text.encode('utf-8')
|
||||
|
@ -62,7 +61,7 @@ def echo(bot):
|
|||
text=message)
|
||||
|
||||
# Updates global offset to get the new updates
|
||||
LAST_UPDATE_ID = update.update_id
|
||||
LAST_UPDATE_ID = update.update_id + 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -38,12 +38,10 @@ def main():
|
|||
chat_id = update.message.chat.id
|
||||
update_id = update.update_id
|
||||
|
||||
if LAST_UPDATE_ID < update_id: # If newer than the initial
|
||||
# LAST_UPDATE_ID
|
||||
if text:
|
||||
roboed = ed(text) # Ask something to Robô Ed
|
||||
bot.sendMessage(chat_id=chat_id, text=roboed)
|
||||
LAST_UPDATE_ID = update_id
|
||||
LAST_UPDATE_ID = update_id + 1
|
||||
|
||||
|
||||
def ed(text):
|
||||
|
|
Loading…
Add table
Reference in a new issue