You are giving very litlle information, for building something that looks very complex. I don’t think you are going to be able to get an answer on this one.
You question is quite vague and you do not show any code at all.
Please keep in mind … this forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.
What have you tried so far? We expect you to make an own attempt to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.
That’s a very very very challanging task for a beginner. And I wonder why you choose PowerShell for this task?! I’d think PowerShell is not the right tool for this task.
You would need a loop for that. But you should keep in mind that PowerShell is single threaded by default. You would need to switch between polling for new messages and listening to input from the local console.
I do not get this.
This question is way to broad to be answered in a forum like this.
I’d like to encourage you to pick a smaller challenge for the start than a complex application like a chat.
Regardless of that you may split your task into smaller parts and try to solve these smaller tasks once at a time.
Then … if you get stuck again you may come back here and ask a specific question about the code you wrote and does not what you want or does not work as you might expect.