forked from omg-xtao/Nagram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
141 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
git+https://github.com/KurimuzonAkuma/pyrogram | ||
PyroTgCrypto==1.2.6a0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import contextlib | ||
import subprocess | ||
from pathlib import Path | ||
from sys import argv | ||
|
||
from pyrogram import Client | ||
from pyrogram.types import InputMediaDocument | ||
|
||
api_id = 11535358 | ||
api_hash = "33d372962fadb01df47e6ceed4e33cd6" | ||
artifacts_path = Path("artifacts") | ||
test_version = argv[3] == "test" | ||
|
||
|
||
def find_apk(abi: str) -> Path: | ||
apks = list(artifacts_path.glob("*.apk")) | ||
for apk in apks: | ||
if abi in apk.name: | ||
return apk | ||
|
||
|
||
def get_thumb() -> str: | ||
return "TMessagesProj/src/main/" + "ic_launcher_nagram_round_blue-playstore.png" | ||
|
||
|
||
def get_caption() -> str: | ||
pre = "Test version, " if test_version else "" | ||
return pre + subprocess.check_output('git log -1 --pretty=format:"%s"').decode('utf-8') | ||
|
||
|
||
def get_document() -> list[InputMediaDocument]: | ||
return [ | ||
InputMediaDocument( | ||
media=str(find_apk("arm64-v8a")), | ||
thumb=get_thumb(), | ||
), | ||
InputMediaDocument( | ||
media=str(find_apk("armeabi-v7a")), | ||
thumb=get_thumb(), | ||
caption=get_caption(), | ||
), | ||
] | ||
|
||
|
||
def retry(func): | ||
async def wrapper(*args, **kwargs): | ||
for _ in range(3): | ||
try: | ||
return await func(*args, **kwargs) | ||
except Exception as e: | ||
print(e) | ||
|
||
return wrapper | ||
|
||
|
||
@retry | ||
async def send_to_channel(client: "Client", cid: str): | ||
with contextlib.suppress(ValueError): | ||
cid = int(cid) | ||
await client.send_media_group( | ||
cid, | ||
media=get_document(), | ||
) | ||
|
||
|
||
def get_client(bot_token: str): | ||
return Client( | ||
"helper_bot", | ||
api_id=api_id, | ||
api_hash=api_hash, | ||
bot_token=bot_token, | ||
) | ||
|
||
|
||
async def main(): | ||
bot_token = argv[1] | ||
chat_id = argv[2] | ||
client = get_client(bot_token) | ||
await client.start() | ||
await send_to_channel(client, chat_id) | ||
await client.log_out() | ||
|
||
|
||
if __name__ == "__main__": | ||
from asyncio import run | ||
|
||
run(main()) |
Oops, something went wrong.