Exemplo n.º 1
0
def take_contact(bot, telegram, first_name, phone_number):
    # send_menu
    text = GREETINS.format(first_name)

    message_id = bot.send_photo(telegram,
                                WATER_PHOTO,
                                text,
                                reply_markup=menu[1].get('button'))

    try:
        del_menu(bot, telegram, users[telegram].get('mess_id'))
    except Exception as e:
        print('error', e)
        message_id = bot.send_message(telegram,
                                      NEED_PHONE_NUMBER,
                                      reply_markup=contact_menu())
        del_menu(bot, telegram, message_id.message_id)

    # adding user to users
    check_connect()
    user = select_user(telegram)
    if user == []:
        print(phone_number)
        if phone_number[0] == '+':
            phone_number = phone_number[1::]
        connect_mysql.insert(
            'users', **{
                'telegram': telegram,
                'name': first_name,
                'phone': phone_number
            })
        all_rows = select_list_of_users()
        report(NEW_USER.format(first_name, phone_number, all_rows))

    # adding user to menu
    user_menu = select_menu(telegram)
    if user_menu == []:
        connect_mysql.insert(
            'menu', **{
                'telegram': telegram,
                'message_id': message_id.message_id,
                'text': text.encode('utf-8'),
                'index': 1
            })
    else:
        update_menu(telegram, message_id.message_id, text, 1)
Exemplo n.º 2
0
Arquivo: views.py Projeto: LioHub/CW
def insert_menu(telegram):
    check_connect()
    connect_mysql.insert('menu', **{'telegram': telegram})
Exemplo n.º 3
0
Arquivo: views.py Projeto: LioHub/CW
def insert_news(telegram, new):
    check_connect()
    connect_mysql.insert('news', **{'telegram': telegram, 'new': new})
Exemplo n.º 4
0
Arquivo: views.py Projeto: LioHub/CW
def add_sub(**kwargs):
    check_connect()
    return connect_mysql.insert('subscription', **kwargs)
Exemplo n.º 5
0
Arquivo: views.py Projeto: LioHub/CW
def insert_order(**kwargs):
    check_connect()
    connect_mysql.insert('orders', **kwargs)
Exemplo n.º 6
0
def add_package(**kwargs):
    check_connect()
    return connect_mysql.insert('packages', **kwargs)
Exemplo n.º 7
0
def add_message_db(telegram, message_id):
    result = connect_mysql.insert('message', *["telegram", "branch"], **{'telegram': telegram, 'message_id': message_id})
    return result
Exemplo n.º 8
0
def add_branches_db(telegram, branch):
    result = connect_mysql.insert('branches', *["telegram", "branch"], **{'telegram': telegram, 'branch': branch})
    return result