You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
scripts: setup ksunextbot
This commit is contained in:
@@ -4,13 +4,11 @@ import sys
|
||||
from telethon import TelegramClient
|
||||
from telethon.tl.functions.help import GetConfigRequest
|
||||
|
||||
API_ID = 611335
|
||||
API_HASH = "d524b414d21f4d37f08684c1df41ac9c"
|
||||
|
||||
|
||||
# Environment Variables
|
||||
API_ID = os.environ.get("API_ID")
|
||||
API_HASH = os.environ.get("API_HASH")
|
||||
BOT_TOKEN = os.environ.get("BOT_TOKEN")
|
||||
CHAT_ID = os.environ.get("CHAT_ID")
|
||||
MESSAGE_THREAD_ID = os.environ.get("MESSAGE_THREAD_ID")
|
||||
COMMIT_URL = os.environ.get("COMMIT_URL")
|
||||
COMMIT_MESSAGE = os.environ.get("COMMIT_MESSAGE")
|
||||
RUN_URL = os.environ.get("RUN_URL")
|
||||
@@ -41,15 +39,13 @@ def get_caption():
|
||||
|
||||
|
||||
def check_environ():
|
||||
global CHAT_ID, MESSAGE_THREAD_ID
|
||||
global CHAT_ID
|
||||
if BOT_TOKEN is None:
|
||||
print("[-] Invalid BOT_TOKEN")
|
||||
exit(1)
|
||||
if CHAT_ID is None:
|
||||
print("[-] Invalid CHAT_ID")
|
||||
exit(1)
|
||||
else:
|
||||
CHAT_ID = int(CHAT_ID)
|
||||
if COMMIT_URL is None:
|
||||
print("[-] Invalid COMMIT_URL")
|
||||
exit(1)
|
||||
@@ -65,15 +61,10 @@ def check_environ():
|
||||
if VERSION is None:
|
||||
print("[-] Invalid VERSION")
|
||||
exit(1)
|
||||
if MESSAGE_THREAD_ID is None:
|
||||
print("[-] Invaild MESSAGE_THREAD_ID")
|
||||
exit(1)
|
||||
else:
|
||||
MESSAGE_THREAD_ID = int(MESSAGE_THREAD_ID)
|
||||
|
||||
|
||||
async def main():
|
||||
print("[+] Uploading to telegram")
|
||||
print("[+] Uploading to Telegram channel")
|
||||
check_environ()
|
||||
files = sys.argv[1:]
|
||||
print("[+] Files:", files)
|
||||
@@ -82,7 +73,7 @@ async def main():
|
||||
exit(1)
|
||||
print("[+] Logging in Telegram with bot")
|
||||
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||
session_dir = os.path.join(script_dir, "ksubot")
|
||||
session_dir = os.path.join(script_dir, "ksunextbot")
|
||||
async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot:
|
||||
caption = [""] * len(files)
|
||||
caption[-1] = get_caption()
|
||||
@@ -91,7 +82,12 @@ async def main():
|
||||
print(caption)
|
||||
print("---")
|
||||
print("[+] Sending")
|
||||
await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown")
|
||||
await bot.send_file(
|
||||
entity=CHAT_ID,
|
||||
file=files,
|
||||
caption=caption,
|
||||
parse_mode="markdown"
|
||||
)
|
||||
print("[+] Done!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
Reference in New Issue
Block a user