Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Jul 12, 2024
1 parent 9fad7c8 commit 3e84a94
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 80 deletions.
6 changes: 3 additions & 3 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def stats(_, message):
@new_thread
async def start(client, message):
buttons = ButtonMaker()
reply_markup = buttons.menu(2)
reply_markup = buttons.column(2)
if len(message.command) > 1 and message.command[1] == "private":
await deleteMessage(message)
elif len(message.command) > 1 and len(message.command[1]) == 36:
Expand Down Expand Up @@ -185,7 +185,7 @@ def parseline(line):
endLine = "</pre>"
btn = ButtonMaker()
btn.callback('Close', f'aeon {user_id} close')
reply_message = await sendMessage(message, startLine + escape(Loglines) + endLine, btn.menu(1))
reply_message = await sendMessage(message, startLine + escape(Loglines) + endLine, btn.column(1))
await query.edit_message_reply_markup(None)
await deleteMessage(message)
await five_minute_del(reply_message)
Expand All @@ -202,7 +202,7 @@ def parseline(line):
async def log(_, message):
buttons = ButtonMaker()
buttons.callback('Log display', f'aeon {message.from_user.id} logdisplay')
reply_message = await sendFile(message, 'log.txt', buttons=buttons.menu(1))
reply_message = await sendFile(message, 'log.txt', buttons=buttons.column(1))
await deleteMessage(message)
await five_minute_del(reply_message)

Expand Down
6 changes: 3 additions & 3 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def bt_selection_buttons(id_):
buttons.callback("Pincode", f"btsel pin {gid} {pincode}")
buttons.callback("Cancel", f"btsel rm {gid} {id_}")
buttons.callback("Done Selecting", f"btsel done {gid} {id_}")
return buttons.menu(2)
return buttons.column(2)


async def get_telegraph_list(telegraph_content):
Expand All @@ -157,7 +157,7 @@ async def get_telegraph_list(telegraph_content):
buttons = ButtonMaker()
buttons.url("View", f"https://telegra.ph/{path[0]}")
buttons = extra_btns(buttons)
return buttons.menu(1)
return buttons.column(1)


def handleIndex(index, dic):
Expand Down Expand Up @@ -233,7 +233,7 @@ def get_readable_message():
buttons.callback("Prev", "status pre")
buttons.callback(f"{PAGE_NO}/{PAGES}", "status ref")
buttons.callback("Next", "status nex")
button = buttons.menu(3)
button = buttons.column(3)
msg += f"<b>• Tasks</b>: {tasks}{bmax_task}"
msg += f"\n<b>• Bot uptime</b>: {currentTime}"
msg += f"\n<b>• Free disk space</b>: {get_readable_file_size(disk_usage('/usr/src/app/downloads/').free)}"
Expand Down
8 changes: 4 additions & 4 deletions bot/helper/listeners/tasks_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
await sendMessage(self.botpmmsg, msg + lmsg + fmsg)
await deleteMessage(self.botpmmsg)
if self.isSuperGroup:
await sendMessage(self.message, f'{msg}<b>Files has been sent to your inbox</b>', inboxButton.menu(1))
await sendMessage(self.message, f'{msg}<b>Files has been sent to your inbox</b>', inboxButton.column(1))
else:
await deleteMessage(self.botpmmsg)
if self.seed:
Expand All @@ -402,12 +402,12 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
share_url += '/'
buttons.url('Index link', share_url)
buttons = extra_btns(buttons)
button = buttons.menu(2)
button = buttons.column(2)
elif rclonePath:
msg += f'<b>• Path: </b><code>{rclonePath}</code>\n'
button = None
buttons = extra_btns(buttons)
button = buttons.menu(2)
button = buttons.column(2)
msg += f'<b>• User ID: </b><code>{self.message.from_user.id}</code>\n'
msg += f'<b>• By: </b>{self.tag}</blockquote>\n\n'

