Пример #1
0
        temperature = str(w.get_temperature('celsius').get('temp'))
        bot.send_message(chat_id, 'Status cuaca uro nyo: ' + status + ' Bak ' +
                         placename + ' ' + wtime + ' Suhu jih: ' +
                         temperature + 'C')  #send the anwser


while True:  #a loop to wait for messages
    updates = bot.get_updates(
        offset=last_update_id).wait()  #we wait for a message
    try:
        for update in updates:  #get the messages
            if int(update.update_id) > int(
                    last_update_id):  #if it is a new message then get it
                last_update_id = update.update_id
                process_message(bot, update)  #send it to the function
                continue
        continue
    except Exception:
        ex = None
        print traceback.format_exc()
        continue

# Token of bot account

bot = telepot.Bot(TOKEN)
bot.message_loop(process_message)
print('Loading . . .')

# Keep bot running
while 1:
    time.sleep(10)