X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions examples/echobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ 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')

if (message):
# Reply the message
bot.sendMessage(chat_id=chat_id,
text=message)

# Updates global offset to get the new updates
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')

if (message):
# Reply the message
bot.sendMessage(chat_id=chat_id,
text=message)

# Updates global offset to get the new updates
LAST_UPDATE_ID = update.update_id + 1


if __name__ == '__main__':
Expand Down
10 changes: 4 additions & 6 deletions examples/roboed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
if text:
roboed = ed(text) # Ask something to Robô Ed
bot.sendMessage(chat_id=chat_id, text=roboed)
LAST_UPDATE_ID = update_id + 1


def ed(text):
Expand Down
X Tutup