Alexainc commited on
Commit
2e85f25
·
1 Parent(s): e20d07c

fix: help formatting text and tagall cancel logic

Browse files
QueenNoxi/__main__.py CHANGED
@@ -189,12 +189,22 @@ async def help_button(client, query: CallbackQuery):
189
  )
190
  + HELPABLE[module].__help__
191
  )
192
- await query.message.edit_caption(text,
193
- reply_markup=InlineKeyboardMarkup(
194
- [[InlineKeyboardButton(text="ʙᴀᴄᴋ", callback_data="help_back"),
195
- InlineKeyboardButton(text="sᴜᴘᴘᴏʀᴛ", callback_data="queennoxi_support")]]
196
- ),
197
- )
 
 
 
 
 
 
 
 
 
 
198
  elif prev_match:
199
  curr_page = int(prev_match.group(1))
200
  await query.message.edit_caption(HELP_STRINGS,
@@ -216,8 +226,9 @@ async def help_button(client, query: CallbackQuery):
216
  ),
217
  )
218
  await query.answer()
219
- except Exception:
220
- pass
 
221
 
222
  @pbot.on_callback_query(filters.regex(r"^queennoxi_"))
223
  async def QueenNoxi_about_callback(client, query: CallbackQuery):
 
189
  )
190
  + HELPABLE[module].__help__
191
  )
192
+ try:
193
+ await query.message.edit_caption(text,
194
+ reply_markup=InlineKeyboardMarkup(
195
+ [[InlineKeyboardButton(text="ʙᴀᴄᴋ", callback_data="help_back"),
196
+ InlineKeyboardButton(text="sᴜᴘᴘᴏʀᴛ", callback_data="queennoxi_support")]]
197
+ ),
198
+ )
199
+ except RPCError as e:
200
+ # Fallback if caption is still too long or other RPC error
201
+ LOGGER.error(f"Error editing help caption: {e}")
202
+ await query.message.reply_text(text,
203
+ reply_markup=InlineKeyboardMarkup(
204
+ [[InlineKeyboardButton(text="ʙᴀᴄᴋ", callback_data="help_back"),
205
+ InlineKeyboardButton(text="sᴜᴘᴘᴏʀᴛ", callback_data="queennoxi_support")]]
206
+ ),
207
+ )
208
  elif prev_match:
209
  curr_page = int(prev_match.group(1))
210
  await query.message.edit_caption(HELP_STRINGS,
 
226
  ),
227
  )
228
  await query.answer()
229
+ except Exception as e:
230
+ LOGGER.error(f"Error in help_button: {e}")
231
+ await query.answer("An error occurred while opening help.", show_alert=True)
232
 
233
  @pbot.on_callback_query(filters.regex(r"^queennoxi_"))
234
  async def QueenNoxi_about_callback(client, query: CallbackQuery):
QueenNoxi/modules/formatting.py CHANGED
@@ -4,34 +4,33 @@ from QueenNoxi import pbot
4
  __mod_name__ = "Formatting"
5
 
6
  __help__ = """
7
- You can use the following placeholders to personalize your welcome, filters, or notes:
8
 
9
  **User Info:**
10
- • `{first}`: The user's first name.
11
- • `{last}`: The user's last name (or first name if empty).
12
- • `{fullname}`: The user's full name.
13
- • `{username}`: The user's @username (or mention if empty).
14
- • `{id}`: The user's ID.
15
- • `{mention}`: A clickable mention of the user.
16
 
17
  **Chat Info:**
18
- • `{chatname}`: The name of the current group.
19
- • `{rules}`: A clickable link to the group rules.
20
 
21
- **Advanced Control Tags:**
22
- • `{preview}`: Enables link previews (enabled by default unless this is absent).
23
- • `{nonotif}`: Sends the message without a notification sound.
24
- • `{protect}`: Prevents the message from being forwarded or screenshotted.
25
- • `{mediaspoiler}`: Hides the photo/video behind a spoiler blur (if applicable).
26
 
27
  **Buttons:**
28
- • `[Button Text](buttonurl://link)`: Creates a URL button.
29
- • `[Button Text](buttonurl#danger://link)`: Creates a Red (danger) button.
30
- • `[Button Text](buttonurl#success://link)`: Creates a Green (success) button.
31
- • `[Button Text](buttonurl#primary://link)`: Creates a Blue (primary) button.
32
- • `[Button Text](buttonurl://btn_next)`: Creates a "Next" navigation button.
33
- • `[Button Text](buttonurl://btn_back)`: Creates a "Back" navigation button.
34
 
35
- **Note on Previews:**
36
- Link previews are **DISABLED** by default. To enable them, include `{preview}` anywhere in your message.
37
  """
 
4
  __mod_name__ = "Formatting"
5
 
