made some minor changes

This commit is contained in:
araon 2022-03-09 22:01:36 +05:30
parent c98101f7bf
commit 65f0ba3e2e
6 changed files with 76 additions and 30 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ botConfig.json
agentConfig.json
images
*.mp4
dev
__pycache__

View File

@ -34,7 +34,6 @@ Zoro | 720p, 1080p | ✔️
- [ ] Add subscription feature
- [ ] Moar Bug fixes
- [ ] Add support for linux
- [ ] Change file path
#### Status
Still under development 🛠️

View File

@ -1,7 +1,6 @@
import logging
import json
from datetime import datetime
from turtle import up
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram.update import Update
from botUtils import showhelp,parse_search_query,getalltsfiles
@ -9,19 +8,23 @@ from database import getData, postData, updateData
import subprocess
import datetime
BOT_VERSION = 0.1
#enabling Logging
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
with open('bot/config/botConfig.json', 'r') as config:
try:
with open('bot/config/botConfig.json', 'w+') as config:
configdata = json.load(config)
except:
raise Exception('CONFIG FILE NOT FOUND!')
API_TOKEN = configdata.get("bot_token")
def start(update,context):
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")
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")
def help(update,context):
@ -30,15 +33,22 @@ def help(update,context):
def getanime(update, context):
'''
Fetches the anime file on the mongo db and then if not found,
downloads the anime using animeld
'''
logger.info('download function is called!')
chat_id = update.message.chat_id
rawUserInput = update.message.text
userInput = rawUserInput[10:]
if userInput and not userInput == " ":
userdata = parse_search_query(userInput)
update.message.reply_text(f"Checking Internal Db\nAnime: {userdata.get('series_name')}\nSeason: {userdata.get('season_id')}\nEpisode: {userdata.get('episode_id')}")
logger.info('search_in_mongodb:"%s"', userdata)
search_in_mongodb = userdata.pop('season_id')
anime_name = getData(search_in_mongodb)
if not anime_name:
@ -55,7 +65,7 @@ def getanime(update, context):
else:
update.message.reply_text("Please refer to /help")
update.message.reply_text(f"{userdata.get('series_name')} - {userdata.get('episode_id')} almost done downloading on the server side!")
update.message.reply_text(f"{userdata.get('series_name')} - {userdata.get('episode_id')} is done downloading on the server side!")
filepath = getalltsfiles()
upload_status = subprocess.check_call("python uploaderService/main.py " +'"'+filepath+'"'+ ' ' + str(chat_id) + ' ' + (userdata.get('series_name')+'-'+str(userdata.get('episode_id'))), shell=True)
@ -63,7 +73,7 @@ def getanime(update, context):
def error(update, context):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s" and "%s"', update, context.error, context )
update.message.reply_text("Something has went wrong!, Please retry :)")
update.message.reply_text("Something has went wrong!, Please retry")
def check_document(update, context):
'''
@ -92,6 +102,7 @@ def check_document(update, context):
logger.info(data2post)
post_data_to_mongo = postData(data2post)
logger.info(post_data_to_mongo)
#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,timeout=120)

View File

@ -1,6 +1,9 @@
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
MONGO_DB_URL = 'mongodb://localhost:27017/'
client = MongoClient(MONGO_DB_URL)
#database
db = client["animeDatabase"]

View File

@ -1,17 +1,42 @@
python-telegram-bot
telethon
cachetools
certifi
pyaes
pyasn1
pytz
pytz-deprecation-shim
rsa
six
tornado
tzdata
tzlocal
APScheduler
ffmpeg
Telethon
backports.zoneinfo
Package Version
--------------------- -----------
animdl 1.4.84
anitopy 2.1.0
anyio 3.5.0
APScheduler 3.6.3
backports.zoneinfo 0.2.1
cachetools 4.2.2
certifi 2021.10.8
charset-normalizer 2.0.12
click 8.0.4
comtypes 1.1.11
cssselect 1.1.0
ffmpeg 1.4
h11 0.12.0
httpcore 0.14.7
httpx 0.22.0
idna 3.3
lxml 4.8.0
multidict 6.0.2
pip 20.3.4
pkg-resources 0.0.0
pyaes 1.6.1
pyasn1 0.4.8
pycryptodomex 3.14.1
pymongo 4.0.2
python-telegram-bot 13.11
pytz 2021.3
pytz-deprecation-shim 0.1.0.post0
PyYAML 6.0
regex 2021.10.8
rfc3986 1.5.0
rsa 4.8
setuptools 44.1.1
six 1.16.0
sniffio 1.2.0
Telethon 1.24.0
tornado 6.1
tqdm 4.63.0
tzdata 2021.5
tzlocal 4.1
yarl 1.7.2

View File

@ -22,8 +22,12 @@ 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:
try:
with open('uploaderService/config/agentConfig.json', 'w+') as config:
configdata = json.load(config)
except:
raise Exception('CONFIG FILE NOT FOUND!')
entity = configdata.get('entity') #session name - it doesn't matter what
api_id = configdata.get('api_id')
@ -44,11 +48,13 @@ async def callback(current, total):
'''
bot_name = the actual bot name
file_path = where the file is downloaded
chat_id = this is the end user chat_id, sent over caption to bot, so it can parse and send it to the correct user
object_id = an internal id used for mapping of file_id and filename stored in the server(for optimization).
chat_id = this is the end user chat_id, sent over caption to bot,
so it can parse and send it to the correct user
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')
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