Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
subinps committed Oct 29, 2021
1 parent 67a19b9 commit d9113c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
1 change: 1 addition & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def start(self):
await Media.ensure_indexes()
me = await self.get_me()
temp.ME = me.id
temp.U_NAME = me.username
self.username = '@' + me.username
print(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")

Expand Down
14 changes: 10 additions & 4 deletions plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from database.ia_filterdb import Media, get_file_details
from database.users_chats_db import db
from info import CHANNELS, ADMINS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION, LOG_CHANNEL, PICS
from utils import get_size, is_subscribed
from utils import get_size, is_subscribed, temp

logger = logging.getLogger(__name__)

Expand All @@ -19,7 +19,7 @@ async def start(client, message):
await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention))
if len(message.command) != 2:
buttons = [[
InlineKeyboardButton('➕ Add Me To Your Groups ➕', url='http://t.me/EvaMariaBot?startgroup=true')
InlineKeyboardButton('➕ Add Me To Your Groups ➕', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('🔍 Search', switch_inline_query_current_chat=''),
InlineKeyboardButton('🤖 Updates', url='https://t.me/EvaMariaUpdates')
Expand All @@ -43,8 +43,14 @@ async def start(client, message):
except ChatAdminRequired:
logger.error("Make sure Bot is admin in Forcesub channel")
return
btn = []
btn.append([InlineKeyboardButton("🤖 Join Updates Channel", url=invite_link.invite_link)])
btn = [
[
InlineKeyboardButton(
"🤖 Join Updates Channel", url=invite_link.invite_link
)
]
]

if message.command[1] != "subscribe":
btn.append([InlineKeyboardButton(" 🔄 Try Again", callback_data=f"checksub#{message.command[1]}")])
await client.send_message(
Expand Down
25 changes: 5 additions & 20 deletions plugins/pm_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
from pyrogram import Client, filters
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
from utils import get_size, is_subscribed, get_poster
from utils import get_size, is_subscribed, get_poster, temp
from database.users_chats_db import db
from database.ia_filterdb import Media, get_file_details, get_search_results
from database.filters_mdb import(
Expand All @@ -18,8 +18,7 @@
)

BUTTONS = {}
BOT = {}
ab = []


@Client.on_message(filters.group & filters.text)
async def give_filter(client,message):
Expand Down Expand Up @@ -316,22 +315,9 @@ async def cb_handler(client: Client, query: CallbackQuery):
if f_caption is None:
f_caption = f"{files.file_name}"

try:
username = ab[0]
except:
pass
try:
bot = await client.get_me()
username = bot.username
ab.append(username)
except FloodWait as e:
asyncio.sleep(e.x)
bot = await client.get_me()
username = bot.username
ab.append(username)
try:
if AUTH_CHANNEL and not await is_subscribed(client, query):
await query.answer(url=f"https://t.me/{username}?start={file_id}")
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
return
else:
await client.send_cached_media(
Expand All @@ -343,10 +329,9 @@ async def cb_handler(client: Client, query: CallbackQuery):
except UserIsBlocked:
await query.answer('Unblock the bot mahn !',show_alert = True)
except PeerIdInvalid:
await query.answer(url=f"https://t.me/{username}?start={file_id}")
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
except Exception as e:

await query.answer(url=f"https://t.me/{username}?start={file_id}")
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")

elif query.data.startswith("checksub"):
if AUTH_CHANNEL and not await is_subscribed(client, query):
Expand Down
1 change: 1 addition & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class temp(object):
CURRENT=int(os.environ.get("SKIP", 2))
CANCEL = False
MELCOW = {}
U_NAME = None

async def is_subscribed(bot, query):
try:
Expand Down

0 comments on commit d9113c6

Please sign in to comment.