diff --git a/languages/built-in/en.yml b/languages/built-in/en.yml index ac44201..771e6f2 100644 --- a/languages/built-in/en.yml +++ b/languages/built-in/en.yml @@ -514,3 +514,4 @@ sb_set: This group has been added to the automatic banned list. sb_remove: The automatic banned list has been removed this group. sb_exist: This group exists in the automatic banned list. sb_no_exist: This group does't exist in the automatic banned list. +sb_channel: Successfully blocked this channel in this group. diff --git a/languages/built-in/zh-cn.yml b/languages/built-in/zh-cn.yml index 8a8a8fb..e136d9b 100644 --- a/languages/built-in/zh-cn.yml +++ b/languages/built-in/zh-cn.yml @@ -530,3 +530,4 @@ sb_set: 已被添加到自动封禁列表中。 sb_remove: 已被移除自动封禁列表。 sb_exist: 此群组存在于自动封禁列表中。 sb_no_exist: 此群组不存在于自动封禁列表中。 +sb_channel: 成功在本群封禁此频道。 diff --git a/languages/built-in/zh-tw.yml b/languages/built-in/zh-tw.yml index 4647e47..bb8d9de 100644 --- a/languages/built-in/zh-tw.yml +++ b/languages/built-in/zh-tw.yml @@ -514,3 +514,4 @@ sb_set: 已被添加到自動封禁列表中。 sb_remove: 已被移除自動封禁列表。 sb_exist: 此群組存在於自動封禁列表中。 sb_no_exist: 此群組不存在於自動封禁列表中。 +sb_channel: 成功在本群封禁此頻道。 diff --git a/pagermaid/modules/sb.py b/pagermaid/modules/sb.py index 24799a1..9b35cd6 100644 --- a/pagermaid/modules/sb.py +++ b/pagermaid/modules/sb.py @@ -4,8 +4,9 @@ from pagermaid.utils import lang, alias_command from struct import error as StructError from telethon.tl.functions.messages import GetCommonChatsRequest from telethon.tl.functions.users import GetFullUserRequest -from telethon.tl.functions.channels import DeleteUserHistoryRequest -from telethon.tl.types import MessageEntityMentionName, ChannelParticipantsAdmins, MessageEntityPhone, PeerChannel +from telethon.tl.functions.channels import DeleteUserHistoryRequest, EditBannedRequest +from telethon.tl.types import MessageEntityMentionName, ChannelParticipantsAdmins, MessageEntityPhone, PeerChannel, \ + ChatBannedRights from telethon.errors.rpcerrorlist import UserAdminInvalidError, ChatAdminRequiredError, FloodWaitError from asyncio import sleep from random import uniform @@ -49,7 +50,19 @@ async def span_ban(context): await context.edit(lang('arg_error')) return if isinstance(user, PeerChannel): - return await context.edit(lang('arg_error')) + # 封禁频道 + try: + entity = await context.client.get_input_entity(context.chat_id) + user = await context.client.get_input_entity(reply_message.sender.id) + await context.client(EditBannedRequest( + channel=entity, + participant=user, + banned_rights=ChatBannedRights( + until_date=None, view_messages=True) + )) + except ChatAdminRequiredError: + return await context.edit(lang('sb_no_per')) + return await context.edit(lang('sb_channel')) elif not user: return await context.edit(lang('arg_error')) target_user = await context.client(GetFullUserRequest(user))