diff --git a/config.env.sample b/config.env.sample index d974e4ca1..537cd8173 100644 --- a/config.env.sample +++ b/config.env.sample @@ -58,6 +58,10 @@ WORKERS="" # Telegram Chat id For Updates of Rss Feed RSS_CHAT_ID="" +# Telegram Chat id to Fban User +# add your federation bots to chat and copy chat_id of that chat +FBAN_CHAT_ID="" + # Googel Drive API Keys from https://console.developers.google.com/ G_DRIVE_CLIENT_ID="" G_DRIVE_CLIENT_SECRET="" diff --git a/userge/config.py b/userge/config.py index d738f702d..c31890a37 100644 --- a/userge/config.py +++ b/userge/config.py @@ -83,6 +83,7 @@ class Config: ALLOWED_COMMANDS: Set[str] = set() IGNORE_VERIFIED_CHATS = True ANTISPAM_SENTRY = False + FBAN_CHAT_ID = int(os.environ.get("FBAN_CHAT_ID", 0)) RUN_DYNO_SAVER = False HEROKU_APP = heroku3.from_key(HEROKU_API_KEY).apps()[HEROKU_APP_NAME] \ if HEROKU_ENV and HEROKU_API_KEY and HEROKU_APP_NAME else None diff --git a/userge/plugins/admin/gban.py b/userge/plugins/admin/gban.py index 07e34b88a..7a93844dc 100644 --- a/userge/plugins/admin/gban.py +++ b/userge/plugins/admin/gban.py @@ -110,6 +110,21 @@ async def gban_user(message: Message): 'user_id': user_id, 'reason': reason, 'chat_ids': gbanned_chats}) + if Config.FBAN_CHAT_ID and not message.client.is_bot: + mention = None # to avoid peer id invalid + if message.reply_to_message and message.reply_to_message.from_user: + mention = message.reply_to_message.from_user.mention + elif message.entities: + for i in message.entities: + if i.type == "text_mention": + mention = i.user.mention + break + if mention: + await message.client.send_message( + Config.FBAN_CHAT_ID, + f"/fban {mention} {reason}" + ) + await CHANNEL.log(f'$FBAN #prid{user_id} ⬆️') replied = message.reply_to_message if replied: if replied.text: @@ -152,6 +167,21 @@ async def ungban_user(message: Message): f"\n\n**First Name:** [{firstname}](tg://user?id={user_id})\n" f"**User ID:** `{user_id}`") await GBAN_USER_BASE.delete_one({'firstname': firstname, 'user_id': user_id}) + if Config.FBAN_CHAT_ID and not message.client.is_bot: + mention = None # to avoid peer id invalid + if message.reply_to_message and message.reply_to_message.from_user: + mention = message.reply_to_message.from_user.mention + elif message.entities: + for i in message.entities: + if i.type == "text_mention": + mention = i.user.mention + break + if mention: + await message.client.send_message( + Config.FBAN_CHAT_ID, + f"/unfban {mention}" + ) + await CHANNEL.log(f'$UNFBAN #prid{user_id} ⬆️') LOG.info("UnGbanned %s", str(user_id))