示例#1
0
def countUnreadMessages(chat_with: str) -> str:
    meta = {
        "method": "countUnreadMessages",
        "args": {
            "username": username,
            "chat_with": chat_with
        }
    }

    with messageClient.ApiClient() as api_client:
        # Create an instance of the API class
        api_instance = messageClient.MessagesApi(api_client)
        post_message_count_unread_messages = messageClient.PostMessageCountUnreadMessages(
            meta=meta
        )  # PostMessageCountUnreadMessages | Returns count of unread messages from specific user

        try:
            # Returns count of unread messages from specific user
            api_response = api_instance.returnscountofunreadmessagesfromspecificuser0(
                post_message_count_unread_messages).to_dict()
        except ApiException as e:
            print(
                "Exception when calling MessagesApi->returnscountofunreadmessagesfromspecificuser0: %s\n"
                % e)

    return api_response["meta"]["result"]["result"]
示例#2
0
def sendMessage(to: str):
    meta = {
        "method": "sendMessage",
        "args": {
            "sender": username,
            "to": to,
            "text": messagebox.get("1.0", "end")
        }
    }
    messagebox.delete("1.0", "end")

    with messageClient.ApiClient() as api_client:
        # Create an instance of the API class
        api_instance = messageClient.MessagesApi(api_client)
        post_message_send_message = messageClient.PostMessageSendMessage(
            meta=meta
        )  # PostMessageSendMessage | Sends message to specific chat application user

        try:
            # Sends message to specific chat application users
            api_instance.sendsmessagetospecificchatapplicationusers0(
                post_message_send_message)
        except ApiException as e:
            print(
                "Exception when calling MessagesApi->sendsmessagetospecificchatapplicationusers0: %s\n"
                % e)

        getChat()
示例#3
0
def printGlobalChat():
    with messageClient.ApiClient() as api_client:
        # Create an instance of the API class
        api_instance = messageClient.MessagesApi(api_client)

    try:
        # Gets all global chat messages
        api_response = api_instance.getsallglobalchatmessages0().to_dict()

        for message in api_response["meta"]["result"]["messages"]:
            if message["sender"] == username:
                chatWindow.insert(
                    "end", 4 * "\t" + "Napisałeś/łaś:\n" + 4 * "\t" +
                    message["text"] + "\n" + 4 * "\t" + "Wysłano: " +
                    message["sent"] + "\n\n")
            else:
                chatWindow.insert(
                    "end", message["sender"] + " napisał:\n" +
                    message["text"] + "\nWysłano: " + message["sent"] + "\n\n")
        chatWindow.yview("end")

    except ApiException as e:
        print(
            "Exception when calling MessagesApi->getsallglobalchatmessages0: %s\n"
            % e)
示例#4
0
def broadcastMessage():
    meta = {
        "method": "broadcastMessage",
        "args": {
            "sender": username,
            "text": messagebox.get("1.0", "end")
        }
    }
    messagebox.delete("1.0", "end")

    with messageClient.ApiClient() as api_client:
        # Create an instance of the API class
        api_instance = messageClient.MessagesApi(api_client)
        post_message_broadcast_message = messageClient.PostMessageBroadcastMessage(
            meta=meta
        )  # PostMessageBroadcastMessage | Sends message to all chat application users

        try:
            # Sends message to all chat application users
            api_instance.sendsmessagetoallchatapplicationusers0(
                post_message_broadcast_message)
        except ApiException as e:
            print(
                "Exception when calling MessagesApi->sendsmessagetoallchatapplicationusers0: %s\n"
                % e)

    return
示例#5
0
def printUserChat(chat_with: str):
    meta = {
        "method": "getChat",
        "args": {
            "username": username,
            "chat_with": chat_with
        }
    }

    with messageClient.ApiClient() as api_client:
        # Create an instance of the API class
        api_instance = messageClient.MessagesApi(api_client)
        post_message_get_chat = messageClient.PostMessageGetChat(
            meta=meta
        )  # PostMessageGetChat | Gets all messages sender to an user from specific user

        try:
            # Gets all messages sender to an user from specific user
            api_response = api_instance.getsallmessagessendertoanuserfromspecificuser0(
                post_message_get_chat).to_dict()

            for message in api_response["meta"]["result"]["messages"]:
                if message["sender"] == username:
                    if message["read"] == "":
                        readStatus = "Nie odczytano"
                    else:
                        readStatus = "Odczytano: " + message["read"]

                    chatWindow.insert(
                        "end", 4 * "\t" + "Napisałeś/łaś:\n" + 4 * "\t" +
                        message["text"] + "\n" + 4 * "\t" + readStatus +
                        "\n\n")
                else:
                    chatWindow.insert(
                        "end",
                        message["sender"] + " napisał:\n" + message["text"] +
                        "\nWysłano: " + message["sent"] + "\n\n")
            chatWindow.yview("end")

        except ApiException as e:
            print(
                "Exception when calling MessagesApi->getsallmessagessendertoanuserfromspecificuser0: %s\n"
                % e)