Captain Ezio commited on
Commit
350cc3c
·
1 Parent(s): 59a80e2

Update admin.py

Browse files
Files changed (1) hide show
  1. Powers/plugins/admin.py +33 -31
Powers/plugins/admin.py CHANGED
@@ -162,7 +162,7 @@ async def tag_admins(_, m: Message):
162
  )
163
 
164
 
165
- @Gojo.on_message(command("fullpromote") & promote_filter)
166
  async def fullpromote_usr(c: Gojo, m: Message):
167
  global ADMIN_CACHE
168
 
@@ -205,33 +205,34 @@ async def fullpromote_usr(c: Gojo, m: Message):
205
  )
206
  return
207
 
208
- try:
209
- await m.chat.promote_member(user_id=user_id, privileges=bot.privileges)
 
 
210
 
211
- title = ""
212
- if len(m.text.split()) == 3 and not m.reply_to_message:
213
- title = m.text.split()[2]
214
- elif len(m.text.split()) == 2 and m.reply_to_message:
215
- title = m.text.split()[1]
216
- if title and len(title) > 16:
217
- title = title[0:16] # trim title to 16 characters
218
 
219
- try:
220
- await c.set_administrator_title(m.chat.id, user_id, title)
221
- except RPCError as e:
222
- LOGGER.error(e)
223
 
224
  LOGGER.info(
225
  f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
226
  )
227
 
228
  await m.reply_text(
229
- ("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
230
  promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
231
  promoted=(await mention_html(user_first_name, user_id)),
232
  chat_title=f"{escape(m.chat.title)} title set to {title}"
233
  if title
234
- else f"{escape(m.chat.title)} title set to Gojo",
235
  ),
236
  )
237
 
@@ -319,23 +320,24 @@ async def promote_usr(c: Gojo, m: Message):
319
  can_manage_video_chats=bot.privileges.can_manage_video_chats,
320
  ),
321
  )
322
-
323
  title = "" # Deafult title
324
- if len(m.text.split()) == 3 and not m.reply_to_message:
325
- title = m.text.split()[2]
326
- elif len(m.text.split()) == 2 and m.reply_to_message:
327
- title = m.text.split()[1]
328
- if title and len(title) > 16:
329
- title = title[0:16] # trim title to 16 characters
 
330
 
331
- try:
332
- await c.set_administrator_title(m.chat.id, user_id, title)
333
- except RPCError as e:
334
- LOGGER.error(e)
335
 
336
- LOGGER.info(
337
- f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
338
- )
339
 
340
  await m.reply_text(
341
  ("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
@@ -343,7 +345,7 @@ async def promote_usr(c: Gojo, m: Message):
343
  promoted=(await mention_html(user_first_name, user_id)),
344
  chat_title=f"{escape(m.chat.title)} title set to {title}"
345
  if title
346
- else f"{escape(m.chat.title)} title set to Itadori",
347
  ),
348
  )
349
 
 
162
  )
163
 
164
 
165
+ @Gojo.on_message(command(["fullpromote", "fulpromote"]) & promote_filter)
166
  async def fullpromote_usr(c: Gojo, m: Message):
167
  global ADMIN_CACHE
168
 
 
205
  )
206
  return
207
 
208
+ title = "" # Deafult title
209
+ if not m.chat.type == ChatType.SUPERGROUP:
210
+ try:
211
+ await m.chat.promote_member(user_id=user_id, privileges=bot.privileges)
212
 
213
+ if len(m.text.split()) == 3 and not m.reply_to_message:
214
+ title = m.text.split()[2]
215
+ elif len(m.text.split()) == 2 and m.reply_to_message:
216
+ title = m.text.split()[1]
217
+ if title and len(title) > 16:
218
+ title = title[0:16] # trim title to 16 characters
 
219
 
220
+ try:
221
+ await c.set_administrator_title(m.chat.id, user_id, title)
222
+ except RPCError as e:
223
+ LOGGER.error(e)
224
 
225
  LOGGER.info(
226
  f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
227
  )
228
 
229
  await m.reply_text(
230
+ ("{promoter} promoted {promoted} in chat <b>{chat_title}</b> with all rights!").format(
231
  promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
232
  promoted=(await mention_html(user_first_name, user_id)),
233
  chat_title=f"{escape(m.chat.title)} title set to {title}"
234
  if title
235
+ else f"{escape(m.chat.title)} title set to default",
236
  ),
237
  )
238
 
 
320
  can_manage_video_chats=bot.privileges.can_manage_video_chats,
321
  ),
322
  )
323
+
324
  title = "" # Deafult title
325
+ if not m.chat.type == ChatType.SUPERGROUP:
326
+ if len(m.text.split()) == 3 and not m.reply_to_message:
327
+ title = m.text.split()[2]
328
+ elif len(m.text.split()) == 2 and m.reply_to_message:
329
+ title = m.text.split()[1]
330
+ if title and len(title) > 16:
331
+ title = title[0:16] # trim title to 16 characters
332
 
333
+ try:
334
+ await c.set_administrator_title(m.chat.id, user_id, title)
335
+ except RPCError as e:
336
+ LOGGER.error(e)
337
 
338
+ LOGGER.info(
339
+ f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
340
+ )
341
 
342
  await m.reply_text(
343
  ("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
 
345
  promoted=(await mention_html(user_first_name, user_id)),
346
  chat_title=f"{escape(m.chat.title)} title set to {title}"
347
  if title
348
+ else f"{escape(m.chat.title)} title set to default",
349
  ),
350
  )
351