Пример #1
0
def store_lang(update, context, query):
    lang_code = LANGUAGES[query.data]
    with client.transaction():
        user_key = client.key(USER, query.from_user.id)
        user = client.get(key=user_key)
        user[LANGUAGE] = lang_code
        client.put(user)

    context.user_data[LANGUAGE] = lang_code
    _ = set_lang(update, context)
    query.message.edit_text(_("Your language has been set to {}").format(query.data))
Пример #2
0
def update_stats(update, task):
    user_key = client.key(USER, update.effective_message.from_user.id)
    with client.transaction():
        user = client.get(key=user_key)
        if user is None:
            user = datastore.Entity(user_key)
            user[task] = 1
        else:
            if task in user:
                user[task] += 1
            else:
                user[task] = 1

        client.put(user)