Ejemplo n.º 1
0
def create_vpn_user(vpn_name='', duration=3600):
    #users = api(cmd='/ppp/secret/print')
    params = {'profile': 'default', 'service': 'pptp'}
    import generation_pass
    vpn_pass = generation_pass.create_password()
    print(vpn_name)
    if len(vpn_name) == 0:
        import generation_name2
        vpn_name = generation_name2.create_name()
    else:
        vpn_name = vpn_name

    params['name'] = vpn_name
    params['password'] = vpn_pass
    api(cmd='/ppp/secret/add', **params)
    #from create_database import add_user_in_database
    #add_user_in_database(vpn_name)
    from add_time import add_data2
    add_data2(vpn_name, duration)
    #date_create = a[0]
    #date_off = a[1]
    from create_database import add_user_in_database
    add_user_in_database(vpn_name, duration)
    '''
    from duration import date_off
    print(delta)
    date_off(delta)
    '''
    return params
Ejemplo n.º 2
0
def create_user(message):
    '''this function create new user vpn, set random name - cocteil
    and generation password. send it in chat'''
    au = whois(message.chat.username)
    #print('я твое имя', au)
    if au[0] == True and au[1] <= 1:
        text = message.text[7:]
        text = text.strip()
        from generation_name2 import create_name
        zero_name = create_name()
        #print('я голый текст')
        if text == None:
            duration = 3600
        elif text.isdigit() == True:
            #print('это же число!')
            if text == 0:
                duration = 3600
            else:
                duration = int(text) * 3600
        elif len(text) == 0:
            duration = 3600
        else:
            #print('не поверишь, но ты тут')
            #add create_mit_name
            from create_mit_name import create_mit_name
            #print('а я текст который прилетит',  text)
            row_name = create_mit_name(text)
            #print('я есть полученный текст в мит',  row_name)
            #print(type(row_name))

            duration = row_name[1]
            duration = int(duration)
            #print('я дуратион,',   duration,  'мой тип',  type(duration))
            zero_name = row_name[0]
            #print('я зеро нейм',  zero_name)
            bot.send_message(message.chat.id, 'пробуем принять имя')
            #exit()

        #zero_name = ''
        a = api_test3.create_vpn_user(zero_name, duration)
        b = a['name']
        b = str(b)
        #print('имя',  b)
        #print(type(b))
        c = a['password']
        c = str(c)
        #print(b)
        #print(c)
        d = 'логин ' + b + ' пароль ' + c
        bot.send_message(message.chat.id, d)
    else:
        bot.send_message(message.chat.id,
                         'что то не то с правами. не буду создавать')
        pass