6
  __help__ = """
7
+ Personalize your welcome, filters, or notes with these placeholders:
8
 
9
  **User Info:**
10
+ • `{first}`: First name.
11
+ • `{last}`: Last name.
12
+ • `{fullname}`: Full name.
13
+ • `{username}`: @username.
14
+ • `{id}`: User ID.
15
+ • `{mention}`: Mention user.
16
 
17
  **Chat Info:**
18
+ • `{chatname}`: Group name.
19
+ • `{rules}`: Link to rules.
20
 
21
+ **Control Tags:**
22
+ • `{preview}`: Enable link previews.
23
+ • `{nonotif}`: Muted message.
24
+ • `{protect}`: Prevent forward/screenshot.
25
+ • `{mediaspoiler}`: Blur media.
26
 
27
  **Buttons:**
28
+ • `[Text](buttonurl://link)`: URL button.
29
+ • `[Text](buttonurl#danger://link)`: Red button.
30
+ • `[Text](buttonurl#success://link)`: Green button.
31
+ • `[Text](buttonurl#primary://link)`: Blue button.
32
+ • `[Text](buttonurl://btn_next)`: Next page.
33
+ • `[Text](buttonurl://btn_back)`: Previous page.
34
 
35
+ **Note:** Previews are **DISABLED** by default. Use `{preview}` to enable.
 
36
  """
QueenNoxi/modules/tagall.py CHANGED
@@ -7,7 +7,7 @@ from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantCreator
7
 
8
  from QueenNoxi import telethn as client
9
 
10
- spam_chats = []
11
 
12
  @client.on(events.NewMessage(pattern="^@tagall ?(.*)"))
13
  @client.on(events.NewMessage(pattern="^@all ?(.*)"))
@@ -50,15 +50,17 @@ async def mentionall(event):
50
  "__Reply to a message or give me some text to mention others!__"
51
  )
52
 
53
- spam_chats.append(chat_id)
54
  usrnum = 0
55
  usrtxt = ""
56
  async for usr in client.iter_participants(chat_id):
57
- if not chat_id in spam_chats:
58
  break
59
  usrnum += 1
60
  usrtxt += f"[{usr.first_name}](tg://user?id={usr.id}), "
61
  if usrnum == 15:
 
 
62
  if mode == "text_on_cmd":
63
  txt = f"{msg}\n{usrtxt}"
64
  await client.send_message(chat_id, txt)
@@ -68,14 +70,14 @@ async def mentionall(event):
68
  usrnum = 0
69
  usrtxt = ""
70
  try:
71
- spam_chats.remove(chat_id)
72
  except:
73
  pass
74
 
75
 
76
  @client.on(events.NewMessage(pattern="^/cancel$"))
77
  async def cancel_spam(event):
78
- if not event.chat_id in spam_chats:
79
  return await event.respond("ᴛʜᴇʀᴇ ɪs ɴᴏ ᴘʀᴏᴄᴄᴇss ᴏɴ ɢᴏɪɴɢ..")
80
  is_admin = False
81
  try:
@@ -91,10 +93,7 @@ async def cancel_spam(event):
91
  return await event.respond("__ᴏɴʟʏ ᴀᴅᴍɪɴs ᴄᴀɴ ᴇxᴇᴄᴜᴛᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ!__")
92
 
93
  else:
94
- try:
95
- spam_chats.remove(event.chat_id)
96
- except:
97
- pass
98
  return await event.respond("sᴛᴏᴘᴘᴇᴅ ᴍᴇɴᴛɪᴏɴ.__")
99
 
100
 
 
7
 
8
  from QueenNoxi import telethn as client
9
 
10
+ spam_chats = set()
11
 
12
  @client.on(events.NewMessage(pattern="^@tagall ?(.*)"))
13
  @client.on(events.NewMessage(pattern="^@all ?(.*)"))
 
50
  "__Reply to a message or give me some text to mention others!__"
51
  )
52
 
53
+ spam_chats.add(chat_id)
54
  usrnum = 0
55
  usrtxt = ""
56
  async for usr in client.iter_participants(chat_id):
57
+ if chat_id not in spam_chats:
58
  break
59
  usrnum += 1
60
  usrtxt += f"[{usr.first_name}](tg://user?id={usr.id}), "
61
  if usrnum == 15:
62
+ if chat_id not in spam_chats:
63
+ break
64
  if mode == "text_on_cmd":
65
  txt = f"{msg}\n{usrtxt}"
66
  await client.send_message(chat_id, txt)
 
70
  usrnum = 0
71
  usrtxt = ""
72
  try:
73
+ spam_chats.discard(chat_id)
74
  except:
75
  pass
76
 
77
 
78
  @client.on(events.NewMessage(pattern="^/cancel$"))
79
  async def cancel_spam(event):
80
+ if event.chat_id not in spam_chats:
81
  return await event.respond("ᴛʜᴇʀᴇ ɪs ɴᴏ ᴘʀᴏᴄᴄᴇss ᴏɴ ɢᴏɪɴɢ..")
82
  is_admin = False
83
  try:
 
93
  return await event.respond("__ᴏɴʟʏ ᴀᴅᴍɪɴs ᴄᴀɴ ᴇxᴇᴄᴜᴛᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ!__")
94
 
95
  else:
96
+ spam_chats.discard(event.chat_id)
 
 
 
97
  return await event.respond("sᴛᴏᴘᴘᴇᴅ ᴍᴇɴᴛɪᴏɴ.__")
98
 
99