omecli 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
client/__init__.py ADDED
File without changes
client/main.py ADDED
@@ -0,0 +1,301 @@
1
+ try:
2
+ from client.pages.home import render_home
3
+ from client.pages.room import render_room
4
+ from client.pages.about import render_about
5
+ from client.pages.settings import render_settings
6
+ from client.video.engine import VideoEngine
7
+ except ImportError:
8
+ from pages.home import render_home
9
+ from pages.room import render_room
10
+ from pages.about import render_about
11
+ from pages.settings import render_settings
12
+ from video.engine import VideoEngine
13
+ from rich.console import Console
14
+ from prompt_toolkit import Application
15
+ from prompt_toolkit.key_binding import KeyBindings
16
+ from prompt_toolkit.layout import Layout
17
+ from prompt_toolkit.layout.containers import Window
18
+ from prompt_toolkit.layout.controls import FormattedTextControl
19
+ from prompt_toolkit.styles import Style as PTStyle
20
+ from prompt_toolkit.formatted_text import ANSI
21
+ from prompt_toolkit.widgets import TextArea
22
+ from prompt_toolkit.layout.containers import Window, HSplit, ConditionalContainer
23
+ from prompt_toolkit.filters import Condition
24
+ import shutil
25
+ import asyncio
26
+ import websockets
27
+ import json
28
+ import datetime
29
+ import os
30
+
31
+ apiUrl = "wss://omecli.sakxem.xyz"
32
+ configFile = "config.json"
33
+
34
+ bindings = KeyBindings()
35
+ videoEngine = VideoEngine()
36
+
37
+ style = PTStyle.from_dict({
38
+ "selected": "fg:#FFFFFF bg:#123D2A bold",
39
+ "normal": "fg:#FFFFFF"
40
+ })
41
+
42
+ selected = 0
43
+ selectedSetting = 0
44
+ current_page = "menu"
45
+ messages = []
46
+ websocketConnection = None
47
+ strangerFrame = "Waiting for stranger video..."
48
+
49
+ defSettings = {
50
+ "theme": "Dark Mode",
51
+ "anon_display": True,
52
+ "save_history": False
53
+ }
54
+
55
+ def loadSettings():
56
+ if os.path.exists(configFile):
57
+ try:
58
+ with open(configFile, "r", encoding="utf-8") as f:
59
+ saved = json.load(f)
60
+ return {**defSettings, **saved}
61
+ except Exception:
62
+ pass
63
+ return defSettings.copy()
64
+
65
+ def saveSettings():
66
+ try:
67
+ with open(configFile, "w", encoding="utf-8") as f:
68
+ json.dump(appSettings, f, indent=4)
69
+ except Exception:
70
+ pass
71
+
72
+ appSettings = loadSettings()
73
+
74
+
75
+ async def connectToServer():
76
+ global websocketConnection, strangerFrame
77
+ try:
78
+ async with websockets.connect(apiUrl) as websocket:
79
+ websocketConnection = websocket
80
+ app.invalidate()
81
+
82
+ async for rawMessage in websocket:
83
+ data = json.loads(rawMessage)
84
+ msgType = data.get("type")
85
+
86
+ if msgType == "status":
87
+ messages.append(data.get("message"))
88
+ elif msgType == "message":
89
+ messages.append(f"Stranger: {data.get('text')}")
90
+ elif msgType == "video":
91
+ strangerFrame = data.get("frame", "")
92
+ app.invalidate()
93
+
94
+ except (websockets.exceptions.ConnectionClosed, ConnectionRefusedError):
95
+ messages.append("Connection to server lost")
96
+ websocketConnection = None
97
+ app.invalidate()
98
+
99
+ async def videoStreamLoop():
100
+ global websocketConnection
101
+ while True:
102
+ if current_page == "room" and websocketConnection:
103
+ try:
104
+ terminalWidth = shutil.get_terminal_size().columns
105
+ panelInnerWidth = max(20, ((terminalWidth - 2) // 2) - 6)
106
+ frame = videoEngine.get_ascii_frame(targetWidth=panelInnerWidth)
107
+
108
+ await websocketConnection.send(json.dumps({
109
+ "type" : "video",
110
+ "frame" : frame
111
+ }))
112
+ except Exception:
113
+ pass
114
+ await asyncio.sleep(1 / 15)
115
+
116
+ def send_message(buffer):
117
+ global websocketConnection
118
+ text = buffer.text.strip()
119
+ if text:
120
+ if text.lower() == "/next":
121
+ messages.append("You skipped the stranger")
122
+ if websocketConnection:
123
+ asyncio.create_task(websocketConnection.send(json.dumps({
124
+ "type" : "skip"
125
+ })))
126
+ else:
127
+ messages.append(f"You: {text}")
128
+ if websocketConnection:
129
+ asyncio.create_task(websocketConnection.send(json.dumps({
130
+ "type" : "message",
131
+ "text" : text
132
+ })))
133
+ buffer.text = ""
134
+ app.invalidate()
135
+
136
+ def getDynamicStyle():
137
+ if appSettings.get("theme") == "Cyber Green":
138
+ return PTStyle.from_dict({
139
+ "selected" : "fg:#000000 bg:#00FF66 bold",
140
+ "normal" : "fg:#00FF66"
141
+ })
142
+ elif appSettings.get("theme") == "Amber Retro":
143
+ return PTStyle.from_dict({
144
+ "selected" : "fg:#000000 bg:#FFB000 bold",
145
+ "normal" : "fg:#FFB000"
146
+ })
147
+ elif appSettings.get("theme") == "Synthwave":
148
+ return PTStyle.from_dict({
149
+ "selected" : "fg:#FFFFFF bg:#FF007F bold",
150
+ "normal" : "fg:#FF007F"
151
+ })
152
+ elif appSettings.get("theme") == "Dracula":
153
+ return PTStyle.from_dict({
154
+ "selected" : "fg:#F8F8F2 bg:#BD93F9 bold",
155
+ "normal" : "fg:#8D93F9"
156
+ })
157
+ else:
158
+ return PTStyle.from_dict({
159
+ "selected" : "fg:#FFFFFF bg:#123D2A bold",
160
+ "normal" : "fg:#FFFFFF"
161
+ })
162
+
163
+ def saveChatHistory():
164
+ if appSettings.get("save_history") and messages:
165
+ timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
166
+ filename = f"chat_history_{timestamp}.txt"
167
+ try:
168
+ with open(filename, "w", encoding="utf-8") as f:
169
+ f.write("\n".join(messages))
170
+ messages.append(f"History saved to {filename}")
171
+ except Exception:
172
+ pass
173
+
174
+
175
+ message_input = TextArea(
176
+ height=1,
177
+ prompt="You: ",
178
+ style="class:input-field",
179
+ multiline=False,
180
+ wrap_lines=False,
181
+ accept_handler=send_message
182
+ )
183
+
184
+ def get_page():
185
+ if current_page == "menu":
186
+ return render_home(selected, appSettings)
187
+ elif current_page == "room":
188
+ terminalWidth = shutil.get_terminal_size().columns
189
+ panelInnerWidth = max(20, ((terminalWidth - 2) // 2) - 6)
190
+ yourframe = videoEngine.get_ascii_frame(targetWidth=panelInnerWidth)
191
+ return render_room(messages, yourFrame=yourframe, strangerFrame=strangerFrame, appSettings=appSettings)
192
+ elif current_page == "about":
193
+ return render_about(appSettings)
194
+ elif current_page == "settings":
195
+ return render_settings(selectedSetting, appSettings)
196
+
197
+ @bindings.add("up")
198
+ def move_up(event):
199
+ global selected, selectedSetting
200
+ if current_page == "menu":
201
+ selected = 3 if selected == 0 else selected - 1
202
+ elif current_page == "settings":
203
+ selectedSetting = 3 if selectedSetting == 0 else selectedSetting - 1
204
+ event.app.invalidate()
205
+
206
+ @bindings.add("down")
207
+ def move_down(event):
208
+ global selected, selectedSetting
209
+ if current_page == "menu":
210
+ selected = 0 if selected == 3 else selected + 1
211
+ elif current_page == "settings":
212
+ selectedSetting = 0 if selectedSetting == 3 else selectedSetting + 1
213
+ event.app.invalidate()
214
+
215
+ @bindings.add("enter",
216
+ filter=Condition(lambda: current_page in ("menu", "settings"))
217
+ )
218
+ def handle_enter(event):
219
+ global current_page, selectedSetting
220
+ if current_page == "menu":
221
+ if selected == 0:
222
+ current_page = "room"
223
+ messages.clear()
224
+ messages.append("Connecting to server ...")
225
+ asyncio.create_task(connectToServer())
226
+ event.app.layout.focus(message_input.window)
227
+ elif selected == 1:
228
+ current_page = "about"
229
+ elif selected == 2:
230
+ selectedSetting = 0
231
+ current_page = "settings"
232
+ elif selected == 3:
233
+ event.app.exit()
234
+ return
235
+ elif current_page == "settings":
236
+ if selectedSetting == 0:
237
+ themes = ["Dark Mode", "Cyber Green", "Amber Retro", "Synthwave", "Dracula"]
238
+ currentTheme = appSettings["theme"]
239
+ nextIndex = (themes.index(currentTheme) + 1) % len(themes)
240
+ appSettings["theme"] = themes[nextIndex]
241
+ app.style = getDynamicStyle()
242
+ saveSettings()
243
+ elif selectedSetting == 1:
244
+ appSettings['anon_display'] = not appSettings['anon_display']
245
+ saveSettings()
246
+ elif selectedSetting == 2:
247
+ appSettings['save_history'] = not appSettings['save_history']
248
+ saveSettings()
249
+ elif selectedSetting == 3:
250
+ current_page = "menu"
251
+ event.app.invalidate()
252
+
253
+ @bindings.add("escape")
254
+ def go_back(event):
255
+ global current_page, websocketConnection
256
+ if current_page != "menu":
257
+ if current_page == "room":
258
+ saveChatHistory()
259
+ videoEngine.stop()
260
+ if websocketConnection:
261
+ asyncio.create_task(websocketConnection.close())
262
+ websocketConnection = None
263
+ current_page = "menu"
264
+ event.app.invalidate()
265
+
266
+ app = Application(
267
+ layout=Layout(
268
+ HSplit([
269
+ Window(
270
+ FormattedTextControl(get_page),
271
+ dont_extend_height=True
272
+ ),
273
+ ConditionalContainer(
274
+ content=message_input,
275
+ filter=Condition(lambda: current_page == "room")
276
+ )
277
+ ])
278
+ ),
279
+ key_bindings=bindings,
280
+ style=style,
281
+ full_screen=True,
282
+ erase_when_done=True
283
+ )
284
+
285
+ async def videoLoop():
286
+ while True:
287
+ if current_page == "room":
288
+ app.invalidate()
289
+ await asyncio.sleep(1 / 15)
290
+
291
+ async def main():
292
+ asyncio.create_task(videoLoop())
293
+ asyncio.create_task(videoStreamLoop())
294
+ await app.run_async()
295
+ videoEngine.stop()
296
+
297
+ def run():
298
+ asyncio.run(main())
299
+
300
+ if __name__ == "__main__":
301
+ run()
File without changes
client/pages/about.py ADDED
@@ -0,0 +1,80 @@
1
+ from rich.console import Console, Group
2
+ from rich.text import Text
3
+ from rich.align import Align
4
+ from rich.panel import Panel
5
+ from rich import box
6
+ import shutil
7
+
8
+ from io import StringIO
9
+ from prompt_toolkit.formatted_text import ANSI
10
+
11
+ def render_about(appSettings=None):
12
+ if appSettings is None:
13
+ appSettings = {"theme" : "Dark Mode"}
14
+
15
+ isCyber = appSettings.get("theme") == "Cyber Green"
16
+ isAmber = appSettings.get("theme") == "Amber Retro"
17
+ isSynthwave = appSettings.get("theme") == "Synthwave"
18
+ isDracula = appSettings.get("theme") == "Dracula"
19
+
20
+ if isCyber:
21
+ titleStyle="bold bright_green"
22
+ borderColor="bright_green"
23
+ featureColor = "bright_green"
24
+ elif isAmber:
25
+ titleStyle="bold bright_yellow"
26
+ borderColor="bright_yellow"
27
+ featureColor = "bright_yellow"
28
+ elif isSynthwave:
29
+ titleStyle="bold bright_magenta"
30
+ borderColor = "magenta"
31
+ featureColor = "bright_magenta"
32
+ elif isDracula:
33
+ titleStyle = "bold #BD93F9"
34
+ borderColor = "#8BE9FD"
35
+ featureColor = "#BD93F9"
36
+ else:
37
+ titleStyle="bold cyan"
38
+ borderColor="bright_blue"
39
+ featureColor="bright_green"
40
+
41
+ title_text = Text("About OmeCli", style=titleStyle)
42
+
43
+ body_text = Text()
44
+ body_text.append("OmeCli is a terminal based anonymous talk room, inspired by Omegle\nPurely built in Python.\n", style="bold white")
45
+ body_text.append("Key Features:\n", style=f"bold {featureColor}")
46
+ body_text.append("> Fast, lightweight and fully keyboard controllled\n",style="dim white")
47
+ body_text.append("> ASCII video engine and chat support\n", style="dim white")
48
+ body_text.append("> Responsive layout\n", style="dim white")
49
+ body_text.append("Press [ESC] to return to the main menu",style="bright yellow")
50
+
51
+ content = Group(
52
+ Align.center(title_text),
53
+ Align.center(body_text)
54
+ )
55
+
56
+ about_panel = Panel(
57
+ content,
58
+ title="OmeCli v0.0.1",
59
+ title_align="left",
60
+ border_style=borderColor,
61
+ box=box.SQUARE_DOUBLE_HEAD,
62
+ padding=(2,4),
63
+ expand=True
64
+ )
65
+
66
+ output = StringIO()
67
+
68
+ terminalWidth = shutil.get_terminal_size().columns
69
+ consoleWidth = max(40, terminalWidth - 2)
70
+
71
+ rich_console = Console(
72
+ file=output,
73
+ force_terminal=True,
74
+ color_system="truecolor",
75
+ width=consoleWidth
76
+ )
77
+
78
+ rich_console.print(about_panel)
79
+
80
+ return ANSI((output.getvalue()))
client/pages/home.py ADDED
@@ -0,0 +1,117 @@
1
+ from rich.console import Console, Group
2
+ from rich.text import Text
3
+ from rich.align import Align
4
+ from rich.panel import Panel
5
+ from rich.style import Style
6
+ from rich import box
7
+
8
+ from io import StringIO
9
+ from prompt_toolkit.formatted_text import ANSI
10
+
11
+ import shutil
12
+
13
+ def render_home(selected, appSettings=None):
14
+ if appSettings is None:
15
+ appSettings = {"theme":"Dark Mode"}
16
+ isCyber = appSettings.get("theme") == "Cyber Green"
17
+ isAmber = appSettings.get("theme") == "Amber Retro"
18
+ isSynthwave = appSettings.get("theme") == "Synthwave"
19
+ isDracula = appSettings.get("theme") == "Dracula"
20
+
21
+ if isCyber:
22
+ bannerColor = "bright_green"
23
+ selectedBg = "#00FF66"
24
+ selectedFg = "#000000"
25
+ elif isAmber:
26
+ bannerColor = "bright_yellow"
27
+ selectedBg = "#FFB000"
28
+ selectedFg = "#000000"
29
+ elif isSynthwave:
30
+ bannerColor = "bright_magenta"
31
+ selectedBg = "#FF007F"
32
+ selectedFg = "#FFFFFF"
33
+ elif isDracula:
34
+ bannerColor = "bright_cyan"
35
+ selectedBg = "#8D93F9"
36
+ selectedFg = "#282A36"
37
+ else:
38
+ bannerColor = "bright_cyan"
39
+ selectedBg = "#123D2A"
40
+ selectedFg = "#FFFFFF"
41
+
42
+
43
+ # Welcome Banner Part ;-;
44
+ welcomeText = Text()
45
+ versionText = Text()
46
+
47
+ welcomeText.append("Welcome to OmeCli\n", style="bold white")
48
+ welcomeText.append("""
49
+ ▄▄▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄
50
+ ▄███████▄ ████▄ ▄████ ███▀▀▀▀▀ ███▀▀▀▀▀ ███ ███
51
+ ███ ███ ███▀████▀███ ███▄▄ ███ ███ ███
52
+ ███▄▄▄███ ███ ▀▀ ███ ███ ███ ███ ███
53
+ ▀█████▀ ███ ███ ▀███████ ▀███████ ████████ ▄███▄ """,style=bannerColor)
54
+ versionText.append("Version 0.0.1", style="dim italic white")
55
+
56
+ groupedWelcome = Group(
57
+ Align.left(welcomeText),
58
+ Align.right(versionText)
59
+ )
60
+
61
+ welcomePanel = Panel(groupedWelcome, box=box.SQUARE_DOUBLE_HEAD, expand=True)
62
+
63
+ # Buttons
64
+
65
+ buttons_panels =[
66
+ Panel(
67
+ Align.center(Text("1. Find a Stranger", style="bold white")),
68
+ border_style="bright_green",
69
+ box=box.SQUARE_DOUBLE_HEAD,
70
+ padding=(0,4),
71
+ style =Style(bgcolor=selectedBg if selected == 0 else "#0D1117", color=selectedFg if selected == 0 else "white"),
72
+ expand=True
73
+ ),
74
+ Panel(
75
+ Align.center(Text("2. About OmeCli", style="bold white")),
76
+ border_style="bright_blue",
77
+ box=box.SQUARE_DOUBLE_HEAD,
78
+ padding=(0,4),
79
+ style=Style(bgcolor=selectedBg if selected == 1 else "#0D1117", color=selectedFg if selected == 1 else "white"),
80
+ expand=True
81
+ ),
82
+ Panel(
83
+ Align.center(Text("3. Settings", style="bold white")),
84
+ border_style="bright_white",
85
+ box=box.SQUARE_DOUBLE_HEAD,
86
+ padding=(0,4),
87
+ style=Style(bgcolor=selectedBg if selected == 2 else "#0D1117", color=selectedFg if selected == 2 else "white"),
88
+ expand=True
89
+ ),
90
+ Panel(
91
+ Align.center(Text("4. Quit OmeCli", style="bold white")),
92
+ border_style="bright_red",
93
+ box=box.SQUARE_DOUBLE_HEAD,
94
+ padding=(0,4),
95
+ style=Style(bgcolor=selectedBg if selected == 3 else "#0D1117", color=selectedFg if selected == 3 else "white"),
96
+ expand=True
97
+ )
98
+ ]
99
+
100
+ output = StringIO()
101
+
102
+ terminalWidth = shutil.get_terminal_size().columns
103
+ consoleWidth = max (40, terminalWidth - 2)
104
+ rich_console = Console(
105
+ file=output,
106
+ force_terminal=True,
107
+ color_system="truecolor",
108
+ width=consoleWidth
109
+ )
110
+
111
+ rich_console.print(welcomePanel)
112
+ rich_console.print()
113
+
114
+ for button in buttons_panels:
115
+ rich_console.print(button)
116
+
117
+ return ANSI(output.getvalue())
client/pages/room.py ADDED
@@ -0,0 +1,150 @@
1
+ from rich.console import Console, Group
2
+ from rich.text import Text
3
+ from rich.align import Align
4
+ from rich.panel import Panel
5
+ from rich.columns import Columns
6
+ from rich.table import Table
7
+ from rich import box
8
+
9
+ from io import StringIO
10
+ from prompt_toolkit.formatted_text import ANSI
11
+
12
+ import shutil
13
+
14
+ def render_room(messages, yourFrame="Starting Camera..", strangerFrame="Waiting for stranger...", appSettings=None):
15
+ if appSettings is None:
16
+ appSettings = {"theme":"Dark Mode", "anon_display": True}
17
+
18
+ isCyber = appSettings.get("theme") == "Cyber Green"
19
+ isAmber = appSettings.get("theme") == "Amber Retro"
20
+ isSynthwave = appSettings.get("theme") == "Synthwave"
21
+ isDracula = appSettings.get("theme") == "Dracula"
22
+
23
+ if isCyber:
24
+ headerStyle = "bold bright_green"
25
+ youStyle = "bright_green"
26
+ youBorder = "bright_green"
27
+ strangerStyle = "green"
28
+ strangerBorder = "green"
29
+ chatBorder = "bright_green"
30
+ elif isAmber:
31
+ headerStyle = "bold bright_yellow"
32
+ youStyle = "bright_yellow"
33
+ youBorder = "bright_yellow"
34
+ strangerStyle = "yellow"
35
+ strangerBorder = "yellow"
36
+ chatBorder = "bright_yellow"
37
+ elif isSynthwave:
38
+ headerStyle = "bold bright_magenta"
39
+ youStyle = "bright_magenta"
40
+ youBorder = "magenta"
41
+ strangerStyle = "pink1"
42
+ strangerBorder = "bright_magenta"
43
+ chatBorder = "magenta"
44
+ elif isDracula:
45
+ headerStyle = "bold #BD93F9"
46
+ youStyle = "#8BE9FD"
47
+ youBorder = "#BD93F9"
48
+ strangerStyle = "#50FA7B"
49
+ strangerBorder = "#8BE9FD"
50
+ chatBorder = "#BD93F9"
51
+ else:
52
+ headerStyle = "bold white"
53
+ youStyle = "bright_cyan"
54
+ youBorder = "bright_blue"
55
+ strangerStyle = "bright_green"
56
+ strangerBorder = "brighter_green"
57
+ chatBorder = "bright_white"
58
+
59
+ headerLeft = Text()
60
+ headerLeft.append("OMECLI", style=headerStyle)
61
+ headerRight = Text()
62
+ headerRight.append("Anonymous Talk" if appSettings.get("anon_display") else "Public Talk", style="dim white")
63
+
64
+ header = Columns(
65
+ [headerLeft,headerRight],
66
+ expand=True
67
+ )
68
+
69
+ youContent = Text(yourFrame, style=youStyle)
70
+
71
+ you = Panel(
72
+ Align.center(
73
+ youContent,
74
+ vertical = "middle"
75
+ ),
76
+ title="You",
77
+ border_style=youBorder,
78
+ box=box.SQUARE,
79
+ height=16,
80
+ expand=True
81
+ )
82
+
83
+ strangerContent = Text(strangerFrame, style=strangerStyle)
84
+ stranger = Panel(
85
+ Align.center(
86
+ strangerContent,
87
+ vertical = "middle"
88
+ ),
89
+ title="Stranger",
90
+ border_style=strangerBorder,
91
+ box=box.SQUARE,
92
+ height=16,
93
+ expand=True
94
+ )
95
+
96
+ terminalWidth = shutil.get_terminal_size().columns
97
+ consoleWidth = max(40, terminalWidth - 2)
98
+ leftWidth = consoleWidth // 2
99
+ rightWidth = consoleWidth - leftWidth
100
+
101
+ video_table = Table.grid(expand=True)
102
+ video_table.add_column(width=leftWidth)
103
+ video_table.add_column(width=rightWidth)
104
+ video_table.add_row(you, stranger)
105
+
106
+ chat_text = Text()
107
+
108
+ if messages:
109
+ maxMessages = 3
110
+ for message in messages[-maxMessages:]:
111
+ if message.startswith("You:"):
112
+ msgStyle = "bold bright_green" if isCyber else "bright_blue"
113
+ elif message.startswith("Stranger:"):
114
+ msgStyle = "green" if isCyber else "bright_green"
115
+ else:
116
+ msgStyle = "dim bright_green" if isCyber else "dim yellow"
117
+ chat_text.append(f"{message}\n", style=msgStyle)
118
+ else:
119
+ chat_text.append(
120
+ "Your conversation will appear here...",
121
+ style="dim white"
122
+ )
123
+
124
+ chat_history = Panel(
125
+ chat_text,
126
+ title="Conversation",
127
+ title_align="left",
128
+ border_style=chatBorder,
129
+ box=box.SQUARE,
130
+ height=7,
131
+ padding=(1,2),
132
+ expand=True
133
+ )
134
+
135
+ output = StringIO()
136
+
137
+ rich_console = Console(
138
+ file=output,
139
+ force_terminal=True,
140
+ color_system="truecolor",
141
+ width=consoleWidth
142
+ )
143
+
144
+ rich_console.print(header)
145
+ rich_console.print()
146
+ rich_console.print(video_table)
147
+ rich_console.print(chat_history)
148
+
149
+ return ANSI(output.getvalue())
150
+
@@ -0,0 +1,105 @@
1
+ from rich.console import Console, Group
2
+ from rich.text import Text
3
+ from rich.align import Align
4
+ from rich.panel import Panel
5
+ from rich.style import Style
6
+ from rich import box
7
+
8
+ import shutil
9
+
10
+ from io import StringIO
11
+ from prompt_toolkit.formatted_text import ANSI
12
+
13
+ def render_settings(selectedSetting, settings):
14
+ isCyber = settings.get("theme") == "Cyber Green"
15
+ isAmber = settings.get("theme") == "Retro Amber"
16
+ isSynthwave = settings.get("theme") == "Synthwave"
17
+ isDracula = settings.get("theme") == "Dracula"
18
+
19
+ if isCyber:
20
+ titleStyle = "bold bright_green"
21
+ outerBorder = "bright_green"
22
+ selectedBorder = "bright_green"
23
+ selectedBg = "#00FF66"
24
+ selectedFg = "#000000"
25
+ elif isAmber:
26
+ titleStyle = "bold bright_yellow"
27
+ outerBorder = "bright_yellow"
28
+ selectedBorder = "bright_yellow"
29
+ selectedBg = "#FF8000"
30
+ selectedFg = "#000000"
31
+ elif isSynthwave:
32
+ titleStyle = "bold bright_magenta"
33
+ outerBorder = "magenta"
34
+ selectedBorder = "bright_magenta"
35
+ selectedBg = "#FF007F"
36
+ selectedFg = "#FFFFFF"
37
+ elif isDracula:
38
+ titleStyle = "bold #BD93F9"
39
+ outerBorder = "#8BE9FD"
40
+ selectedBorder = "#BD93F9"
41
+ selectedBg = "#8D93F9"
42
+ selectedFg = "#282A36"
43
+ else:
44
+ titleStyle = "bold yellow"
45
+ outerBorder = "yellow"
46
+ selectedBorder = "bright_yellow"
47
+ selectedBg = "#3A3012"
48
+ selectedFg = "white"
49
+
50
+ titleText = Text("OmeCli Settings", style=titleStyle)
51
+
52
+ options = [
53
+ f"Theme: {settings['theme']}",
54
+ f"Anonymous Mode: {'Enabled' if settings['anon_display'] else 'Disabled'}",
55
+ f"Save Chat History: {'On' if settings['save_history'] else 'Off'}",
56
+ "Back to Main Menu"
57
+ ]
58
+
59
+ settingPanel = []
60
+
61
+ for i,opt in enumerate(options):
62
+ is_selected = (selectedSetting == i)
63
+ settingPanel.append(
64
+ Panel(
65
+ Align.center(Text(opt, style=f"bold {selectedFg if is_selected else 'white'}")),
66
+ border_style= selectedBorder if is_selected else "dim white",
67
+ box= box.SQUARE_DOUBLE_HEAD,
68
+ padding=(0,4),
69
+ style= Style(bgcolor=selectedBg if is_selected else "#0D1117"),
70
+ expand=True
71
+ )
72
+ )
73
+
74
+ contentGroup = Group(
75
+ Align.center(titleText),
76
+ Text(""),
77
+ *settingPanel
78
+ )
79
+
80
+ settingsPanel = Panel(
81
+ contentGroup,
82
+ title="Preferences",
83
+ title_align="left",
84
+ border_style=outerBorder,
85
+ box=box.SQUARE_DOUBLE_HEAD,
86
+ padding=(1,2),
87
+ expand=True
88
+ )
89
+
90
+ output = StringIO()
91
+
92
+
93
+ terminalWidth = shutil.get_terminal_size().columns
94
+ consoleWidth = max(40,terminalWidth -2)
95
+
96
+ rich_console = Console(
97
+ file=output,
98
+ force_terminal=True,
99
+ color_system="truecolor",
100
+ width=consoleWidth
101
+ )
102
+
103
+ rich_console.print(settingsPanel)
104
+
105
+ return ANSI(output.getvalue())
File without changes
client/video/engine.py ADDED
@@ -0,0 +1,39 @@
1
+ import cv2
2
+ import numpy as np
3
+
4
+ ASCII_CHARS = np.asarray(list(" .:-=+*#%@"))
5
+
6
+ class VideoEngine:
7
+ def __init__(self, cameraIndex=0):
8
+ self.cameraIndex = cameraIndex
9
+ self.cap = None
10
+
11
+ def start(self):
12
+ if self.cap is None or not self.cap.isOpened():
13
+ self.cap = cv2.VideoCapture(self.cameraIndex)
14
+
15
+ def stop(self):
16
+ if self.cap is not None and self.cap.isOpened():
17
+ self.cap.release()
18
+ self.cap = None
19
+
20
+ def get_ascii_frame(self, targetWidth=50):
21
+ if self.cap is None or not self.cap.isOpened():
22
+ self.start()
23
+
24
+ ret, frame = self.cap.read()
25
+ if not ret or frame is None:
26
+ return "Starting Camera"
27
+
28
+ frame = cv2.flip(frame, 1)
29
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
30
+
31
+ origHeight, origWidth = gray.shape
32
+ aspectRatio = origHeight / origWidth
33
+ targetHeight = max(5, int(targetWidth * aspectRatio * 0.5))
34
+
35
+ resized = cv2.resize(gray, (targetWidth, targetHeight), interpolation=cv2.INTER_AREA)
36
+ indices = (resized / 255.0 * (len(ASCII_CHARS) - 1)).astype(int)
37
+ asciiMatrix = ASCII_CHARS[indices]
38
+
39
+ return '\n'.join("".join(row) for row in asciiMatrix)
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: omecli
3
+ Version: 0.0.1
4
+ Summary: An anonymous Omegle clone made for the command line with real-time ASCII video streaming
5
+ Author-email: Sakxem <sakxem@duck.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: prompt-toolkit>=3.0.0
9
+ Requires-Dist: rich>=13.0.0
10
+ Requires-Dist: websockets>=10.0.0
11
+ Requires-Dist: opencv-python>=4.0.0
12
+
13
+ <h1 align="center">OmeCli</h1>
14
+
15
+ <p align="center">
16
+ <b>An anonymous Omegle clone made for the command line</b>
17
+ </p>
18
+
19
+ Well, most CLI apps out there are pretty bland, so I wanted to mix things up by building something that integrates OpenCV video processsing and a slick, modern terminal UI.
20
+ What's better than spending your time in terminal talking to complete strangers?
21
+
22
+ <p align="center">
23
+ <img alt="OmeCli Preview" src="https://i.ibb.co/5xSrWMKP/image.png" width="800">
24
+ </p>
25
+
26
+ ## Overview
27
+
28
+ OmeCli captures live frames straight from your webcam, converts them on the fly into realtime ASCII art, and streams everything seamlessly to the server using WebSockets. Zero clutter, full anonymity
29
+
30
+ ## Features
31
+
32
+ **ASCII Video Engine**: Captures webcam frames using OpenCV and renders them live into terminal ASCII art
33
+ **Built-In Themes**: Switch dynamically from one theme to another, anytime, anywhere, based of your mood
34
+ - **Dark Mode**: Clean default terminal look
35
+ - **Cyber Green**: Matrix inspired green look
36
+ - **Amber Retro**: Warm terminal look
37
+ - **Synthwave**: Neon pink cyberpunk look
38
+ - **Dracula**: Deep purple, cyan look
39
+ **Chat History Log**: Automatically saved chats from each conversations with timestamps
40
+ **Fully Keyboard Driven**: Smooth navigation with only keyboard
41
+
42
+ ## Project Structure
43
+
44
+ ```
45
+ OmeCli/
46
+ ├── client/
47
+ │ ├── pages/
48
+ │ │ ├── about.py # About page
49
+ │ │ ├── home.py # Main menu
50
+ │ │ ├── room.py # Talk/Chat room
51
+ │ │ └── settings.py # Theme switcher and user preferences
52
+ │ ├── video/
53
+ │ │ └── engine.py # CV2 ASCII Engine
54
+ │ ├── config.json # Persistent settings
55
+ │ └── main.py # Client initilization, handlers, websockets
56
+ ├── server/
57
+ │ └── server.py # Serverside websockets
58
+ ├── pyproject.toml # PyPI packaging & CLI entry point config
59
+ └── README.md # Project documentation
60
+ ```
61
+
62
+ ## Installation and Quick Start
63
+
64
+ **Install via PyPi**
65
+
66
+ ```
67
+ pip install omecli
68
+ omecli
69
+ ```
70
+
71
+ **Run Locally**
72
+
73
+ 1. Clone Repository
74
+ ```
75
+ git clone [https://github.com/yourusername/OmeCli.git](https://github.com/yourusername/OmeCli.git)
76
+ cd OmeCli
77
+ ```
78
+
79
+ 2. Install Dependencies
80
+
81
+ ```
82
+ pip install prompt-toolkit rich websockets opencv-python
83
+ ```
84
+
85
+ 3. Start the WebSocket Server
86
+
87
+ ```
88
+ python server/server.py
89
+ ```
90
+
91
+ 4. Launch the Client
92
+
93
+ ```
94
+ python client/main.py
95
+ ```
96
+
97
+ ## Controls and Commands
98
+
99
+ | Key / Command | Action |
100
+ | :--- | :--- |
101
+ | `↑` / `↓` | Navigate menus and settings |
102
+ | `Enter` | Select option / Send chat message |
103
+ | `Esc` | Return to main menu / Disconnect from room |
104
+ | `/next` | Skip current stranger and match with someone new |
105
+
106
+ ## Tech Stack
107
+ - **Terminal UI**: `prompt_toolkit` and `rich`
108
+ - **Networking**: `websockets`
109
+ - **Video Engine**: `OpenCV (cv2)`
110
+ - **Config Storage** : `JSON`
@@ -0,0 +1,14 @@
1
+ client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ client/main.py,sha256=FSC2IR-yZzfiR3CVniEeplhUT5fP6aUmPpI56iiV-bI,9977
3
+ client/pages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ client/pages/about.py,sha256=ufpj9dYGjLDvjiJQPrd0AavHIC7DAPAK5IG2nxeekPM,2555
5
+ client/pages/home.py,sha256=LSqMngFDL-5OEgG3Hb1eB2pXlB4F9PbmAflB0Lw1zaE,4237
6
+ client/pages/room.py,sha256=14UGu2I5iLQFt77RgZ0cb2p1rpgpJITtI1ugTb8kN_8,4472
7
+ client/pages/settings.py,sha256=na3xir3zHcUKGAPP7z7F542tcFiXnK6w4f6Cg59B5Ac,3117
8
+ client/video/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ client/video/engine.py,sha256=3TsaVJiex9VjFGqgr_HECNPXkukVlt-sJH6fdz7qxWg,1271
10
+ omecli-0.0.1.dist-info/METADATA,sha256=8LpoaWhNVx9y6ev7vyd30SVHJbCkW9jcbeaMCMxOMAM,3438
11
+ omecli-0.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
12
+ omecli-0.0.1.dist-info/entry_points.txt,sha256=nr3Abgf_vZcmfMXfgIIfLsvMhN9iPirC96z-nVQL9z0,43
13
+ omecli-0.0.1.dist-info/top_level.txt,sha256=DJiuN0ty6vOMYewH87cxtQ0LWVaJpE0bZ1Blm0e3RCE,7
14
+ omecli-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ omecli = client.main:run
@@ -0,0 +1 @@
1
+ client