Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
711b749
1
Parent(s):
3dd3ca2
Minor changes
Browse files- Powers/plugins/admin.py +5 -5
- Powers/plugins/greetings.py +2 -3
- Powers/plugins/info.py +18 -5
- Powers/plugins/purge.py +7 -7
- Powers/plugins/report.py +4 -6
- Powers/plugins/start.py +7 -8
- Powers/plugins/utils.py +5 -4
- Powers/utils/chat_type.py +0 -41
- Powers/utils/custom_filters.py +13 -17
- Powers/utils/string.py +2 -3
Powers/plugins/admin.py
CHANGED
|
@@ -6,7 +6,7 @@ from Powers.vars import Config
|
|
| 6 |
from traceback import format_exc
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from pyrogram.types import Message
|
| 9 |
-
from
|
| 10 |
from Powers.utils.parser import mention_html
|
| 11 |
from Powers.database.approve_db import Approve
|
| 12 |
from Powers.database.reporting_db import Reporting
|
|
@@ -25,8 +25,8 @@ from pyrogram.errors import (
|
|
| 25 |
@Gojo.on_message(command("adminlist"))
|
| 26 |
async def adminlist_show(_, m: Message):
|
| 27 |
global ADMIN_CACHE
|
| 28 |
-
|
| 29 |
-
if
|
| 30 |
return await m.reply_text(
|
| 31 |
text="This command is made to be used in groups only!",
|
| 32 |
)
|
|
@@ -112,8 +112,8 @@ async def zombie_clean(c: Gojo, m: Message):
|
|
| 112 |
@Gojo.on_message(command("admincache"))
|
| 113 |
async def reload_admins(_, m: Message):
|
| 114 |
global TEMP_ADMIN_CACHE_BLOCK
|
| 115 |
-
|
| 116 |
-
if
|
| 117 |
return await m.reply_text(
|
| 118 |
"This command is made to be used in groups only!",
|
| 119 |
)
|
|
|
|
| 6 |
from traceback import format_exc
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from pyrogram.types import Message
|
| 9 |
+
from pyrogram.enums import ChatType
|
| 10 |
from Powers.utils.parser import mention_html
|
| 11 |
from Powers.database.approve_db import Approve
|
| 12 |
from Powers.database.reporting_db import Reporting
|
|
|
|
| 25 |
@Gojo.on_message(command("adminlist"))
|
| 26 |
async def adminlist_show(_, m: Message):
|
| 27 |
global ADMIN_CACHE
|
| 28 |
+
|
| 29 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 30 |
return await m.reply_text(
|
| 31 |
text="This command is made to be used in groups only!",
|
| 32 |
)
|
|
|
|
| 112 |
@Gojo.on_message(command("admincache"))
|
| 113 |
async def reload_admins(_, m: Message):
|
| 114 |
global TEMP_ADMIN_CACHE_BLOCK
|
| 115 |
+
|
| 116 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 117 |
return await m.reply_text(
|
| 118 |
"This command is made to be used in groups only!",
|
| 119 |
)
|
Powers/plugins/greetings.py
CHANGED
|
@@ -4,7 +4,6 @@ from Powers import DEV_USERS
|
|
| 4 |
from Powers.vars import Config
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
from pyrogram import enums, filters
|
| 7 |
-
from Powers.utils.chat_type import chattype
|
| 8 |
from Powers.database.antispam_db import GBan
|
| 9 |
from Powers.database.greetings_db import Greetings
|
| 10 |
from pyrogram.enums import ChatMemberStatus as CMS
|
|
@@ -20,6 +19,7 @@ from Powers.utils.string import (
|
|
| 20 |
# Initialize
|
| 21 |
gdb = GBan()
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
async def escape_mentions_using_curly_brackets_wl(
|
| 25 |
m: ChatMemberUpdated,
|
|
@@ -33,7 +33,6 @@ async def escape_mentions_using_curly_brackets_wl(
|
|
| 33 |
else:
|
| 34 |
user = m.old_chat_member.user if m.old_chat_member else m.from_user
|
| 35 |
if teks:
|
| 36 |
-
chat_type = await chattype(m)
|
| 37 |
teks = teks.format(
|
| 38 |
first=escape(user.first_name),
|
| 39 |
last=escape(user.last_name or user.first_name),
|
|
@@ -52,7 +51,7 @@ async def escape_mentions_using_curly_brackets_wl(
|
|
| 52 |
),
|
| 53 |
mention=await (mention_html(escape(user.first_name), user.id)),
|
| 54 |
chatname=escape(m.chat.title)
|
| 55 |
-
if
|
| 56 |
else escape(user.first_name),
|
| 57 |
id=user.id,
|
| 58 |
)
|
|
|
|
| 4 |
from Powers.vars import Config
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
from pyrogram import enums, filters
|
|
|
|
| 7 |
from Powers.database.antispam_db import GBan
|
| 8 |
from Powers.database.greetings_db import Greetings
|
| 9 |
from pyrogram.enums import ChatMemberStatus as CMS
|
|
|
|
| 19 |
# Initialize
|
| 20 |
gdb = GBan()
|
| 21 |
|
| 22 |
+
ChatType = enums.ChatType
|
| 23 |
|
| 24 |
async def escape_mentions_using_curly_brackets_wl(
|
| 25 |
m: ChatMemberUpdated,
|
|
|
|
| 33 |
else:
|
| 34 |
user = m.old_chat_member.user if m.old_chat_member else m.from_user
|
| 35 |
if teks:
|
|
|
|
| 36 |
teks = teks.format(
|
| 37 |
first=escape(user.first_name),
|
| 38 |
last=escape(user.last_name or user.first_name),
|
|
|
|
| 51 |
),
|
| 52 |
mention=await (mention_html(escape(user.first_name), user.id)),
|
| 53 |
chatname=escape(m.chat.title)
|
| 54 |
+
if m.chat.type != ChatType.PRIVATE
|
| 55 |
else escape(user.first_name),
|
| 56 |
id=user.id,
|
| 57 |
)
|
Powers/plugins/info.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime
|
|
| 5 |
from traceback import format_exc
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
from pyrogram.types import Message
|
| 8 |
-
from
|
| 9 |
from Powers.database.antispam_db import GBan
|
| 10 |
from Powers.utils.custom_filters import command
|
| 11 |
from Powers.utils.extract_user import extract_user
|
|
@@ -146,7 +146,21 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 146 |
username = chat.username
|
| 147 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
| 148 |
title = chat.title
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
is_scam = chat.is_scam
|
| 151 |
is_fake = chat.is_fake
|
| 152 |
description = chat.description
|
|
@@ -155,8 +169,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 155 |
dc_id = chat.dc_id
|
| 156 |
photo_id = chat.photo.big_file_id if chat.photo else None
|
| 157 |
can_save = chat.has_protected_content
|
| 158 |
-
linked_chat = chat.linked_chat
|
| 159 |
-
linked_id = chat.linked_chat.id
|
| 160 |
|
| 161 |
caption = f"""
|
| 162 |
🔰 <b>CHAT INFO</b> 🔰
|
|
@@ -176,7 +189,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 176 |
<b>👨🏿💻 Description</b>: <code>{description}</code>
|
| 177 |
<b>👪 Total members</b>: {members}
|
| 178 |
<b>🚫 Has Protected Content</b>: {can_save}
|
| 179 |
-
<b>🔗 Linked Chat</b>: @{linked_chat if linked_chat else
|
| 180 |
|
| 181 |
"""
|
| 182 |
|
|
|
|
| 5 |
from traceback import format_exc
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
from pyrogram.types import Message
|
| 8 |
+
from pyrogram.enums import ChatType
|
| 9 |
from Powers.database.antispam_db import GBan
|
| 10 |
from Powers.utils.custom_filters import command
|
| 11 |
from Powers.utils.extract_user import extract_user
|
|
|
|
| 146 |
username = chat.username
|
| 147 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
| 148 |
title = chat.title
|
| 149 |
+
if chat.type == ChatType.CHANNEL:
|
| 150 |
+
type_ = "channel"
|
| 151 |
+
|
| 152 |
+
if chat.type == ChatType.GROUP:
|
| 153 |
+
type_ = "group"
|
| 154 |
+
|
| 155 |
+
if chat.type == ChatType.SUPERGROUP:
|
| 156 |
+
type_ = "supergroup"
|
| 157 |
+
|
| 158 |
+
if chat.type == ChatType.PRIVATE:
|
| 159 |
+
type_ = "private"
|
| 160 |
+
|
| 161 |
+
if chat.type == ChatType.BOT:
|
| 162 |
+
type_ = "bot"
|
| 163 |
+
|
| 164 |
is_scam = chat.is_scam
|
| 165 |
is_fake = chat.is_fake
|
| 166 |
description = chat.description
|
|
|
|
| 169 |
dc_id = chat.dc_id
|
| 170 |
photo_id = chat.photo.big_file_id if chat.photo else None
|
| 171 |
can_save = chat.has_protected_content
|
| 172 |
+
linked_chat = chat.linked_chat
|
|
|
|
| 173 |
|
| 174 |
caption = f"""
|
| 175 |
🔰 <b>CHAT INFO</b> 🔰
|
|
|
|
| 189 |
<b>👨🏿💻 Description</b>: <code>{description}</code>
|
| 190 |
<b>👪 Total members</b>: {members}
|
| 191 |
<b>🚫 Has Protected Content</b>: {can_save}
|
| 192 |
+
<b>🔗 Linked Chat</b>: @{linked_chat.id if linked_chat else "Noe Linked"}
|
| 193 |
|
| 194 |
"""
|
| 195 |
|
Powers/plugins/purge.py
CHANGED
|
@@ -2,15 +2,15 @@ from asyncio import sleep
|
|
| 2 |
from Powers import SUPPORT_GROUP
|
| 3 |
from Powers.bot_class import Gojo
|
| 4 |
from pyrogram.types import Message
|
| 5 |
-
from
|
| 6 |
from pyrogram.errors import RPCError, MessageDeleteForbidden
|
| 7 |
from Powers.utils.custom_filters import command, admin_filter
|
| 8 |
|
| 9 |
|
| 10 |
@Gojo.on_message(command("purge") & admin_filter)
|
| 11 |
async def purge(c: Gojo, m: Message):
|
| 12 |
-
|
| 13 |
-
if
|
| 14 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 15 |
return
|
| 16 |
|
|
@@ -56,8 +56,8 @@ async def purge(c: Gojo, m: Message):
|
|
| 56 |
|
| 57 |
@Gojo.on_message(command("spurge") & admin_filter)
|
| 58 |
async def spurge(c: Gojo, m: Message):
|
| 59 |
-
|
| 60 |
-
if
|
| 61 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 62 |
return
|
| 63 |
|
|
@@ -100,8 +100,8 @@ async def spurge(c: Gojo, m: Message):
|
|
| 100 |
group=9,
|
| 101 |
)
|
| 102 |
async def del_msg(c: Gojo, m: Message):
|
| 103 |
-
|
| 104 |
-
if
|
| 105 |
return
|
| 106 |
|
| 107 |
if m.reply_to_message:
|
|
|
|
| 2 |
from Powers import SUPPORT_GROUP
|
| 3 |
from Powers.bot_class import Gojo
|
| 4 |
from pyrogram.types import Message
|
| 5 |
+
from pyrogram.enums import ChatType
|
| 6 |
from pyrogram.errors import RPCError, MessageDeleteForbidden
|
| 7 |
from Powers.utils.custom_filters import command, admin_filter
|
| 8 |
|
| 9 |
|
| 10 |
@Gojo.on_message(command("purge") & admin_filter)
|
| 11 |
async def purge(c: Gojo, m: Message):
|
| 12 |
+
|
| 13 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 14 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 15 |
return
|
| 16 |
|
|
|
|
| 56 |
|
| 57 |
@Gojo.on_message(command("spurge") & admin_filter)
|
| 58 |
async def spurge(c: Gojo, m: Message):
|
| 59 |
+
|
| 60 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 61 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
| 62 |
return
|
| 63 |
|
|
|
|
| 100 |
group=9,
|
| 101 |
)
|
| 102 |
async def del_msg(c: Gojo, m: Message):
|
| 103 |
+
|
| 104 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 105 |
return
|
| 106 |
|
| 107 |
if m.reply_to_message:
|
Powers/plugins/report.py
CHANGED
|
@@ -4,11 +4,10 @@ from Powers.bot_class import Gojo
|
|
| 4 |
from pyrogram.errors import RPCError
|
| 5 |
from Powers.utils.kbhelpers import ikb
|
| 6 |
from Powers import LOGGER, SUPPORT_STAFF
|
| 7 |
-
from Powers.utils.chat_type import chattype
|
| 8 |
from Powers.utils.parser import mention_html
|
| 9 |
from pyrogram.types import Message, CallbackQuery
|
| 10 |
from Powers.database.reporting_db import Reporting
|
| 11 |
-
from pyrogram.enums import ChatMembersFilter as cmf
|
| 12 |
from Powers.utils.custom_filters import command, admin_filter
|
| 13 |
|
| 14 |
|
|
@@ -19,8 +18,7 @@ async def report_setting(_, m: Message):
|
|
| 19 |
args = m.text.split()
|
| 20 |
db = Reporting(m.chat.id)
|
| 21 |
|
| 22 |
-
|
| 23 |
-
if chat_type == "private":
|
| 24 |
if len(args) >= 2:
|
| 25 |
option = args[1].lower()
|
| 26 |
if option in ("yes", "on", "true"):
|
|
@@ -64,8 +62,8 @@ async def report_setting(_, m: Message):
|
|
| 64 |
|
| 65 |
@Gojo.on_message(command("report") & filters.group)
|
| 66 |
async def report_watcher(c: Gojo, m: Message):
|
| 67 |
-
|
| 68 |
-
if
|
| 69 |
return
|
| 70 |
|
| 71 |
if not m.from_user:
|
|
|
|
| 4 |
from pyrogram.errors import RPCError
|
| 5 |
from Powers.utils.kbhelpers import ikb
|
| 6 |
from Powers import LOGGER, SUPPORT_STAFF
|
|
|
|
| 7 |
from Powers.utils.parser import mention_html
|
| 8 |
from pyrogram.types import Message, CallbackQuery
|
| 9 |
from Powers.database.reporting_db import Reporting
|
| 10 |
+
from pyrogram.enums import ChatMembersFilter as cmf, ChatType
|
| 11 |
from Powers.utils.custom_filters import command, admin_filter
|
| 12 |
|
| 13 |
|
|
|
|
| 18 |
args = m.text.split()
|
| 19 |
db = Reporting(m.chat.id)
|
| 20 |
|
| 21 |
+
if m.chat.type == ChatType.PRIVATE:
|
|
|
|
| 22 |
if len(args) >= 2:
|
| 23 |
option = args[1].lower()
|
| 24 |
if option in ("yes", "on", "true"):
|
|
|
|
| 62 |
|
| 63 |
@Gojo.on_message(command("report") & filters.group)
|
| 64 |
async def report_watcher(c: Gojo, m: Message):
|
| 65 |
+
|
| 66 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 67 |
return
|
| 68 |
|
| 69 |
if not m.from_user:
|
Powers/plugins/start.py
CHANGED
|
@@ -5,10 +5,9 @@ from pyrogram import enums, filters
|
|
| 5 |
from Powers.utils.kbhelpers import ikb
|
| 6 |
from Powers import LOGGER, HELP_COMMANDS
|
| 7 |
from Powers.utils.extras import StartPic
|
| 8 |
-
from Powers.utils.chat_type import chattype
|
| 9 |
from Powers.utils.custom_filters import command
|
| 10 |
from pyrogram.types import Message, CallbackQuery
|
| 11 |
-
from pyrogram.enums import ChatMemberStatus as CMS
|
| 12 |
from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
|
| 13 |
from Powers.utils.start_utils import (
|
| 14 |
gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
|
|
@@ -59,8 +58,8 @@ async def close_admin_callback(_, q: CallbackQuery):
|
|
| 59 |
command("start") & (filters.group | filters.private),
|
| 60 |
)
|
| 61 |
async def start(c: Gojo, m: Message):
|
| 62 |
-
|
| 63 |
-
if
|
| 64 |
if len(m.text.split()) > 1:
|
| 65 |
help_option = (m.text.split(None, 1)[1]).lower()
|
| 66 |
|
|
@@ -188,8 +187,8 @@ async def help_menu(_, m: Message):
|
|
| 188 |
LOGGER.info(
|
| 189 |
f"{m.from_user.id} fetched help for '{help_option}' text in {m.chat.id}",
|
| 190 |
)
|
| 191 |
-
|
| 192 |
-
if
|
| 193 |
if len(help_msg) >= 1026:
|
| 194 |
await m.reply_text(
|
| 195 |
help_msg, parse_mode=enums.ParseMode.MARKDOWN, quote=True
|
|
@@ -219,8 +218,8 @@ async def help_menu(_, m: Message):
|
|
| 219 |
),
|
| 220 |
)
|
| 221 |
else:
|
| 222 |
-
|
| 223 |
-
if
|
| 224 |
keyboard = ikb(
|
| 225 |
[
|
| 226 |
*(await gen_cmds_kb(m)),
|
|
|
|
| 5 |
from Powers.utils.kbhelpers import ikb
|
| 6 |
from Powers import LOGGER, HELP_COMMANDS
|
| 7 |
from Powers.utils.extras import StartPic
|
|
|
|
| 8 |
from Powers.utils.custom_filters import command
|
| 9 |
from pyrogram.types import Message, CallbackQuery
|
| 10 |
+
from pyrogram.enums import ChatMemberStatus as CMS, ChatType
|
| 11 |
from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
|
| 12 |
from Powers.utils.start_utils import (
|
| 13 |
gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
|
|
|
|
| 58 |
command("start") & (filters.group | filters.private),
|
| 59 |
)
|
| 60 |
async def start(c: Gojo, m: Message):
|
| 61 |
+
|
| 62 |
+
if m.chat.type == ChatType.PRIVATE:
|
| 63 |
if len(m.text.split()) > 1:
|
| 64 |
help_option = (m.text.split(None, 1)[1]).lower()
|
| 65 |
|
|
|
|
| 187 |
LOGGER.info(
|
| 188 |
f"{m.from_user.id} fetched help for '{help_option}' text in {m.chat.id}",
|
| 189 |
)
|
| 190 |
+
|
| 191 |
+
if m.chat.type == ChatType.PRIVATE:
|
| 192 |
if len(help_msg) >= 1026:
|
| 193 |
await m.reply_text(
|
| 194 |
help_msg, parse_mode=enums.ParseMode.MARKDOWN, quote=True
|
|
|
|
| 218 |
),
|
| 219 |
)
|
| 220 |
else:
|
| 221 |
+
|
| 222 |
+
if m.chat.type == ChatType.PRIVATE:
|
| 223 |
keyboard = ikb(
|
| 224 |
[
|
| 225 |
*(await gen_cmds_kb(m)),
|
Powers/plugins/utils.py
CHANGED
|
@@ -11,6 +11,7 @@ from pyrogram import enums, filters
|
|
| 11 |
from Powers.utils.http_helper import *
|
| 12 |
from Powers.database.users_db import Users
|
| 13 |
from pyrogram.errors import MessageTooLong
|
|
|
|
| 14 |
from Powers.utils.custom_filters import command
|
| 15 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 16 |
from wikipedia.exceptions import PageError, DisambiguationError
|
|
@@ -118,12 +119,12 @@ async def get_lyrics(_, m: Message):
|
|
| 118 |
)
|
| 119 |
async def id_info(c: Gojo, m: Message):
|
| 120 |
|
| 121 |
-
|
| 122 |
-
if
|
| 123 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
| 124 |
return
|
| 125 |
|
| 126 |
-
if
|
| 127 |
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
| 128 |
return
|
| 129 |
|
|
@@ -155,7 +156,7 @@ async def id_info(c: Gojo, m: Message):
|
|
| 155 |
f"{(await mention_html(user.first_name, user.id))}'s ID is <code>{user.id}</code>.",
|
| 156 |
parse_mode=enums.ParseMode.HTML,
|
| 157 |
)
|
| 158 |
-
elif
|
| 159 |
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
| 160 |
else:
|
| 161 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
|
|
|
| 11 |
from Powers.utils.http_helper import *
|
| 12 |
from Powers.database.users_db import Users
|
| 13 |
from pyrogram.errors import MessageTooLong
|
| 14 |
+
from pyrogram.enums import ChatType
|
| 15 |
from Powers.utils.custom_filters import command
|
| 16 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 17 |
from wikipedia.exceptions import PageError, DisambiguationError
|
|
|
|
| 119 |
)
|
| 120 |
async def id_info(c: Gojo, m: Message):
|
| 121 |
|
| 122 |
+
|
| 123 |
+
if m.chat.type == ChatType.SUPERGROUP and not m.reply_to_message:
|
| 124 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
| 125 |
return
|
| 126 |
|
| 127 |
+
if m.chat.type == ChatType.PRIVATE and not m.reply_to_message:
|
| 128 |
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
| 129 |
return
|
| 130 |
|
|
|
|
| 156 |
f"{(await mention_html(user.first_name, user.id))}'s ID is <code>{user.id}</code>.",
|
| 157 |
parse_mode=enums.ParseMode.HTML,
|
| 158 |
)
|
| 159 |
+
elif m.chat.type == ChatType.PRIVATE:
|
| 160 |
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
| 161 |
else:
|
| 162 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
Powers/utils/chat_type.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
from Powers.bot_class import Gojo
|
| 2 |
-
from pyrogram.types import Message
|
| 3 |
-
from pyrogram.enums import ChatType
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
async def chattype(m: Message):
|
| 7 |
-
# To get chat type with message
|
| 8 |
-
|
| 9 |
-
if m.chat.type == ChatType.CHANNEL:
|
| 10 |
-
ct = "channel"
|
| 11 |
-
|
| 12 |
-
if m.chat.type == ChatType.PRIVATE:
|
| 13 |
-
ct = "private"
|
| 14 |
-
|
| 15 |
-
if m.chat.type == ChatType.GROUP:
|
| 16 |
-
ct = "group"
|
| 17 |
-
|
| 18 |
-
if m.chat.type == ChatType.SUPERGROUP:
|
| 19 |
-
ct = "supergroup"
|
| 20 |
-
|
| 21 |
-
return ct
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
async def c_type(c: Gojo, chat_id):
|
| 25 |
-
# To get chat type with chat id
|
| 26 |
-
|
| 27 |
-
ch = await c.get_chat(chat_id)
|
| 28 |
-
|
| 29 |
-
if ch.type == ChatType.CHANNEL:
|
| 30 |
-
ct = "channel"
|
| 31 |
-
|
| 32 |
-
if ch.type == ChatType.GROUP:
|
| 33 |
-
ct = "group"
|
| 34 |
-
|
| 35 |
-
if ch.type == ChatType.SUPERGROUP:
|
| 36 |
-
ct = "supergroup"
|
| 37 |
-
|
| 38 |
-
if ch.type == ChatType.PRIVATE:
|
| 39 |
-
ct = "private"
|
| 40 |
-
|
| 41 |
-
return ct
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powers/utils/custom_filters.py
CHANGED
|
@@ -1,14 +1,12 @@
|
|
| 1 |
from shlex import split
|
| 2 |
-
from pyrogram import enums
|
| 3 |
from Powers.vars import Config
|
| 4 |
from typing import List, Union
|
| 5 |
from pyrogram.filters import create
|
| 6 |
-
from Powers.utils.chat_type import chattype
|
| 7 |
from re import escape, compile as compile_re
|
| 8 |
from Powers.database.disable_db import Disabling
|
| 9 |
from pyrogram.types import Message, CallbackQuery
|
| 10 |
from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
|
| 11 |
-
from pyrogram.enums import ChatMemberStatus as CMS
|
| 12 |
from pyrogram.errors import RPCError, UserNotParticipant
|
| 13 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 14 |
|
|
@@ -32,8 +30,7 @@ def command(
|
|
| 32 |
if date:
|
| 33 |
return # reaction
|
| 34 |
|
| 35 |
-
|
| 36 |
-
if chattype:
|
| 37 |
return
|
| 38 |
|
| 39 |
if m and not m.from_user:
|
|
@@ -69,7 +66,7 @@ def command(
|
|
| 69 |
m.command = [matches.group(1)]
|
| 70 |
if matches.group(1) not in flt.commands:
|
| 71 |
return False
|
| 72 |
-
if bool(m.chat and m.chat.type in {
|
| 73 |
try:
|
| 74 |
user_status = (await m.chat.get_member(m.from_user.id)).status
|
| 75 |
except UserNotParticipant:
|
|
@@ -116,8 +113,7 @@ async def bot_admin_check_func(_, __, m: Message or CallbackQuery):
|
|
| 116 |
if isinstance(m, CallbackQuery):
|
| 117 |
m = m.message
|
| 118 |
|
| 119 |
-
|
| 120 |
-
if chat_type != "supergroup":
|
| 121 |
return False
|
| 122 |
|
| 123 |
# Telegram and GroupAnonyamousBot
|
|
@@ -150,8 +146,8 @@ async def admin_check_func(_, __, m: Message or CallbackQuery):
|
|
| 150 |
if isinstance(m, CallbackQuery):
|
| 151 |
m = m.message
|
| 152 |
|
| 153 |
-
|
| 154 |
-
if
|
| 155 |
return False
|
| 156 |
|
| 157 |
# Telegram and GroupAnonyamousBot
|
|
@@ -186,7 +182,7 @@ async def owner_check_func(_, __, m: Message or CallbackQuery):
|
|
| 186 |
if isinstance(m, CallbackQuery):
|
| 187 |
m = m.message
|
| 188 |
|
| 189 |
-
if bool(m.chat and m.chat.type in {
|
| 190 |
return False
|
| 191 |
|
| 192 |
# Bypass the bot devs, sudos and owner
|
|
@@ -213,8 +209,8 @@ async def restrict_check_func(_, __, m: Message or CallbackQuery):
|
|
| 213 |
if isinstance(m, CallbackQuery):
|
| 214 |
m = m.message
|
| 215 |
|
| 216 |
-
|
| 217 |
-
if
|
| 218 |
return False
|
| 219 |
|
| 220 |
# Bypass the bot devs, sudos and owner
|
|
@@ -237,7 +233,7 @@ async def promote_check_func(_, __, m):
|
|
| 237 |
if isinstance(m, CallbackQuery):
|
| 238 |
m = m.message
|
| 239 |
|
| 240 |
-
if bool(m.chat and m.chat.type in {
|
| 241 |
return False
|
| 242 |
|
| 243 |
# Bypass the bot devs, sudos and owner
|
|
@@ -260,8 +256,8 @@ async def changeinfo_check_func(_, __, m):
|
|
| 260 |
if isinstance(m, CallbackQuery):
|
| 261 |
m = m.message
|
| 262 |
|
| 263 |
-
|
| 264 |
-
if
|
| 265 |
await m.reply_text("This command is made to be used in groups not in pm!")
|
| 266 |
return False
|
| 267 |
|
|
@@ -289,7 +285,7 @@ async def can_pin_message_func(_, __, m):
|
|
| 289 |
if isinstance(m, CallbackQuery):
|
| 290 |
m = m.message
|
| 291 |
|
| 292 |
-
if not bool(m.chat and m.chat.type in {
|
| 293 |
await m.reply_text("This command is made to be used in groups not in pm!")
|
| 294 |
return False
|
| 295 |
|
|
|
|
| 1 |
from shlex import split
|
|
|
|
| 2 |
from Powers.vars import Config
|
| 3 |
from typing import List, Union
|
| 4 |
from pyrogram.filters import create
|
|
|
|
| 5 |
from re import escape, compile as compile_re
|
| 6 |
from Powers.database.disable_db import Disabling
|
| 7 |
from pyrogram.types import Message, CallbackQuery
|
| 8 |
from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
|
| 9 |
+
from pyrogram.enums import ChatMemberStatus as CMS, ChatType
|
| 10 |
from pyrogram.errors import RPCError, UserNotParticipant
|
| 11 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 12 |
|
|
|
|
| 30 |
if date:
|
| 31 |
return # reaction
|
| 32 |
|
| 33 |
+
if m.chat and m.chat.type == ChatType.CHANNEL:
|
|
|
|
| 34 |
return
|
| 35 |
|
| 36 |
if m and not m.from_user:
|
|
|
|
| 66 |
m.command = [matches.group(1)]
|
| 67 |
if matches.group(1) not in flt.commands:
|
| 68 |
return False
|
| 69 |
+
if bool(m.chat and m.chat.type in {ChatType.SUPERGROUP}):
|
| 70 |
try:
|
| 71 |
user_status = (await m.chat.get_member(m.from_user.id)).status
|
| 72 |
except UserNotParticipant:
|
|
|
|
| 113 |
if isinstance(m, CallbackQuery):
|
| 114 |
m = m.message
|
| 115 |
|
| 116 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
|
|
|
| 117 |
return False
|
| 118 |
|
| 119 |
# Telegram and GroupAnonyamousBot
|
|
|
|
| 146 |
if isinstance(m, CallbackQuery):
|
| 147 |
m = m.message
|
| 148 |
|
| 149 |
+
|
| 150 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 151 |
return False
|
| 152 |
|
| 153 |
# Telegram and GroupAnonyamousBot
|
|
|
|
| 182 |
if isinstance(m, CallbackQuery):
|
| 183 |
m = m.message
|
| 184 |
|
| 185 |
+
if bool(m.chat and m.chat.type in {ChatType.SUPERGROUP}):
|
| 186 |
return False
|
| 187 |
|
| 188 |
# Bypass the bot devs, sudos and owner
|
|
|
|
| 209 |
if isinstance(m, CallbackQuery):
|
| 210 |
m = m.message
|
| 211 |
|
| 212 |
+
|
| 213 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 214 |
return False
|
| 215 |
|
| 216 |
# Bypass the bot devs, sudos and owner
|
|
|
|
| 233 |
if isinstance(m, CallbackQuery):
|
| 234 |
m = m.message
|
| 235 |
|
| 236 |
+
if bool(m.chat and m.chat.type in {ChatType.SUPERGROUP}):
|
| 237 |
return False
|
| 238 |
|
| 239 |
# Bypass the bot devs, sudos and owner
|
|
|
|
| 256 |
if isinstance(m, CallbackQuery):
|
| 257 |
m = m.message
|
| 258 |
|
| 259 |
+
|
| 260 |
+
if m.chat.type != ChatType.SUPERGROUP:
|
| 261 |
await m.reply_text("This command is made to be used in groups not in pm!")
|
| 262 |
return False
|
| 263 |
|
|
|
|
| 285 |
if isinstance(m, CallbackQuery):
|
| 286 |
m = m.message
|
| 287 |
|
| 288 |
+
if not bool(m.chat and m.chat.type in {ChatType.SUPERGROUP}):
|
| 289 |
await m.reply_text("This command is made to be used in groups not in pm!")
|
| 290 |
return False
|
| 291 |
|
Powers/utils/string.py
CHANGED
|
@@ -2,7 +2,7 @@ from time import time
|
|
| 2 |
from html import escape
|
| 3 |
from typing import List
|
| 4 |
from re import compile as compile_re
|
| 5 |
-
from
|
| 6 |
from Powers.utils.parser import escape_markdown
|
| 7 |
from pyrogram.types import Message, InlineKeyboardButton
|
| 8 |
|
|
@@ -123,7 +123,6 @@ async def escape_mentions_using_curly_brackets(
|
|
| 123 |
) -> str:
|
| 124 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
| 125 |
if teks:
|
| 126 |
-
chat_type = await chattype(m)
|
| 127 |
teks = teks.format(
|
| 128 |
first=escape(m.from_user.first_name),
|
| 129 |
last=escape(m.from_user.last_name or m.from_user.first_name),
|
|
@@ -142,7 +141,7 @@ async def escape_mentions_using_curly_brackets(
|
|
| 142 |
else [escape(m.from_user.first_name)],
|
| 143 |
),
|
| 144 |
chatname=escape(m.chat.title)
|
| 145 |
-
if
|
| 146 |
else escape(m.from_user.first_name),
|
| 147 |
id=m.from_user.id,
|
| 148 |
)
|
|
|
|
| 2 |
from html import escape
|
| 3 |
from typing import List
|
| 4 |
from re import compile as compile_re
|
| 5 |
+
from pyrogram.enums import ChatType
|
| 6 |
from Powers.utils.parser import escape_markdown
|
| 7 |
from pyrogram.types import Message, InlineKeyboardButton
|
| 8 |
|
|
|
|
| 123 |
) -> str:
|
| 124 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
| 125 |
if teks:
|
|
|
|
| 126 |
teks = teks.format(
|
| 127 |
first=escape(m.from_user.first_name),
|
| 128 |
last=escape(m.from_user.last_name or m.from_user.first_name),
|
|
|
|
| 141 |
else [escape(m.from_user.first_name)],
|
| 142 |
),
|
| 143 |
chatname=escape(m.chat.title)
|
| 144 |
+
if m.chat.type != ChatType.SUPERGROUP
|
| 145 |
else escape(m.from_user.first_name),
|
| 146 |
id=m.from_user.id,
|
| 147 |
)
|