示例#1
0
def set_channel_language(id, language):
    channel_ref = DB.collection("channels").document(str(id))

    channel_ref.set(
        {
            "language" : language
        }, merge=True
    )
示例#2
0
def set_combat_state(id, combat):
    channel_ref = DB.collection("channels").document(str(id))
    channel_ref.set(
        {
            "combat" : {
                "in_combat" : combat
            }
        }, merge=True
    )
示例#3
0
def add_combatant(id, name, init):
    channel_ref = DB.collection("channels").document(str(id))
    channel_ref.set(
        {
            "combat" : {
                "combatants" : {
                    "name" : name,
                    "iscore" : init
                }
            }
        }, merge=True
    )                
示例#4
0
def get_channel_language(id):
    channel_ref = DB.collection("channels").document(str(id))
    channel = channel_ref.get()
    if channel.exists:
        return channel.to_dict()["language"]
    else:
        channel_ref.set(
            {
                "language" : "en"
            }, merge=True
        )
        return "en"
示例#5
0
def get_combat_state(id):
    channel_ref = DB.collection("channels").document(str(id))
    channel = channel_ref.get()
    if channel.exists:
        if channel.to_dict()["combat"]["in_combat"] is not None:
            return channel.to_dict()["combat"]["in_combat"]
        else:
            channel_ref.set(
                {
                    "combat" : {
                        "in_combat" : False
                    }
                }, merge=True
            )
            return False