start_chat.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:project 作者: swatishayna 项目源码 文件源码
def start_chat(spy):

    from globals import current_status_message
    error_message = None  # variable for storing error message

    print Fore.GREEN + "Authentication complete." + Fore.RESET + "\nWelcome " + spy.get_name() + "\n" + "age: ", spy.get_age(), "\nRating: ", spy.get_rating(), "\nOnline: ", spy.get_online();

    # displaying menu for user
    show_menu = True
    while show_menu:
            time.sleep(1)
            menu_choices = Fore.LIGHTMAGENTA_EX + "What do you want to do ?\n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 1.ADD A STATUS UPDATE \n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 2.ADD A FRIEND \n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 3.SEND A SECRET MESSAGE \n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 4.READ A SECRET MESSAGE \n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 5.READ CHATS FROM A USER \n" + Fore.RESET + \
                           Fore.LIGHTMAGENTA_EX + " 6.CLOSE APPLICATION \n  " + Fore.RESET
            result = int(raw_input(menu_choices))

            # validating user's input
            if result == 1:
                time.sleep(1)
                current_status_message = add_status(current_status_message)
                time.sleep(1)
                print 'your status has been updated to :\n', current_status_message

            elif result == 2:
                time.sleep(1)
                number_of_friends = add_friend()
                print 'You have %d friends' % number_of_friends
                show_friends()

            elif result == 3:
                time.sleep(1)
                send_message()
            elif result == 4:
                time.sleep(1)
                read_message()
            elif result == 5:
                time.sleep(1)
                read_chat_history()
            elif result == 6:
                show_menu = False
                time.sleep(1)
                print Fore.RED + "Application is closed now."
            else:
                print "WRONG CHOICE"  # exit from application
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号