Skip to content

Commit

Permalink
Added cleandir option & some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Gorn authored Jul 21, 2021
1 parent fd8070d commit 9993b15
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Telegram RoBot to Upload manga/comic.

👉 Uploading from [supported resources](https://manga-py.com/manga-py/#resources-list) as PDF/ZIP/Folder (each chapter) | Uploaded as Zipfile

👉 `/cleandir` to clean your download directory if bot are stuck

#### How to use?!

* Send manga url from [supported resources](https://manga-py.com/manga-py/#resources-list), for url example [read this](#url-options-and-examples)
Expand All @@ -15,11 +17,11 @@ Telegram RoBot to Upload manga/comic.

#### URL options and examples

```https://komikid.com/manga/updater -s 5``` - will skip 5 chapters and start from chapter 6-end
`https://komikid.com/manga/updater -s 5` - will skip 5 chapters and start from chapter 6-end

```https://komikid.com/manga/updater -c 5``` - will start from chapter 1-5
`https://komikid.com/manga/updater -c 5` - will start from chapter 1-5

```https://komikid.com/manga/updater -s 5 -c 5``` - ```-s 5``` will skip 5 chapters and ```-c 5``` will start from chapter 6-10
`https://komikid.com/manga/updater -s 5 -c 5` - `-s 5` will skip 5 chapters and `-c 5` will start from chapter 6-10

for more help, [read this](https://github.com/manga-py/manga-py#downloading-manga)

Expand Down
36 changes: 15 additions & 21 deletions plugins/commands.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import os, shutil
from pyrogram import Client, filters
from pyrogram.types.bots_and_keyboards import InlineKeyboardButton, InlineKeyboardMarkup
from pyrogram.types.bots_and_keyboards import InlineKeyboardMarkup
from translation import Translation


@Client.on_message(filters.private & filters.command('start'))
def _start(bot, update):
bot.send_message(
chat_id=update.chat.id,
text=Translation.START_TEXT.format(str(update.from_user.first_name)),
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"Source", url="https://github.com/X-Gorn/MangaLoader"
),
InlineKeyboardButton("Project Channel", url="https://t.me/xTeamBots"),
],
[InlineKeyboardButton("Author", url="https://t.me/xgorn")],
]
),
reply_to_message_id=update.message_id
update.reply_text(
Translation.START_TEXT.format(str(update.from_user.first_name)), reply_markup=InlineKeyboardMarkup(Translation.start_buttons)
)


@Client.on_message(filters.private & filters.command('help'))
def _help(bot, update):
bot.send_message(
chat_id=update.chat.id,
text=Translation.HELP_TEXT,
reply_to_message_id=update.message_id
)
update.reply_text(Translation.HELP_TEXT)


@Client.on_message(filters.private & filters.command('cleandir'))
def _cleandir(bot, update):
dirx = './Manga/'
if os.path.isdir(dirx):
shutil.rmtree(dirx)
update.reply_text(Translation.CLEANDIR_SUCCESS)
else:
update.reply_text(Translation.CLEANDIR_UNSUCCESS)
9 changes: 2 additions & 7 deletions plugins/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@


@Client.on_message(filters.private & filters.text)
async def download(bot, update):
def download(bot, update):
if update.from_user.id != Config.OWNER_ID:
return
url = update.text
if check_url(url):
pass
else:
return
await bot.send_message(
chat_id=update.chat.id,
text=Translation.UPLOAD,
reply_markup=InlineKeyboardMarkup(Translation.upload_buttons),
reply_to_message_id=update.message_id
)
update.reply_text(Translation.UPLOAD, quote=True, reply_markup=InlineKeyboardMarkup(Translation.upload_buttons))
22 changes: 16 additions & 6 deletions translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@


class Translation(object):
START_TEXT = "Hi {},\nI'm MangaLoader!\nYou can upload any manga to Telegram as a Zipfile!\n\n/help for more details!"
HELP_TEXT = "How to use MangaLoader?!\n\n1. Sent Manga URL.\n2. Choose subdir option.\n3. Wait a few seconds and i will send your archived document\n\nIf bot didn't respond, contact @xgorn"
UPLOAD = "Choose subdirs option (will uploaded as a Zipfile."
START_TEXT = "Hi {},\nI'm MangaLoader!\nYou can upload any manga to Telegram as Zipfile!\n\n/help for more details!"
HELP_TEXT = "How to use MangaLoader?!\n\n1. Send manga url from [supported resources](https://github.com/X-Gorn/MangaLoader/tree/cleandir#url-options-and-examples)\n2. Choose subdir option. (will uploaded as Zipfile)\n3. Wait a few minutes and you will receive your archived manga\n\nIf bot didn't respond, contact @xgorn"
UPLOAD = 'Choose subdirs option. (will uploaded as Zipfile)'
CLEANDIR_SUCCESS = 'Successfully cleaned your download dir, now you can sent another link'
CLEANDIR_UNSUCCESS = 'Your download dir are empty, use this command only if your bot are stuck'

upload_buttons=[
[
InlineKeyboardButton("as PDF", callback_data="pdf"),
InlineKeyboardButton("as ZIP", callback_data="zip"),
InlineKeyboardButton('as PDF', callback_data='pdf'),
InlineKeyboardButton('as ZIP', callback_data='zip'),
],
[InlineKeyboardButton("as Folder", callback_data="folder")],
[InlineKeyboardButton('as Folder', callback_data='folder')],
]

start_buttons=[
[
InlineKeyboardButton('Source', url='https://github.com/X-Gorn/MangaLoader'),
InlineKeyboardButton('Project Channel', url='https://t.me/xTeamBots'),
],
[InlineKeyboardButton('Author', url='https://t.me/xgorn')],
]

0 comments on commit 9993b15

Please sign in to comment.