Пример #1
0
def new_chat(usr,chat_no=''):
    try:
        while(1):
            print("\n")
            print("           New Chat          ")
            print("-----------------------------")
            print("\n")
            if(chat_no==''):
                chat_no=raw_input("Mobile Number")
                validate_destination.validate_destination(usr, chat_no)
            print_messages.print_messages(usr, str(chat_no))
            update_msg_status.update_msg_status(usr, chat_no)
            msg=checkdestination.check_destination(chat_no)
            print("Chat with ",msg.get_dis_name())
            msg=raw_input("Message (#Exit to exit) : ")
            if(msg.upper()=='#EXIT'):
                break
            check_mesglength.check_msglength(msg)
            insert_msg.insert_msg(str(usr.get_mobile_no()),str(chat_no), msg)
            print("Message Sent.")
    except DestNoSameException as e:
        print(e)
    except DestinationNotFoundException as e:
        print(e)
    except MsgLengthException as e:
        print(e)
Пример #2
0
def check_my_chats(usr):
    f=True
    while(f==True):
        sender=get_messages(usr)
        count=len(sender)
        li=[]
        ct=[]
        chat_no=''
        ''' for i in sender.keys():
            Sender Number/Name
            li.append(i)
            #Count of respective Unread messages
            ct.append(sender[i])'''

        for i in range(0,count):
            print (i)
            #msg=check_destination(li[i])
            #if(ct[i]==0):
             #   print(i+1,".",msg.get_dis_name())
            #else:
             #   print(i+1,".",msg.get_dis_name(),"[",ct[i],"]")
        print(sender)
        print((count+1),". New Chat")
        print((count+2),". Exit\n")
        choice=raw_input()
        try:
            choice=int(choice)
        except ValueError:
            raise InvalidChoiceException()
        if(choice<=count):
            chat_no=li[choice-1]
            new_chat(usr,chat_no)
            update_msg_status(usr,str(chat_no))
            check_my_chats(usr)
            f=False
        elif(choice==count+1):

            new_chat(usr)
            check_my_chats(usr)
            f=False

            update_msg_status(usr,str(chat_no))
        elif(choice==count+2):
            f=False
        else:
            print("Enter a valid option")