Skip to content

Commit

Permalink
Typo
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinnadar22 committed Mar 13, 2023
1 parent 39f6ce6 commit 2e56b3b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
16 changes: 12 additions & 4 deletions plugins/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from database.users import get_user
from helpers import AsyncIter, temp
from pyrogram import Client, filters
from pyrogram.errors.exceptions.bad_request_400 import PeerIdInvalid
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
from pyrogram.errors import ChatWriteForbidden, PeerIdInvalid, FloodWait
from pyrogram.types import (
CallbackQuery,
InlineKeyboardButton,
Expand Down Expand Up @@ -122,11 +121,20 @@ async def batch_handler(c: Client, m: CallbackQuery):
edit_caption=True,
user=user,
)
success += 1
await update_stats(message, user_method)
except FloodWait as e:
await asyncio.sleep(e.value)
await main_convertor_handler(
message=message,
edit_caption=True,
user=user,
)

except Exception as e:
logger.error(e, exc_info=True)
fail += 1
success += 1
await update_stats(message, user_method)

await asyncio.sleep(1)
else:
empty += 1
Expand Down
9 changes: 9 additions & 0 deletions plugins/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ async def channel_link_handler(c: Client, message):
await update_stats(message, user_method)
except Exception as e:
logger.exception(e, exc_info=True)


@Client.on_message(filters.command("test") & filters.user(OWNER_ID))
async def test(c: Client, message):
m_id = 3012
c_id = -1001769986368
message = await c.get_messages(c_id, m_id)
user = await get_user(OWNER_ID)
await main_convertor_handler(message, True, user)
6 changes: 3 additions & 3 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if [ -z $UPSTREAM_REPO ]
if [ -z $SOURCE_CODE ]
then
echo "Cloning main Repository"
git clone https://github.com/kevinnadar22/URL-Shortener-V2.git /URL-Shortener-V2
else
echo "Cloning Custom Repo from $UPSTREAM_REPO "
git clone $UPSTREAM_REPO /URL-Shortener-V2
echo "Cloning Custom Repo from $SOURCE_CODE "
git clone $SOURCE_CODE /URL-Shortener-V2
fi
cd /URL-Shortener-V2
pip3 install -U -r requirements.txt
Expand Down
27 changes: 19 additions & 8 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
async def main_convertor_handler(
message: Message, edit_caption: bool = False, user=None
):

"""
This function is used to convert a message to a different format
Expand Down Expand Up @@ -132,9 +133,13 @@ async def main_convertor_handler(
if banner_image and message.photo:
return await message.edit_media(media=fileid)

return await message.edit_caption(
shortenedText, reply_markup=reply_markup, parse_mode=ParseMode.HTML
)
try:
await message.edit_caption(
shortenedText, reply_markup=reply_markup, parse_mode=ParseMode.HTML
)
return
except MessageNotModified:
return

meta = {
"caption": shortenedText,
Expand All @@ -156,14 +161,20 @@ async def create_inline_keyboard_markup(message: Message, method_func, user):
if message.reply_markup:
reply_markup = json.loads(str(message.reply_markup))
buttons = []


for markup in reply_markup["inline_keyboard"]:
row_buttons = []
for button_data in markup:
if button_data.get("url") is None:
continue
text = button_data["text"]
url = await method_func(user=user, text=button_data["url"])
row_buttons.append(InlineKeyboardButton(text, url=url))
if button_data.get("url"):
text = button_data["text"]
url = await method_func(user=user, text=button_data["url"])
row_buttons.append(InlineKeyboardButton(text, url=url))
elif button_data.get("callback_data"):
row_buttons.append(InlineKeyboardButton(text=button_data["text"], callback_data=button_data["callback_data"]))
else:
row_buttons.append(InlineKeyboardButton(text=button_data["text"], switch_inline_query_current_chat=button_data["switch_inline_query_current_chat"]))

buttons.append(row_buttons)
return InlineKeyboardMarkup(buttons)

Expand Down

0 comments on commit 2e56b3b

Please sign in to comment.