示例#1
0
    def record_name(self):
        print(list_.random_return(self.ask_name_messages))
        name_ = input('Enter your full name: ')
        name_list = name_.split(' ')
        mn = ''
        if len(name_list) == 3:
            fn = name_list[0]
            mn = name_list[1]
            ln = name_list[2]
            print(f'Is this your name: {fn} {mn} {ln}')
        else:
            try:
                fn = name_list[0]
                ln = name_list[1]
                print(f'Is this your name: {fn} {ln}')
            except IndexError:
                ln = ''
                print(f'Is this your name: {fn} {ln}')

        if self.yess():
            self.main_user_name = f'{fn} {ln}'
            user = objects.User(1)
            user.set_name(fn, ln, mn)
            print('Do you have nickname which I can call  you?')
            if self.yess():
                user.set_username(input("Enter your nickname: "))
            else:
                user.set_username(fn + str(user.one_time_number))
        print('Do you want to see your information ?')
        if self.yess():
            p = objects.User(1)
            print(f'''Your information: {p.show_identity()}''')
示例#2
0
def client_handle(c_sock, c_addr, state):  # to be implemented
    c_sock.settimeout(TIMEOUT)
    # Read the first message from the client # and use this as the nickname/username

    nick = read_buf(c_sock)
    user = objects.User(nick, c_sock)
    users[nick] = user
    print('ALERT::User {} at {}'.format(nick, c_addr))

    users[nick].queue.append(('SERVER', nick + ' has joined'))

    print('Choose channel(s):')
    for key, value in channels.items():
        users[nick].queue.append(('SERVER', key))

    print(channels)
    while state.running and nick in users:
        # Read next message from client
        msg = read_buf(c_sock)

        # If msg is empty, try again
        if not msg:
            continue

        # First word in message is the receiver
        # Remaining words are message to send
        msg = msg.split(' ')
        receiver, msg = msg[0], ' '.join(msg[1:])
        command_handle(nick, user, msg)
    c_sock.close()
示例#3
0
def main():
    now_str = datetime.now().strftime('%Y-%m-%d-%H-%M')
    user = objects.User()
    game = objects.Game(user, 'Game-%s' % now_str)

    game.make_square_deck('../sample/deck_a')
    game.make_poker_deck('../sample/deck_b')
    game.make_booklet('../sample/booklet_a')
示例#4
0
 def add_email(self):
     p = objects.User(1)
     email = input('Enter your email address to add/change: ')
     p.set_email_phonenumber(email, p.phone_number)
     if p.phone_number == '\n':
         print('Do you wanna store phone number also?')
         if self.yess():
             p.set_email_phonenumber(email, input('Enter phone number: '))
示例#5
0
 def add_phone_number(self):
     p = objects.User(1)
     phone = input('Enter your phone number to add/change: ')
     p.set_email_phonenumber(p.email, phone)
     if p.email == '':
         print('Do you wanna store email also?')
         if self.yess():
             p.set_email_phonenumber(input('Enter email address: '),
                                     p.phone_number)
示例#6
0
    def second_step_processing(self, user_message):
        if (self.universal_true('data/strings/user_ask_cemail.txt')
                or self.universal_true('data/strings/user_ask_add_email.txt')):
            print('Do you want to change/add email ?')
            if self.yess():
                self.add_email()
            else:
                self.user_message = ''
            self.user_message = ''
        elif (self.universal_true('data/strings/delete information.txt')):
            print(
                "Sorry you cannot do that but you can change your information as much as you want !"
            )
            self.user_message = ''

        elif (self.universal_true('data/strings/user_ask_cphone.txt')
              or self.universal_true('data/strings/user_ask_add_phone.txt')):
            print('Do you want to change/add phone number ?')
            if self.yess():
                self.add_phone_number()
            else:
                self.user_message = ''
            self.user_message = ''
        elif (self.universal_true('data/strings/user_ask_cname.txt')):
            print('Do you want to change/add name ?')
            if self.yess():
                self.record_name()
            else:
                self.user_message = ''
            self.user_message = ''
        elif self.universal_true('data/strings/exit.txt'):
            print('Are you sure want to exit? ')
            if self.yess():
                exit()
            else:
                print('OK....I am glad')
                self.user_message = ''
            self.user_message = ''
        elif strings.string_in_string(
                strings.return_alphabet(user_message).lower(),
                list_.last_filter(self.ask_name_messages)):
            self.shortcut_message = (
                f'''My name is {self.name}, a chat bot.''')
            self.reply()
            p = objects.User(1)
            if p.first_name == '':
                print('Do you want to record your name?')
                if self.yess():
                    self.record_name()
            self.user_message = ''
        elif (strings.string_in_string(
                strings.return_alphabet(user_message).lower(),
                list_.last_filter(self.ask_user_name))
              or self.universal_true('data/strings/user_ask_email.txt')
              or self.universal_true('data/strings/user_ask_phone.txt')):
            self.show_user_identity()
            self.user_message = ''
