Drag commited on
Commit
60428a8
·
1 Parent(s): eb22b9f

Update _help.py

Browse files
Files changed (1) hide show
  1. plugins/_help.py +19 -75
plugins/_help.py CHANGED
@@ -82,6 +82,7 @@ async def _help(ult):
82
  file = file_name
83
  break
84
  if not file:
 
85
  text = f"`{plug}` is not a valid plugin!"
86
  best_match = None
87
  for _ in compare_strings:
@@ -95,6 +96,12 @@ async def _help(ult):
95
  if file in HELP["Official"]:
96
  for i in HELP["Official"][file]:
97
  output += i
 
 
 
 
 
 
98
  output += "\n© @xteam_cloner"
99
  await ult.eor(output)
100
  except BaseException as er:
@@ -103,78 +110,15 @@ async def _help(ult):
103
  else:
104
  try:
105
  results = await ult.client.inline_query(asst.me.username, "ultd")
106
- await results[0].click(chat.id, reply_to=ult.reply_to_msg_id, hide_via=True)
107
- await ult.delete()
108
- except Exception as e:
109
- LOGS.info(e)
110
- # Count total commands
111
- cmd_count = sum(len(cmds) for cmds in LIST.values())
112
-
113
- # Create the help menu with clean buttons
114
- text = "**Help Modules**\n"
115
- text += f"**Prefixes:** {HNDLR}\n"
116
- text += f"**Commands:** {cmd_count}"
117
-
118
- buttons = [
119
- [
120
- Button.inline("Admin", data="hlp_admin"),
121
- Button.inline("Asupan", data="hlp_asupan")
122
- ],
123
- [
124
- Button.inline("Auto Broadcast", data="hlp_autobc"),
125
- Button.inline("Blacklist", data="hlp_blacklist")
126
- ],
127
- [
128
- Button.inline("Convert", data="hlp_convert"),
129
- Button.inline("Copy", data="hlp_copy")
130
- ],
131
- [
132
- Button.inline("«", data="hlp_prev"),
133
- Button.inline("»", data="hlp_next")
134
- ]
135
- ]
136
- await ult.eor(text, buttons=buttons)
137
-
138
- @callback(pattern="hlp_(.*)")
139
- async def help_callback(event):
140
- data = event.data_match.group(1).decode("utf-8")
141
- if data == "prev":
142
- await event.answer("Previous page")
143
- elif data == "next":
144
- await event.answer("Next page")
145
- elif data == "back":
146
- cmd_count = sum(len(cmds) for cmds in LIST.values())
147
- text = "**Help Modules**\n"
148
- text += f"**Prefixes:** {HNDLR}\n"
149
- text += f"**Commands:** {cmd_count}"
150
-
151
- buttons = [
152
- [
153
- Button.inline("Admin", data="hlp_admin"),
154
- Button.inline("Asupan", data="hlp_asupan")
155
- ],
156
- [
157
- Button.inline("Auto Broadcast", data="hlp_autobc"),
158
- Button.inline("Blacklist", data="hlp_blacklist")
159
- ],
160
- [
161
- Button.inline("Convert", data="hlp_convert"),
162
- Button.inline("Copy", data="hlp_copy")
163
- ],
164
- [
165
- Button.inline("«", data="hlp_prev"),
166
- Button.inline("»", data="hlp_next")
167
- ]
168
- ]
169
- await event.edit(text, buttons=buttons)
170
- else:
171
- # Show help for specific plugin
172
- try:
173
- output = f"**Plugin** - `{data}`\n"
174
- if data in HELP["Official"]:
175
- for i in HELP["Official"][data]:
176
- output += i
177
- output += "\n© @xteam_cloner"
178
- await event.edit(output, buttons=[[Button.inline("« Back", data="hlp_back")]])
179
- except Exception as e:
180
- await event.edit(f"No help available for {data}")
 
82
  file = file_name
83
  break
84
  if not file:
85
+ # the entered command/plugin name is not found
86
  text = f"`{plug}` is not a valid plugin!"
87
  best_match = None
88
  for _ in compare_strings:
 
96
  if file in HELP["Official"]:
97
  for i in HELP["Official"][file]:
98
  output += i
99
+ elif HELP.get("Addons") and file in HELP["Addons"]:
100
+ for i in HELP["Addons"][file]:
101
+ output += i
102
+ elif HELP.get("VCBot") and file in HELP["VCBot"]:
103
+ for i in HELP["VCBot"][file]:
104
+ output += i
105
  output += "\n© @xteam_cloner"
106
  await ult.eor(output)
107
  except BaseException as er:
 
110
  else:
111
  try:
112
  results = await ult.client.inline_query(asst.me.username, "ultd")
113
+ except BotMethodInvalidError:
114
+ return await ult.reply(
115
+ "Inline mode is disabled. Please enable it in bot settings or contact support.",
116
+ )
117
+ except BotResponseTimeoutError:
118
+ return await ult.eor(
119
+ "The bot did not respond in time. Please try again later.",
120
+ )
121
+ except BotInlineDisabledError:
122
+ return await ult.eor("The bot's inline mode is currently disabled.")
123
+ await results[0].click(chat.id, reply_to=ult.reply_to_msg_id, hide_via=True)
124
+ await ult.delete()