Ejemplo n.º 1
0
def add_stats(user_id, chat_id, _datetime):
    user = try_user(user_id)
    chat = try_chat(chat_id)

    if user and chat:
        row = Stats(id_user=user, id_chat=chat, date_time=_datetime)
        row.save(force_insert=True)
Ejemplo n.º 2
0
def add_text(user_id, chat_id, msg, attach):
    user = try_user(user_id)
    chat = try_chat(chat_id)

    if user and chat:
        row = Texts(id_user=user, id_chat=chat, text=msg, attach=attach)
        row.save(force_insert=True)
Ejemplo n.º 3
0
def add_stats_user(user_id, chat_id):
    user = try_user(user_id)
    chat = try_chat(chat_id)
    if user and chat:
        row = StatsUser(
            id_user=user,
            id_chat=chat,
        )
        row.save(force_insert=True)
Ejemplo n.º 4
0
def add_set_default(chat_id, type_id, val):
    chat = try_chat(chat_id)
    _type = TypeSet.select().where(TypeSet.id == int(type_id)).get()
    if chat:
        row = Settings(
            id_type=_type,
            id_chat=chat,
            val=_type.default_val
        )
    row.save(force_insert=True)
Ejemplo n.º 5
0
def add_marrieds(user_id_one, user_id_two, chat_id):
    m_exist = False

    user_one = try_user(user_id_one)
    user_two = try_user(user_id_two)
    chat = try_chat(chat_id)

    try:
        Marrieds.select().where(Marrieds.id_chat == int(chat_id),
                                ((Marrieds.id_user_one == user_id_one) |
                                 (Marrieds.id_user_one == user_id_two) |
                                 (Marrieds.id_user_two == user_id_one) |
                                 (Marrieds.id_user_two == user_id_one))).get()
    except Marrieds.DoesNotExist:
        m_exist = True

    if user_one and user_two and chat:
        if m_exist:
            row = Marrieds(id_user_one=user_one,
                           id_user_two=user_two,
                           id_chat=chat)
            row.save(force_insert=True)
            return 1
    return 0