mirror of
https://github.com/Araon/Meido.git
synced 2025-02-20 11:13:20 +08:00
POC complete
This commit is contained in:
parent
d04045c67d
commit
b5315145fc
33
bot/bot.py
33
bot/bot.py
@ -1,10 +1,14 @@
|
||||
from cgitb import text
|
||||
import logging
|
||||
import json
|
||||
from operator import truediv
|
||||
from time import time
|
||||
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
|
||||
from telegram.update import Update
|
||||
from botUtils import showhelp,parse_search_query,getalltsfiles
|
||||
import subprocess
|
||||
import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
|
||||
@ -19,7 +23,7 @@ API_TOKEN = configdata.get("bot_token")
|
||||
|
||||
|
||||
def start(update,context):
|
||||
update.message.reply_text("Hello there!")
|
||||
update.message.reply_text("Thanks for using Araon Bot(v:0.01)\nThis is a alpha built so expect delayed response and many bugs\nIf you spot any issue feel free to reach out")
|
||||
|
||||
|
||||
def help(update,context):
|
||||
@ -29,7 +33,6 @@ def help(update,context):
|
||||
|
||||
def search(update, context):
|
||||
logger.info('Search function is called!')
|
||||
|
||||
update.message.reply_text('Searching....')
|
||||
|
||||
def get(update, context):
|
||||
@ -42,13 +45,10 @@ def get(update, context):
|
||||
update.message.reply_text(f"Checking Internal Db\nAnime: {userdata.get('series')}\nSeason: {userdata.get('season_id')}\nEpisode: {userdata.get('episode_id')}")
|
||||
|
||||
download_status = subprocess.check_call("python downloaderService/main.py "+'"'+userdata.get('series')+'"'+ ' ' + userdata.get('episode_id') , shell=True)
|
||||
update.message.reply_text(f"{userdata.get('series')} - {userdata.get('episode_id')} Downloaded!")
|
||||
|
||||
update.message.reply_text(f"{userdata.get('series')} - {userdata.get('episode_id')} almost done downloading on the server side!")
|
||||
filepath = getalltsfiles()
|
||||
print("getalltsfiles: ",filepath)
|
||||
update.message.reply_text(f"{userdata.get('series')} - {userdata.get('episode_id')} Uploading Started!")
|
||||
#update.message.reply_text(f"{userdata.get('series')} - {userdata.get('episode_id')} Uploading Started!")
|
||||
upload_status = subprocess.check_call("python uploaderService/main.py " +'"'+filepath+'"'+ ' ' + str(chat_id) + ' ' + (userdata.get('series')+str(userdata.get('episode_id'))), shell=True)
|
||||
print(upload_status)
|
||||
|
||||
else:
|
||||
update.message.reply_text("Please refer to /help")
|
||||
@ -71,7 +71,7 @@ def check_document(update, context):
|
||||
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)
|
||||
context.bot.send_video(end_user_chat_id,file_id,supports_streaming=True,timeout=120)
|
||||
|
||||
|
||||
|
||||
@ -81,13 +81,25 @@ def debug_message(update, context):
|
||||
|
||||
update.message.reply_text(str(user_id))
|
||||
|
||||
def callback_minute(context):
|
||||
context.bot.send_message(chat_id = configdata.get('agent_user_id'), text = 'Heart_beat <3')
|
||||
|
||||
# def check_for_update():
|
||||
# logger.info('Checking Update for Animdl')
|
||||
# subprocess.check_call("python -m pip install git+https://www.github.com/justfoolingaround/animdl")
|
||||
|
||||
|
||||
def main():
|
||||
updater = Updater(token=API_TOKEN, use_context=True, request_kwargs={'read_timeout': 100, 'connect_timeout': 100})
|
||||
updater = Updater(token=API_TOKEN, use_context=True, request_kwargs={'read_timeout': 10, 'connect_timeout': 10})
|
||||
|
||||
job = updater.job_queue
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dp = updater.dispatcher
|
||||
|
||||
job.run_repeating(callback_minute, interval=60,first=10)
|
||||
#job.run_daily(check_for_update)
|
||||
|
||||
# on different commands - answer in Telegram
|
||||
dp.add_handler(CommandHandler("start", start))
|
||||
dp.add_handler(CommandHandler("help", help))
|
||||
@ -100,7 +112,8 @@ def main():
|
||||
|
||||
dp.add_error_handler(error)
|
||||
|
||||
updater.start_polling()
|
||||
|
||||
updater.start_polling(timeout=120)
|
||||
updater.idle()
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ example - /search Death Note
|
||||
import os
|
||||
|
||||
def showhelp():
|
||||
helpText = "Here are the following bot commands\n\n/get - will download the anime episode you wanted\nexample - /get Death note, s1, ep3\n\n/getadd - will provide all the episode of an anime in a given season\nexample - /getall Death Note, s1\n\n/search - will provide deatails about an anime\nexample - /search Death Note"
|
||||
helpText = "Here are the following bot commands\n\n/get - will download the anime episode you wanted(make sure you seperate the name and the season and ep with comma)\nexample - /get Death note, 1, 3\n\n/getall(still in development) - will provide all the episode of an anime in a given season\nexample - /getall Death Note, 1\n\n/search(still in development) - will provide deatails about an anime\nexample - /search Death Note"
|
||||
return helpText
|
||||
|
||||
def parse_search_query(raw_input):
|
||||
|
@ -24,6 +24,7 @@ def convert2mp4(infile, outfile):
|
||||
|
||||
subprocess.run(['ffmpeg','-i',infile,'-c:v','copy','-c:a','copy','-preset:v','ultrafast','-segment_list_flags','+live',outfile])
|
||||
|
||||
|
||||
def main(argv):
|
||||
search_query = argv[1]
|
||||
search_query_range = argv[2]
|
||||
|
@ -17,7 +17,10 @@ from telethon import TelegramClient
|
||||
from telethon.tl.types import DocumentAttributeVideo
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
with open('uploaderService/config/agentConfig.json', 'r') as config:
|
||||
configdata = json.load(config)
|
||||
@ -33,9 +36,9 @@ bot_name = configdata.get('bot_name')
|
||||
|
||||
|
||||
|
||||
def callback(current, total):
|
||||
async def callback(current, total):
|
||||
# for upload progression
|
||||
print('Uploaded: {:.2%}'.format(current / total))
|
||||
logger.info('Uploaded: {:.2%}'.format(current / total))
|
||||
|
||||
|
||||
'''
|
||||
@ -45,6 +48,7 @@ chat_id = this is the end user chat_id, sent over caption to bot, so it can pars
|
||||
object_id = an internal id used for mapping of file_id and filename stored in the server(for optimization).
|
||||
'''
|
||||
async def uploadVideo(bot_name,file_path,chat_id,object_id):
|
||||
logger.info('UploadVideo Called')
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user