fix: eval on python 3.13 and include multi client script

This commit is contained in:
New-dev0
2025-05-31 23:23:48 +05:30
parent a98f052166
commit b1ee7d9733
4 changed files with 98 additions and 14 deletions

View File

@@ -113,12 +113,42 @@ Different ways to get your `SESSION`:
---
# Core Contributor Team
<table>
<tr>
<td align="center"><a href="https://github.com/xditya"><img src="https://avatars.githubusercontent.com/xditya" width="75px;" alt=""/><br/><sub><b>@xditya</b></sub></a></td>
<td align="center"><a href="https://github.com/1danish-00"><img src="https://avatars.githubusercontent.com/1danish-00" width="75px;" alt=""/><br/><sub><b>@1danish_00</b></sub></a></td>
<td align="center"><a href="https://github.com/buddhhu"><img src="https://avatars.githubusercontent.com/buddhhu" width="75px;" alt=""/><br/><sub><b>@buddhhu</b></sub></a></td>
<td align="center"><a href="https://github.com/TechiError"><img src="https://avatars.githubusercontent.com/TechiError" width="75px;" alt=""/><br/><sub><b>@TechiError</b></sub></a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/New-dev0"><img src="https://avatars.githubusercontent.com/New-dev0" width="75px;" alt=""/><br/><sub><b>@New-dev0</b></sub></a></td>
<td align="center"><a href="https://github.com/ArnabXD"><img src="https://avatars.githubusercontent.com/ArnabXD" width="75px;" alt=""/><br/><sub><b>@Arnab431</b></sub></a></td>
<td align="center"><a href="https://github.com/sppidy"><img src="https://avatars.githubusercontent.com/sppidy" width="75px;" alt=""/><br/><sub><b>@sppidy</b></sub></a></td>
<td align="center"><a href="https://github.com/Atul-Kumar-Jena"><img src="https://avatars.githubusercontent.com/Atul-kumar-Jena" width="75px;" alt=""/><br/><sub><b>@hellboi_atul</b></sub></a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/iAkashPattnaik"><img src="https://avatars.githubusercontent.com/iAkashPattnaik" width="75px;" alt=""/><br/><sub><b>@iAkashPattnaik</b></sub></a></td>
</tr>
</table>
## Contributors
<a href="https://github.com/TeamUltroid/Ultroid/graphs/contributors">
<img src="https://contrib.rocks/image?repo=TeamUltroid/Ultroid" />
</a>
We are highly grateful for all the contributions made by our amazing community! ❤️
---
# License
[![License](https://www.gnu.org/graphics/agplv3-155x51.png)](LICENSE)
Ultroid is licensed under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) v3 or later.
---
---
# Credits
* [![TeamUltroid-Devs](https://img.shields.io/static/v1?label=Teamultroid&message=devs&color=critical)](https://t.me/UltroidDevs)
* [Lonami](https://github.com/LonamiWebs/) for [Telethon.](https://github.com/LonamiWebs/Telethon)

39
multi_client.py Normal file
View File

@@ -0,0 +1,39 @@
import asyncio
import os
import subprocess
import sys
vars = ["API_ID", "API_HASH", "SESSION"]
def _check(z):
new = []
for var in vars:
ent = os.environ.get(var + z)
if not ent:
return False, new
new.append(ent)
return True, new
for z in range(5):
n = str(z + 1)
if z == 0:
z = ""
fine, out = _check(str(z))
if fine:
subprocess.Popen(
[sys.executable, "-m", "pyUltroid", out[0], out[1], out[2], out[3], out[4], n],
stdin=None,
stderr=None,
stdout=None,
cwd=None,
)
loop = asyncio.get_event_loop()
try:
loop.run_forever()
except Exception as er:
print(er)
finally:
loop.close()

View File

@@ -321,19 +321,34 @@ def _stringify(text=None, *args, **kwargs):
async def aexec(code, event):
exec(
(
"async def __aexec(e, client): "
+ "\n print = p = _stringify"
+ "\n message = event = e"
+ "\n u.r = reply = await event.get_reply_message()"
+ "\n chat = event.chat_id"
+ "\n u.lr = locals()"
)
+ "".join(f"\n {l}" for l in code.split("\n"))
# Create a dedicated namespace for execution
exec_globals = {
'print': _stringify,
'p': _stringify,
'message': event,
'event': event,
'client': event.client,
'reply': await event.get_reply_message(),
'chat': event.chat_id,
'u': u,
'__builtins__': __builtins__
}
# Format the async function definition
wrapped_code = (
'async def __aexec(e, client):\n' +
'\n'.join(f' {line}' for line in code.split('\n'))
)
return await locals()["__aexec"](event, event.client)
try:
# Execute the wrapped code in our custom namespace
exec(wrapped_code, exec_globals)
# Get the defined async function
func = exec_globals['__aexec']
# Execute it with proper parameters
return await func(event, event.client)
except Exception as e:
raise Exception(f"Failed to execute code: {str(e)}")
DUMMY_CPP = """#include <iostream>

View File

@@ -16,4 +16,4 @@ echo "
"
if [ -f .env ] ; then set -o allexport; source .env; set +o allexport ; fi
if [ $SESSION1 ] ; then wget https://gist.github.com/1Danish-00/6554f034549197e5824972b01f631e0c/raw/main.py && python3 main.py ; else python3 -m pyUltroid ; fi
if [ $SESSION1 ] ; then python3 multi_client.py ; else python3 -m pyUltroid ; fi