Expand All @@ -418,7 +418,7 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
await sendMessage(self.botpmmsg, msg, button, 'Random')
await deleteMessage(self.botpmmsg)
if self.isSuperGroup:
await sendMessage(self.message, f'{msg} <b>Links has been sent to your inbox</b>', inboxButton.menu(1))
await sendMessage(self.message, f'{msg} <b>Links has been sent to your inbox</b>', inboxButton.column(1))
else:
await deleteMessage(self.botpmmsg)
if self.seed:
Expand Down
6 changes: 3 additions & 3 deletions bot/helper/mirror_leech_utils/rclone_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def get_path_buttons(self):
if self.path:
buttons.callback('Back To Root', 'rcq root', position='footer')
buttons.callback('Cancel', 'rcq cancel', position='footer')
button = buttons.menu(f_cols=2)
button = buttons.column(f_cols=2)
msg = 'Choose Path:' + ('\nTransfer Type: Download' if self.list_status ==
'rcd' else '\nTransfer Type: Upload')
if self.list_status == 'rcu':
Expand Down Expand Up @@ -239,7 +239,7 @@ async def list_remotes(self):
if self.__rc_user and self.__rc_owner:
buttons.callback('Back', 'rcq back re', position='footer')
buttons.callback('Cancel', 'rcq cancel', position='footer')
button = buttons.menu(2)
button = buttons.column(2)
await self.__send_list_message(msg, button)

async def list_config(self):
Expand All @@ -252,7 +252,7 @@ async def list_config(self):
buttons.callback('Owner Config', 'rcq owner')
buttons.callback('My Config', 'rcq user')
buttons.callback('Cancel', 'rcq cancel')
button = buttons.menu(2)
button = buttons.column(2)
await self.__send_list_message(msg, button)
else:
self.config_path = 'rcl.conf' if self.__rc_owner else self.user_rcc_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def __buttons(self, up_path, is_video=False):
LOGGER.info(m)
except Exception as e:
LOGGER.error(f"MediaInfo Error: {str(e)}")
return buttons.menu(1) if self.__has_buttons else None
return buttons.column(1) if self.__has_buttons else None

async def __copy_file(self):
try:
Expand Down
69 changes: 33 additions & 36 deletions bot/helper/telegram_helper/button_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,43 @@

class ButtonMaker:
def __init__(self):
self.__button = []
self.__header_button = []
self.__footer_button = []
self.main_buttons = []
self.header_buttons = []
self.footer_buttons = []

def url(self, key, link, position=None):
if not position:
self.__button.append(InlineKeyboardButton(text=key, url=link))
elif position == 'header':
self.__header_button.append(
InlineKeyboardButton(text=key, url=link))
def url(self, text, url, position=None):
button = InlineKeyboardButton(text=text, url=url)
if position == 'header':
self.header_buttons.append(button)
elif position == 'footer':
self.__footer_button.append(
InlineKeyboardButton(text=key, url=link))
self.footer_buttons.append(button)
else:
self.main_buttons.append(button)

def callback(self, key, data, position=None):
if not position:
self.__button.append(InlineKeyboardButton(
text=key, callback_data=data))
elif position == 'header':
self.__header_button.append(
InlineKeyboardButton(text=key, callback_data=data))
def callback(self, text, callback_data, position=None):
button = InlineKeyboardButton(text=text, callback_data=callback_data)
if position == 'header':
self.header_buttons.append(button)
elif position == 'footer':
self.__footer_button.append(
InlineKeyboardButton(text=key, callback_data=data))
self.footer_buttons.append(button)
else:
self.main_buttons.append(button)

def menu(self, b_cols=1, h_cols=8, f_cols=8):
menu = [self.__button[i:i+b_cols]
for i in range(0, len(self.__button), b_cols)]
if self.__header_button:
h_cnt = len(self.__header_button)
if h_cnt > h_cols:
header_buttons = [self.__header_button[i:i+h_cols]
for i in range(0, len(self.__header_button), h_cols)]
menu = header_buttons + menu
def column(self, main_columns=1, header_columns=8, footer_columns=8):
keyboard = [self.main_buttons[i:i + main_columns] for i in range(0, len(self.main_buttons), main_columns)]

