def process_updates(update_offset):
    next_update_offset = update_offset
    for update in bot.getUpdates(offset = update_offset):
        telegram_target = update.message.chat_id
        message = update.message.text.encode('utf-8')

        if (message):
            bot.sendMessage(chat_id=telegram_target, text=message)
            next_update_offset = max(next_update_offset, update.update_id + 1)

    return next_update_offset
def notify_by_key(msg, api_key):
    key = ApiKey.query.filter_by(key=api_key).first()
    print(text)
    for target in key.telegram_targets:
        bot.sendMessage(chat=target.id ,text=msg)