Skip to content

Commit

Permalink
make dual buttons optional, fix anonymous admins
Browse files Browse the repository at this point in the history
  • Loading branch information
subinps committed Nov 1, 2021
1 parent 56bcc59 commit f69916e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 30 deletions.
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
"value": "True",
"required": false
},
"SINGLE_BUTTON": {
"description": "choose b/w single or double buttons https://github.com/EvamariaTG/EvaMaria/issues/22",
"value": "False",
"required": false
},
"P_TTTI_SHOW_OFF": {
"description": "Customize Result Buttons to Callback or Url by (True = url / False = callback)",
"value": "False",
Expand Down
1 change: 1 addition & 0 deletions info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
SUPPORT_CHAT = environ.get('SUPPORT_CHAT', 'TeamEvamaria')
P_TTTI_SHOW_OFF = eval((environ.get('P_TTTI_SHOW_OFF', "False")))
IMDB = eval((environ.get('IMDB', "True")))
SINGLE_BUTTON = eval((environ.get('SINGLE_BUTTON', "False")))
CUSTOM_FILE_CAPTION = environ.get("CUSTOM_FILE_CAPTION", None)
4 changes: 2 additions & 2 deletions plugins/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@Client.on_message((filters.private | filters.group) & filters.command('connect'))
async def addconnection(client,message):
userid = message.reply_to_message.from_user.id if message.from_user else None
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
Expand Down Expand Up @@ -76,7 +76,7 @@ async def addconnection(client,message):

@Client.on_message((filters.private | filters.group) & filters.command('disconnect'))
async def deleteconnection(client,message):
userid = message.reply_to_message.from_user.id if message.from_user else None
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
Expand Down
6 changes: 3 additions & 3 deletions plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def addfilter(client, message):
async def get_all(client, message):

chat_type = message.chat.type
userid = message.reply_to_message.from_user.id if message.from_user else None
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
if chat_type == "private":
Expand Down Expand Up @@ -182,7 +182,7 @@ async def get_all(client, message):

@Client.on_message(filters.command('del') & filters.incoming)
async def deletefilter(client, message):
userid = message.reply_to_message.from_user.id if message.from_user else None
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
Expand Down Expand Up @@ -233,7 +233,7 @@ async def deletefilter(client, message):

@Client.on_message(filters.command('delall') & filters.incoming)
async def delallconfirm(client, message):
userid = message.reply_to_message.from_user.id if message.from_user else None
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
Expand Down
69 changes: 44 additions & 25 deletions plugins/pm_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from Script import script
import pyrogram
from database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, make_inactive
from info import ADMINS, AUTH_CHANNEL, AUTH_USERS, CUSTOM_FILE_CAPTION, AUTH_GROUPS, P_TTTI_SHOW_OFF, IMDB
from info import ADMINS, AUTH_CHANNEL, AUTH_USERS, CUSTOM_FILE_CAPTION, AUTH_GROUPS, P_TTTI_SHOW_OFF, IMDB, SINGLE_BUTTON
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
from pyrogram import Client, filters
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
Expand Down Expand Up @@ -89,18 +89,28 @@ async def next_page(bot, query):

if not files:
return
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}", callback_data=f'files#{file.file_id}'
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
callback_data=f'files_#{file.file_id}',
),
if SINGLE_BUTTON:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'files#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}", callback_data=f'files#{file.file_id}'
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
callback_data=f'files_#{file.file_id}',
),
]
for file in files
]
for file in files
]

if 0 < offset <= 10:
off_set = 0
Expand Down Expand Up @@ -530,7 +540,6 @@ async def cb_handler(client: Client, query: CallbackQuery):
)



async def auto_filter(client, message):
if re.findall("((^\/|^,|^!|^\.|^[\U0001F600-\U000E007F]).*)", message.text):
return
Expand All @@ -540,19 +549,29 @@ async def auto_filter(client, message):
files, offset, total_results = await get_search_results(search.lower(), offset=0)
if not files:
return
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}",
callback_data=f'files#{file.file_id}',
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
callback_data=f'files_#{file.file_id}',
),
if SINGLE_BUTTON:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'files#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}",
callback_data=f'files#{file.file_id}',
),
InlineKeyboardButton(
text=f"{get_size(file.file_size)}",
callback_data=f'files_#{file.file_id}',
),
]
for file in files
]
for file in files
]

if offset != "":
key = f"{message.chat.id}-{message.message_id}"
Expand Down

0 comments on commit f69916e

Please sign in to comment.