if self.header_buttons:
if len(self.header_buttons) > header_columns:
header_chunks = [self.header_buttons[i:i + header_columns] for i in range(0, len(self.header_buttons), header_columns)]
keyboard = header_chunks + keyboard
else:
menu.insert(0, self.__header_button)
if self.__footer_button:
if len(self.__footer_button) > f_cols:
[menu.append(self.__footer_button[i:i+f_cols])
for i in range(0, len(self.__footer_button), f_cols)]
keyboard.insert(0, self.header_buttons)

if self.footer_buttons:
if len(self.footer_buttons) > footer_columns:
footer_chunks = [self.footer_buttons[i:i + footer_columns] for i in range(0, len(self.footer_buttons), footer_columns)]
keyboard += footer_chunks
else:
menu.append(self.__footer_button)
return InlineKeyboardMarkup(menu)
keyboard.append(self.footer_buttons)

return InlineKeyboardMarkup(keyboard)
2 changes: 1 addition & 1 deletion bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ async def get_buttons(key=None, edit_type=None, edit_mode=None, mess=None):
buttons.callback('Make it True', f"botset boolvar {key} on")
else:
buttons.callback('Make it False', f"botset boolvar {key} off")
button = buttons.menu(1) if key is None else buttons.menu(2)
button = buttons.column(1) if key is None else buttons.column(2)
return msg, button


Expand Down
2 changes: 1 addition & 1 deletion bot/modules/cancel_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def cancell_all_buttons(_, message):
buttons.callback("Paused", f"stopall {MirrorStatus.STATUS_PAUSED}")
buttons.callback("All", "stopall all")
buttons.callback("Close", "stopall close")
button = buttons.menu(2)
button = buttons.column(2)
can_msg = await sendMessage(message, 'Choose tasks to cancel.', button)
await deleteMessage(message)
await one_minute_del(can_msg)
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def __run_multi():
for __i, __msg in enumerate(error_msg, 1):
final_msg += f'\n<blockquote><b>{__i}</b>: {__msg}</blockquote>'
if error_button is not None:
error_button = error_button.menu(2)
error_button = error_button.column(2)
await delete_links(message)
force_m = await sendMessage(message, final_msg, error_button)
await five_minute_del(force_m)
Expand Down
6 changes: 3 additions & 3 deletions bot/modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def pictures(_, message):
buttons.callback("Close", f"images {user_id} close")
buttons.callback("Remove all", f"images {user_id} removeall", 'footer')
await deleteMessage(to_edit)
await sendMessage(message, f'<b>Image No. : 1 / {len(IMAGES)}</b>', buttons.menu(2), IMAGES[0])
await sendMessage(message, f'<b>Image No. : 1 / {len(IMAGES)}</b>', buttons.column(2), IMAGES[0])

@new_task
async def pics_callback(_, query):
Expand All @@ -90,7 +90,7 @@ async def pics_callback(_, query):
buttons.callback("Remove Image", f"images {data[1]} remove {ind}")
buttons.callback("Close", f"images {data[1]} close")
buttons.callback("Remove all", f"images {data[1]} removeall", 'footer')
await editMessage(message, pic_info, buttons.menu(2), IMAGES[ind])
await editMessage(message, pic_info, buttons.column(2), IMAGES[ind])

elif data[2] == "remove":
IMAGES.pop(int(data[3]))
Expand All @@ -112,7 +112,7 @@ async def pics_callback(_, query):
buttons.callback("Remove image", f"images {data[1]} remove {ind}")
buttons.callback("Close", f"images {data[1]} close")
buttons.callback("Remove all", f"images {data[1]} removeall", 'footer')
await editMessage(message, pic_info, buttons.menu(2), IMAGES[ind])
await editMessage(message, pic_info, buttons.column(2), IMAGES[ind])

