minor fixes

This commit is contained in:
araon 2022-03-17 18:39:30 +05:30
parent 65f0ba3e2e
commit cdf26f1425
3 changed files with 14 additions and 10 deletions

View File

@ -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")

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import subprocess
import os
import sys

View File

@ -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
# python uploader.py <file_path> <caption> <chat_id> <object_id>