From 985499abb62938f36740f8d102b597dff369b585 Mon Sep 17 00:00:00 2001 From: Ara0n Date: Tue, 11 Jan 2022 00:12:03 +0530 Subject: [PATCH] added video sending function from caption --- .gitignore | 3 ++- architechture.md | 2 +- bot/bot.py | 28 +++++++++++++++++----------- uploaderService/main.py | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b24a9c0..2f32dd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ botConfig.json *.session agentConfig.json -images \ No newline at end of file +images +test.mp4 diff --git a/architechture.md b/architechture.md index 04fb4dd..e5e9f39 100644 --- a/architechture.md +++ b/architechture.md @@ -14,7 +14,7 @@ - Episode_id # Happy Path -* /get and /getll +* /get and /getall 1. call a function videoFetcher(user_input). 2. the videoFetcher will check in mapping db if found return file_id 3. if the not found in mapping db will call downloadVideoService and it will return file_path,file_name,duration diff --git a/bot/bot.py b/bot/bot.py index b1a111d..425c964 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -16,7 +16,7 @@ API_TOKEN = configdata.get("bot_token") def start(update,context): - update.message.reply_text(str(update.message.chat_id) + ": " + update.message.text) + update.message.reply_text("Hello there!") def help(update,context): @@ -38,6 +38,7 @@ def get(update, context): userdata = parse_search_query(userInput) update.message.reply_text(f"Checking Internal Db\nAnime: {userdata.get('series')}\nSeason: {userdata.get('season_id')}\nEpisode: {userdata.get('episode_id')}") + else: update.message.reply_text("Please refer to /help") @@ -56,7 +57,6 @@ def getall(update, context): - def error(update, context): """Log Errors caused by Updates.""" logger.warning('Update "%s" caused error "%s"', update, context.error) @@ -67,19 +67,25 @@ def check_document(update, context): and returns a file id ''' logger.info('check_document function is called!') - # these are from the file sent from the agent - file_id = update.message.video.file_id - caption = update.message.caption + user_id = update.message.from_user.id - end_user_chat_id = caption.split(":")[1] - - #Keep in mind here i have to parse the chat_id from the caption above - update.message.send_document(end_user_chat_id,file_id) - + if user_id == configdata.get('agent_user_id'): + file_id = update.message.video.file_id + caption = update.message.caption + end_user_chat_id = caption.split(":")[0] + #Keep in mind here i have to parse the chat_id from the caption above + context.bot.send_video(end_user_chat_id,file_id,supports_streaming=True) + + def debug_message(update, context): logger.info('debug_message function is called!') - update.message.reply_text('up') + user_id = update.message.from_user.id + + update.message.reply_text(str(user_id)) + + + diff --git a/uploaderService/main.py b/uploaderService/main.py index 2981921..55d2fca 100644 --- a/uploaderService/main.py +++ b/uploaderService/main.py @@ -70,6 +70,6 @@ async def main(argv): if __name__ == '__main__': import sys - asyncio.run(main()) + asyncio.run(main(sys.argv[0:])) # python uploader.py rainfall.mp4 rainfall chat_id narutos1ep34 \ No newline at end of file