elif data[2] == 'removeall':
IMAGES.clear()
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def list_buttons(user_id, isRecursive=True):
buttons.callback("Both", f"list_types {user_id} both {isRecursive}")
buttons.callback(f"Recursive: {isRecursive}", f"list_types {user_id} rec {isRecursive}")
buttons.callback("Cancel", f"list_types {user_id} cancel")
return buttons.menu(2)
return buttons.column(2)

async def _list_drive(key, message, item_type, isRecursive):
LOGGER.info(f"listing: {key}")
Expand Down Expand Up @@ -67,7 +67,7 @@ async def drive_list(_, message):
if message.chat.type != message.chat.type.PRIVATE:
msg, btn = await checking_access(user_id)
if msg is not None:
reply_message = await sendMessage(message, msg, btn.menu(1))
reply_message = await sendMessage(message, msg, btn.column(1))
await delete_links(message)
await five_minute_del(reply_message)
return
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/mirror_leech.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def __run_multi():
for __i, __msg in enumerate(error_msg, 1):
final_msg += f'\n<blockquote><b>{__i}</b>: {__msg}</blockquote>'
if error_button is not None:
error_button = error_button.menu(2)
error_button = error_button.column(2)
await delete_links(message)
force_m = await sendMessage(message, final_msg, error_button)
await five_minute_del(force_m)
Expand Down
12 changes: 6 additions & 6 deletions bot/modules/torrent_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def __search(key, site, message, method):
link = await __getResult(search_results, key, message, method)
buttons = ButtonMaker()
buttons.url("View", link)
button = buttons.menu(1)
button = buttons.column(1)
await editMessage(message, msg, button)


Expand Down Expand Up @@ -175,7 +175,7 @@ def __api_buttons(user_id, method):
for data, name in SITES.items():
buttons.callback(name, f"torser {user_id} {data} {method}")
buttons.callback("Cancel", f"torser {user_id} cancel")
return buttons.menu(2)
return buttons.column(2)


async def __plugin_buttons(user_id):
Expand All @@ -184,7 +184,7 @@ async def __plugin_buttons(user_id):
buttons.callback(siteName.capitalize(), f"torser {user_id} {siteName} plugin")
buttons.callback('All', f"torser {user_id} all plugin")
buttons.callback("Cancel", f"torser {user_id} cancel")
return buttons.menu(2)
return buttons.column(2)

@new_thread
async def torrentSearch(_, message):
Expand All @@ -195,7 +195,7 @@ async def torrentSearch(_, message):
if message.chat.type != message.chat.type.PRIVATE:
msg, buttons = await checking_access(user_id, buttons)
if msg is not None:
reply_message = await sendMessage(message, msg, buttons.menu(1))
reply_message = await sendMessage(message, msg, buttons.column(1))
await delete_links(message)
await five_minute_del(reply_message)
return
Expand All @@ -208,13 +208,13 @@ async def torrentSearch(_, message):
buttons.callback('Trending', f"torser {user_id} apitrend")
buttons.callback('Recent', f"torser {user_id} apirecent")
buttons.callback("Cancel", f"torser {user_id} cancel")
button = buttons.menu(2)
button = buttons.column(2)
reply_message = await sendMessage(message, "Send a search key along with command", button)
elif SITES is not None:
buttons.callback('Api', f"torser {user_id} apisearch")
buttons.callback('Plugins', f"torser {user_id} plugin")
buttons.callback("Cancel", f"torser {user_id} cancel")
button = buttons.menu(2)
button = buttons.column(2)
reply_message = await sendMessage(message, 'Choose tool to search:', button)
else:
button = await __plugin_buttons(user_id)
Expand Down
Loading

0 comments on commit 3e84a94

Please sign in to comment.