File tree Expand file tree Collapse file tree 2 files changed +16
-19
lines changed
Expand file tree Collapse file tree 2 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -49,20 +49,19 @@ def main():
4949def echo (bot ):
5050 global LAST_UPDATE_ID
5151
52- # Request updates from last updated_id
52+ # Request updates after the last updated_id
5353 for update in bot .getUpdates (offset = LAST_UPDATE_ID ):
54- if LAST_UPDATE_ID < update .update_id :
55- # chat_id is required to reply any message
56- chat_id = update .message .chat_id
57- message = update .message .text .encode ('utf-8' )
58-
59- if (message ):
60- # Reply the message
61- bot .sendMessage (chat_id = chat_id ,
62- text = message )
63-
64- # Updates global offset to get the new updates
65- LAST_UPDATE_ID = update .update_id
54+ # chat_id is required to reply any message
55+ chat_id = update .message .chat_id
56+ message = update .message .text .encode ('utf-8' )
57+
58+ if (message ):
59+ # Reply the message
60+ bot .sendMessage (chat_id = chat_id ,
61+ text = message )
62+
63+ # Updates global offset to get the new updates
64+ LAST_UPDATE_ID = update .update_id + 1
6665
6766
6867if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -38,12 +38,10 @@ def main():
3838 chat_id = update .message .chat .id
3939 update_id = update .update_id
4040
41- if LAST_UPDATE_ID < update_id : # If newer than the initial
42- # LAST_UPDATE_ID
43- if text :
44- roboed = ed (text ) # Ask something to Robô Ed
45- bot .sendMessage (chat_id = chat_id , text = roboed )
46- LAST_UPDATE_ID = update_id
41+ if text :
42+ roboed = ed (text ) # Ask something to Robô Ed
43+ bot .sendMessage (chat_id = chat_id , text = roboed )
44+ LAST_UPDATE_ID = update_id + 1
4745
4846
4947def ed (text ):
You can’t perform that action at this time.
0 commit comments