Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## TgCore Changelog

### 1.0.97
* Added: `tg.request.execute.create()`
* Added: `tg.request.execute.run()`
* Added: `tg.request.execute.get()`
* Added: `tg.request.execute.delete()`
* Added: both `.done(ok=False, result=False)` and .`skip()`
### 1.0.94
* Added: `tg.services.carbon.create()`
* Added: `tg.services.screenshot.create()`
Expand Down
2 changes: 2 additions & 0 deletions tgcore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .chats import Chats
from .core import CoreBotAuth, MediaFactory
from .default import DefaultMethod
from .execute import Request
from .methods import Methods
from .monitors import UptimeRobot
from .platform import Platform
Expand Down Expand Up @@ -58,6 +59,7 @@ def __init__(
self.translate = CustomTranslate(self)
self.services = Services(self)
self.quotes = Quotes(self)
self.request = Request(self)
self.use = DefaultMethod(self)
self.platform = Platform(self)
self.media: MediaFactory = MediaFactory(self)
Expand Down
11 changes: 11 additions & 0 deletions tgcore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,17 @@ async def skip(self) -> Any:
return None
return _result["ok"]

async def done(self, ok=False, dot=False) -> Any:
_result = await self.execute()
if ok:
if not _result["ok"] or not _result["data"]:
return None
return _result["ok"]
elif dot:
return ResponseResult(self._client.to_obj(_result["data"]))
else:
return _result

async def json(self) -> Any:
return await self.execute()

Expand Down
52 changes: 52 additions & 0 deletions tgcore/execute/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2026 Randy W
# Licensed under the Apache License, Version 2.0

# Github Author: https://github.com/TeamKillerX/
# Code: @zxyeor

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

from ..core import RequestCall
from ..methods.base import BaseMethod


class Execute(BaseMethod):
def create(self, **kw):
return RequestCall(
self._client,
"POST",
"/api/v3/request",
kw
)

def run(self, **kw):
return RequestCall(
self._client,
"POST",
f"/api/v3/request/{request_id}/execute",
kw
)

def get(self, request_id: str):
return RequestCall(
self._client,
"GET",
f"/api/v3/request/{request_id}",
{}
)

def delete(self, request_id: str):
return RequestCall(
self._client,
"DELETE",
f"/api/v3/request/{request_id}",
{}
)

class Request:
def __init__(self, client):
self.execute = Execute(client)
Loading