示例#7
0
def update_project():
    j = request.get_json()
    usrJson = j['user']
    projectJson = j['project']
    newUser = obj.User(usrJson['id'], usrJson['name'], [])
    newProject = obj.Project(projectJson['id'], projectJson['name'],
                             projectJson['dueDate'], projectJson['mileStones'],
                             projectJson['completed'], projectJson['hidden'])
    fb.updateProject(newUser, newProject)
    return '', 204
示例#8
0
    def show_user_identity(self):
        p = objects.User(1)
        print(f'Your information: {p.first_name}')
        p.show_identity()
        if 'change' in self.user_message.split(' '):
            print(
                '''(Note: To change the information ask to change specefic information)
(Eg: To change name, Type: 'change name' or 'chnage my name' or something like this)
(Username cannot be changed, it is generated automatically after new name is given)'''
            )
示例#9
0
def update_user(online_users, user_name, time_stamp):

    if user_name in online_users.keys(
    ):  # key is in dict = user is known to us
        online_users[user_name].event_counter = online_users[
            user_name].event_counter + 1
        # get the value and increase
        online_users[user_name].last_active = time_stamp

    else:
        online_users[user_name] = objects.User(user_name, 0, time_stamp,
                                               1)  #create a new user

    return online_users
示例#10
0
def new_project():
    j = request.get_json()
    usrJson = j['user']
    projectJson = j['project']
    newUser = obj.User(usrJson['id'], usrJson['name'], [])
    pId = fb.idGenerator()
    newProject = obj.Project(pId, projectJson['name'], projectJson['dueDate'],
                             [], False, False)
    mileStones = projectJson['mileStones']
    for m in mileStones:
        mID = fb.idGenerator()
        ms = obj.MileStone(mID, m['name'], '', False)
        newProject.mileStones.append(ms)
    fb.addProject(newUser, newProject)
    return '', 204
示例#11
0
    def _html_lex_objector(self, html_data, *args, **kwargs):
        """Return appropriate LEXObject from html_data when possible."""
        soup = BeautifulSoup(html_data)

        # Check for form page
        title = soup.find('h4').string
        if title == 'Power Search':
            author_select = soup.find('select', {'id': 'i-author'})
            # options =
            desired_options = [
                option for option in author_select.findAll('option')
                if option.text == kwargs['user_name']
            ]
            for option in desired_options:
                user_json = {'user_name': option.text, 'id': option['value']}
                print user_json
                return objects.User(self, user_json)
示例#12
0
def read_Registered_UsersV2():   
	mRegistered_users=[]
	query= "sqlite3 /var/lib/mumble-server/mumble-server.sqlite 'SELECT name, lastchannel,last_active FROM users'"

	p = subprocess.Popen(query, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
	for line in p.stdout.readlines():		
		p.wait()	
		line=line[:-1]#cut \n at the end	
		
		
		line_array= str.split(line.decode('utf-8'),'|')#decode byte to str
		
		new_user = objects.User(line_array[0],line_array[1],line_array[2],0)
		
		mRegistered_users.append(new_user)		

	return mRegistered_users
示例#13
0
def main():
    import objects
    SPREADSHEET_ID = '1YKvM7jLvfbd4IGIYuyKHki_DES9LBhomOz_tdvuPbYo'
    sheets = GoogleSheets(SPREADSHEET_ID)

    RANGE_NAME = 'Users!A2:F'
    values = sheets.read(RANGE_NAME)
    users = {}
    if not values:
        print('No data found.')
    else:
        print('Name, Major:')
        for row in values:
            # Print columns A and E, which correspond to indices 0 and 4.
            user = objects.User(row)
            users[user.barcode] = user

    while (True):

        student = raw_input("Scan student barcode: ")
        if (student not in users):
            print("You are not a registered user.")
            continue

        laptop = raw_input("Scan laptop barcode (Optional):")
        mouse = raw_input("Scan mouse barcode (Optional):")
        ta = raw_input("Scan TA barcode: ")

        if (ta not in users):
            print("You are not a registered user.")
            continue

        ta_user = users[ta]
        if (ta_user.ta != 'yes'):
            print("You are not a TA.")
            continue

        RANGE_NAME = 'Sheet1!A2:D2'
        values = [
            [student, laptop, mouse, ta],
        ]

        sheets.write(RANGE_NAME, values)
示例#14
0
def new_user():
    j = request.get_json()
    newUser = obj.User(j['id'], j['name'], [])
    fb.addUser(newUser)
    return '', 204