Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Add new 'ban' cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Divkix committed Feb 23, 2023
1 parent add7f83 commit 6c4c59f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion WebStreamer/bot/plugins/ban.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyrogram import filters
from pyrogram.types import CallbackQuery
from pyrogram.types import CallbackQuery, Message

from WebStreamer.bot import StreamBot
from WebStreamer.vars import Vars
Expand All @@ -15,3 +15,24 @@ async def ban_user(c: StreamBot, q: CallbackQuery):
user_id = int(q.data.split("_", 1)[1])
await c.ban_chat_member(Vars.AUTH_CHANNEL, user_id)
await q.answer("User Banned from Updates Channel!", show_alert=True)


@StreamBot.on_message(
filters.command("ban") & filters.private & filters.user(Vars.OWNER_ID),
)
async def ban_user_cmd(c: StreamBot, m: Message):
"""
Ban a user from using the bot
:param c: pyrogram.Client
:param m: pyrogram.types.Message
"""
user_id = m.text.split(" ", 1)[1]
# check if user_id has space in between
if len(user_id.split(" ")) == 1:
await c.ban_chat_member(Vars.AUTH_CHANNEL, user_id)
await m.reply_text(f"User '{user_id}' Banned from Updates Channel!")
return
# error if user_id has space in between
await m.reply_text(
"Multiple User IDs given!\nOnly one user can be banned at a time!",
)

0 comments on commit 6c4c59f

Please sign in to comment.