From cdf26f1425f416ecb5b19c575379ed36271e45d4 Mon Sep 17 00:00:00 2001 From: araon Date: Thu, 17 Mar 2022 18:39:30 +0530 Subject: [PATCH] minor fixes --- bot/bot.py | 7 +++++-- downloaderService/main.py | 2 ++ uploaderService/main.py | 15 +++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bot/bot.py b/bot/bot.py index f897dc7..34ec03c 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python3 + + import logging import json from datetime import datetime @@ -14,15 +17,15 @@ BOT_VERSION = 0.1 logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) +#fetching config file try: with open('bot/config/botConfig.json', 'w+') as config: configdata = json.load(config) -except: +except Exception as e: raise Exception('CONFIG FILE NOT FOUND!') API_TOKEN = configdata.get("bot_token") - def start(update,context): update.message.reply_text(f"Thanks for using Araon Bot({BOT_VERSION})\nThis is a alpha built so expect delayed response and many bugs\nIf you spot any issue feel free to reach out") diff --git a/downloaderService/main.py b/downloaderService/main.py index 0f6eeb6..c3caf31 100644 --- a/downloaderService/main.py +++ b/downloaderService/main.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import subprocess import os import sys diff --git a/uploaderService/main.py b/uploaderService/main.py index 276baf3..706fe39 100644 --- a/uploaderService/main.py +++ b/uploaderService/main.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 + #https://sudonull.com/post/62683-Telegram-bots-Uploading-files-larger-than-50mb ''' @@ -12,20 +13,21 @@ the agent must send the bot this file then the bot will receive own file_id for this file and will be able to dispose of it. ''' - from telethon import TelegramClient from telethon.tl.types import DocumentAttributeVideo import asyncio import json import logging +# basic logging logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) + try: with open('uploaderService/config/agentConfig.json', 'w+') as config: configdata = json.load(config) -except: +except Exception as e: raise Exception('CONFIG FILE NOT FOUND!') @@ -37,14 +39,10 @@ phone = configdata.get('phone') bot_name = configdata.get('bot_name') - - - async def callback(current, total): # for upload progression logger.info('Uploaded: {:.2%}'.format(current / total)) - ''' bot_name = the actual bot name file_path = where the file is downloaded @@ -57,7 +55,8 @@ async def uploadVideo(bot_name,file_path,chat_id,object_id): logger.info('video uploading initiated') async with TelegramClient(entity, api_id, api_hash) as client: if not await client.is_user_authorized(): - #await client.send_code_request(phone) #at the first start - uncomment, after authorization to avoid FloodWait I advise you to comment + #await client.send_code_request(phone) + '''at the first start - uncomment, after authorization to avoid FloodWait I advise you to comment''' await client.sign_in(phone, input('Enter code: ')) await client.send_file( str(bot_name), @@ -83,4 +82,4 @@ if __name__ == '__main__': import sys asyncio.run(main(sys.argv[0:])) -# python uploader.py rainfall.mp4 rainfall chat_id narutos1ep34 \ No newline at end of file +# python uploader.py \ No newline at end of file