feat: allow to give titles to oneself
This commit is contained in:
parent
7a314fa68c
commit
b13e8533ed
1 changed files with 22 additions and 12 deletions
|
|
@ -11,9 +11,6 @@ async def handle_promote_command(message: Message) -> None:
|
|||
if message.chat.type not in ['group', 'supergroup']:
|
||||
return
|
||||
try:
|
||||
if not message.reply_to_message:
|
||||
await message.reply('咱不知道给谁头衔呢')
|
||||
return
|
||||
if not title:
|
||||
await message.reply('咱不知道给什么头衔呢')
|
||||
return
|
||||
|
|
@ -26,16 +23,29 @@ async def handle_promote_command(message: Message) -> None:
|
|||
await message.reply('咱不能给群主设置头衔')
|
||||
return
|
||||
if not member.status in ['administrator','creator']:
|
||||
await message.chat.promote(message.reply_to_message.from_user.id,can_manage_chat=True)
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
if message.reply_to_message:
|
||||
await message.chat.promote(message.reply_to_message.from_user.id,can_manage_chat=True)
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
else:
|
||||
await message.chat.promote(message.reply_to_message.from_user.id, can_manage_chat=True)
|
||||
await message.chat.set_administrator_custom_title(message.from_user.id, title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把自己变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
elif member.status == 'administrator' and member.can_be_edited:
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
if message.reply_to_message:
|
||||
await message.chat.set_administrator_custom_title(message.reply_to_message.from_user.id,title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把 {message.reply_to_message.from_user.mention_html()} 变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
else:
|
||||
await message.chat.set_administrator_custom_title(message.from_user.id, title)
|
||||
await message.reply(
|
||||
f'{message.from_user.mention_html()} 把自己变成了 <b>{title}</b>!',
|
||||
parse_mode='HTML')
|
||||
else:
|
||||
await message.reply('咱不能给这个人设置头衔,可能是因为ta已经被其它管理员设置了头衔')
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue