diff --git a/main.py b/main.py index f3532e8..0f542a4 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ from prompt_toolkit import print_formatted_text, HTML from websockets.exceptions import ConnectionClosedError from utils.helper_display import HelperDisplay +from requests import get USERS = {} @@ -28,6 +29,10 @@ def getallus(chatroom): return userlist +def ipaddress(): + return get('https://api64.ipify.org').text + + async def notify_mesej(message): if USERS: await asyncio.wait([user.send(message) for user in USERS]) @@ -40,11 +45,13 @@ def chk_username_presence(mesg_json): else: return False + async def send_chatroommembers_list(websoc): chatroom_id = USERS[websoc][1] users_list = "SNCTRYZERO" + sepr + "USERSLIST" + sepr + str(getallus(chatroom_id)) + sepr + chatroom_id await websoc.send(users_list) + async def chatroom(websocket, path): if not websocket in USERS: USERS[websocket] = "" @@ -107,9 +114,10 @@ def mainfunc(chatport, netprotc): elif netprotc == "ipprotv4": print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP version : 4")) netpdata = "0.0.0.0" + print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > IP address : " + ipaddress() + "")) servenow(netpdata, chatport) except OSError: - print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > The server could not be started up")) + print_formatted_text(HTML("[" + obtntime() + "] " + "SNCTRYZERO > The server could not be started")) if __name__ == "__main__":