Skip to content

Commit 245289c

Browse files
committed
update assistant to latest pyrogram
1 parent 95a66d5 commit 245289c

13 files changed

+62
-53
lines changed

assistant/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .logger import logging # noqa
1010
from .config import Config # noqa
1111
from .bot import bot # noqa
12-
from . import filters # noqa
12+
from . import cus_filters # noqa

assistant/filters.py assistant/cus_filters.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
import asyncio
1212

13-
from pyrogram import Filters, Message
13+
from pyrogram import filters, Client
14+
from pyrogram.types import Message
1415

1516
from . import Config, logging
1617

1718
_LOG = logging.getLogger(__name__)
1819
_FETCHING = False
1920

2021

21-
async def _is_admin_or_dev(_, msg: Message) -> bool:
22+
async def _is_admin_or_dev(_, bot: Client, msg: Message) -> bool:
2223
global _FETCHING # pylint: disable=global-statement
2324
if msg.chat.id not in Config.AUTH_CHATS:
2425
return False
@@ -34,7 +35,7 @@ async def _is_admin_or_dev(_, msg: Message) -> bool:
3435
admins = []
3536
_LOG.info("fetching data from [%s] ...", msg.chat.id)
3637
# pylint: disable=protected-access
37-
async for c_m in msg._client.iter_chat_members(msg.chat.id):
38+
async for c_m in bot.iter_chat_members(msg.chat.id):
3839
if c_m.status in ("creator", "administrator"):
3940
admins.append(c_m.user.id)
4041
Config.ADMINS[msg.chat.id] = tuple(admins)
@@ -44,5 +45,5 @@ async def _is_admin_or_dev(_, msg: Message) -> bool:
4445
return msg.from_user.id in Config.ADMINS[msg.chat.id]
4546

4647

47-
auth_chats = Filters.chat(list(Config.AUTH_CHATS))
48-
auth_users = Filters.create(_is_admin_or_dev)
48+
auth_chats = filters.chat(list(Config.AUTH_CHATS))
49+
auth_users = filters.create(_is_admin_or_dev)

assistant/plugins/alive.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
import time
1010
import random
1111

12-
from pyrogram import Message, Filters, InlineKeyboardMarkup, InlineKeyboardButton
12+
from pyrogram import filters
13+
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
1314
from pyrogram.errors.exceptions import FileIdInvalid, FileReferenceEmpty
1415
from pyrogram.errors.exceptions.bad_request_400 import BadRequest
1516

16-
from assistant import bot, filters, versions
17+
from assistant import bot, cus_filters, versions
1718
from assistant.bot import START_TIME
1819
from assistant.utils import time_formatter
1920

2021
LOGO_DATA = []
2122
MSG_IDS = [499509, 499428, 496502, 496360, 496498]
2223

2324

24-
@bot.on_message(Filters.command("alive") & filters.auth_chats)
25+
@bot.on_message(filters.command("alive") & cus_filters.auth_chats)
2526
async def _alive(_, message: Message):
2627
try:
2728
await _sendit(message.chat.id)

assistant/plugins/antiflood.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
import time
1010

11-
from pyrogram import Message, Filters
12-
from assistant import bot, filters
11+
from pyrogram import filters
12+
from pyrogram.types import Message
13+
from assistant import bot, cus_filters
1314

1415
DATA = {}
1516

@@ -18,8 +19,8 @@
1819
MIN_DELAY = 3
1920

2021

21-
@bot.on_message(
22-
Filters.incoming & ~Filters.edited & filters.auth_chats & ~filters.auth_users, group=1)
22+
@bot.on_message(filters.incoming & ~filters.edited & cus_filters.auth_chats
23+
& ~cus_filters.auth_users, group=1)
2324
async def _flood(_, message: Message):
2425
chat_flood = DATA.get(message.chat.id)
2526
if chat_flood is None:

assistant/plugins/gadmin.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
import time
1010
import asyncio
1111

12-
from pyrogram import Message, Filters, ChatPermissions
12+
from pyrogram import filters
13+
from pyrogram.types import Message, ChatPermissions
1314
from pyrogram.errors import (
1415
FloodWait, UserAdminInvalid, UsernameInvalid, PeerIdInvalid, UserIdInvalid)
1516

16-
from assistant import bot, filters
17+
from assistant import bot, cus_filters
1718
from assistant.utils import (
1819
is_dev, is_self, is_admin, sed_sticker, check_rights, check_bot_rights)
1920

2021

2122
@bot.on_message( # tban in queue
22-
Filters.command("ban") & filters.auth_chats & filters.auth_users)
23+
filters.command("ban") & cus_filters.auth_chats & cus_filters.auth_users)
2324
async def _ban_user(_, msg: Message):
2425
chat_id = msg.chat.id
2526
if not await check_rights(chat_id, msg.from_user.id, "can_restrict_members"):
@@ -74,7 +75,7 @@ async def _ban_user(_, msg: Message):
7475

7576

7677
@bot.on_message(
77-
Filters.command("unban") & filters.auth_chats & filters.auth_users)
78+
filters.command("unban") & cus_filters.auth_chats & cus_filters.auth_users)
7879
async def _unban_user(_, msg: Message):
7980
chat_id = msg.chat.id
8081
if not await check_rights(chat_id, msg.from_user.id, "can_restrict_members"):
@@ -110,7 +111,7 @@ async def _unban_user(_, msg: Message):
110111

111112

112113
@bot.on_message(
113-
Filters.command("kick") & filters.auth_chats & filters.auth_users)
114+
filters.command("kick") & cus_filters.auth_chats & cus_filters.auth_users)
114115
async def _kick_user(_, msg: Message):
115116
chat_id = msg.chat.id
116117
if not await check_rights(chat_id, msg.from_user.id, "can_restrict_members"):
@@ -165,7 +166,7 @@ async def _kick_user(_, msg: Message):
165166

166167

167168
@bot.on_message(
168-
Filters.command("promote") & filters.auth_chats & filters.auth_users)
169+
filters.command("promote") & cus_filters.auth_chats & cus_filters.auth_users)
169170
async def _promote_user(_, msg: Message):
170171
chat_id = msg.chat.id
171172
if not await check_rights(chat_id, msg.from_user.id, "can_promote_members"):
@@ -206,7 +207,7 @@ async def _promote_user(_, msg: Message):
206207

207208

208209
@bot.on_message(
209-
Filters.command("demote") & filters.auth_chats & filters.auth_users)
210+
filters.command("demote") & cus_filters.auth_chats & cus_filters.auth_users)
210211
async def _demote_user(_, msg: Message):
211212
chat_id = msg.chat.id
212213
if not await check_rights(chat_id, msg.from_user.id, "can_promote_members"):
@@ -250,7 +251,7 @@ async def _demote_user(_, msg: Message):
250251

251252

252253
@bot.on_message( # tmute in queue
253-
Filters.command("mute") & filters.auth_chats & filters.auth_users)
254+
filters.command("mute") & cus_filters.auth_chats & cus_filters.auth_users)
254255
async def _mute_user(_, msg: Message):
255256
chat_id = msg.chat.id
256257
if not await check_rights(chat_id, msg.from_user.id, "can_restrict_members"):
@@ -307,7 +308,7 @@ async def _mute_user(_, msg: Message):
307308

308309

309310
@bot.on_message(
310-
Filters.command("unmute") & filters.auth_chats & filters.auth_users)
311+
filters.command("unmute") & cus_filters.auth_chats & cus_filters.auth_users)
311312
async def _unmute_user(_, msg: Message):
312313
chat_id = msg.chat.id
313314
if not await check_rights(chat_id, msg.from_user.id, "can_restrict_members"):
@@ -356,7 +357,7 @@ async def _unmute_user(_, msg: Message):
356357

357358

358359
@bot.on_message(
359-
Filters.command("zombies") & filters.auth_chats & filters.auth_users)
360+
filters.command("zombies") & cus_filters.auth_chats & cus_filters.auth_users)
360361
async def _zombie_clean(_, msg: Message):
361362
chat_id = msg.chat.id
362363
if "clean" in msg.text.lower():
@@ -405,7 +406,7 @@ async def _zombie_clean(_, msg: Message):
405406

406407

407408
@bot.on_message(
408-
Filters.command("pin") & filters.auth_chats & filters.auth_users)
409+
filters.command("pin") & cus_filters.auth_chats & cus_filters.auth_users)
409410
async def _pin(_, msg: Message):
410411
chat_id = msg.chat.id
411412
if not await check_rights(chat_id, msg.from_user.id, "can_pin_messages"):
@@ -433,7 +434,7 @@ async def _pin(_, msg: Message):
433434

434435

435436
@bot.on_message(
436-
Filters.command("unpin") & filters.auth_chats & filters.auth_users)
437+
filters.command("unpin") & cus_filters.auth_chats & cus_filters.auth_users)
437438
async def _unpin(_, msg: Message):
438439
chat_id = msg.chat.id
439440
if not await check_rights(chat_id, msg.from_user.id, "can_pin_messages"):

assistant/plugins/id.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#
77
# All rights reserved.
88

9-
from pyrogram import Message, Filters
9+
from pyrogram import filters
10+
from pyrogram.types import Message
1011

11-
from assistant import bot, filters
12+
from assistant import bot, cus_filters
1213

1314

14-
@bot.on_message(Filters.command("id") & filters.auth_chats)
15+
@bot.on_message(filters.command("id") & cus_filters.auth_chats)
1516
async def _id(_, message: Message):
1617
msg = message.reply_to_message or message
1718
out_str = f"👥 **Chat ID** : `{(msg.forward_from_chat or msg.chat).id}`\n"

assistant/plugins/json.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#
77
# All rights reserved.
88

9-
from pyrogram import Message, Filters
9+
from pyrogram import filters
10+
from pyrogram.types import Message
1011

11-
from assistant import bot, filters, Config
12+
from assistant import bot, cus_filters, Config
1213

1314

14-
@bot.on_message(Filters.command("json") & filters.auth_chats & filters.auth_users)
15+
@bot.on_message(filters.command("json") & cus_filters.auth_chats & cus_filters.auth_users)
1516
async def _json(_, message: Message):
1617
msg = str(message.reply_to_message) if message.reply_to_message else str(message)
1718
if len(msg) > Config.MAX_MSG_LENGTH:

assistant/plugins/paste.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
import aiohttp
1212
from aiohttp import ClientResponseError, ServerTimeoutError, TooManyRedirects
13+
from pyrogram import filters
14+
from pyrogram.types import Message
1315

14-
from pyrogram import Message, Filters
15-
16-
from assistant import bot, filters, Config
16+
from assistant import bot, cus_filters, Config
1717

1818
DOGBIN_URL = "https://del.dog/"
1919
NEKOBIN_URL = "https://nekobin.com/"
2020

2121

22-
@bot.on_message(Filters.command("paste") & filters.auth_chats)
22+
@bot.on_message(filters.command("paste") & cus_filters.auth_chats)
2323
async def dogbin_paste(_, message: Message):
2424
""" pastes the text directly to dogbin """
2525
cmd = len(message.text)
@@ -58,7 +58,7 @@ async def dogbin_paste(_, message: Message):
5858
await msg.edit("`Failed to reach Dogbin`")
5959

6060

61-
@bot.on_message(Filters.command("neko") & filters.auth_chats)
61+
@bot.on_message(filters.command("neko") & cus_filters.auth_chats)
6262
async def nekobin_paste(_, message: Message):
6363
""" pastes the text directly to nekobin """
6464
cmd = len(message.text)
@@ -93,7 +93,7 @@ async def nekobin_paste(_, message: Message):
9393
await msg.edit("`Failed to reach Nekobin`")
9494

9595

96-
@bot.on_message(Filters.command("getpaste") & filters.auth_chats)
96+
@bot.on_message(filters.command("getpaste") & cus_filters.auth_chats)
9797
async def get_paste_(_, message: Message):
9898
""" fetches the content of a dogbin or nekobin URL """
9999
if message.text and len(message.text) == 9:

assistant/plugins/ping.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
from datetime import datetime
1010

11-
from pyrogram import Message, Filters
11+
from pyrogram import filters
12+
from pyrogram.types import Message
1213

13-
from assistant import bot, filters
14+
from assistant import bot, cus_filters
1415

1516

16-
@bot.on_message(Filters.command("ping") & filters.auth_chats)
17+
@bot.on_message(filters.command("ping") & cus_filters.auth_chats)
1718
async def _ping(_, message: Message):
1819
start = datetime.now()
1920
replied = await message.reply('`Pong!`')

assistant/plugins/reply.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#
77
# All rights reserved.
88

9-
from pyrogram import Message, Filters
9+
from pyrogram import filters
10+
from pyrogram.types import Message
1011

11-
from assistant import bot, filters
12+
from assistant import bot, cus_filters
1213

1314

14-
@bot.on_message(Filters.command("reply") & filters.auth_chats & filters.auth_users)
15+
@bot.on_message(filters.command("reply") & cus_filters.auth_chats & cus_filters.auth_users)
1516
async def _reply(_, message: Message):
1617
replid = message.reply_to_message
1718
if not replid:

assistant/plugins/warn.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
import time
1010

11-
from pyrogram import (
12-
Message, Filters, CallbackQuery, ChatPermissions,
11+
from pyrogram import filters
12+
from pyrogram.types import (
13+
Message, CallbackQuery, ChatPermissions,
1314
InlineKeyboardMarkup, InlineKeyboardButton)
1415

15-
from assistant import bot, filters
16+
from assistant import bot, cus_filters
1617
from assistant.utils import is_admin, is_dev, is_self, sed_sticker
1718

1819
WARN_LIMIT = 5
@@ -22,7 +23,7 @@
2223

2324

2425
@bot.on_message(
25-
Filters.command("warn") & filters.auth_chats & filters.auth_users)
26+
filters.command("warn") & cus_filters.auth_chats & cus_filters.auth_users)
2627
async def _warn_user(_, msg: Message):
2728
global WARN_MODE, WARN_LIMIT # pylint: disable=global-statement
2829

@@ -109,7 +110,7 @@ async def _warn_user(_, msg: Message):
109110
await replied.reply_text(r_t, reply_markup=keyboard)
110111

111112

112-
@bot.on_callback_query(Filters.regex(pattern=r"rm_warn\((.+?)\)"))
113+
@bot.on_callback_query(filters.regex(pattern=r"rm_warn\((.+?)\)"))
113114
async def _remove_warn(_, c_q: CallbackQuery):
114115
user_id = int(c_q.matches[0].group(1))
115116
if is_admin(c_q.message.chat.id, c_q.from_user.id, check_devs=True):
@@ -132,7 +133,7 @@ async def _remove_warn(_, c_q: CallbackQuery):
132133

133134

134135
@bot.on_message(
135-
Filters.command("setwarn") & filters.auth_chats & filters.auth_users)
136+
filters.command("setwarn") & cus_filters.auth_chats & cus_filters.auth_users)
136137
async def _set_warn_mode_and_limit(_, msg: Message):
137138
global WARN_MODE, WARN_LIMIT # pylint: disable=global-statement
138139
cmd = len(msg.text)
@@ -161,7 +162,7 @@ async def _set_warn_mode_and_limit(_, msg: Message):
161162

162163

163164
@bot.on_message(
164-
Filters.command("resetwarn") & filters.auth_chats & filters.auth_users)
165+
filters.command("resetwarn") & cus_filters.auth_chats & cus_filters.auth_users)
165166
async def _reset_all_warns(_, msg: Message):
166167
replied = msg.reply_to_message
167168
if not replied:
@@ -182,7 +183,7 @@ async def _reset_all_warns(_, msg: Message):
182183
await msg.reply("`User already not have any warn.`")
183184

184185

185-
@bot.on_message(Filters.command("warns") & filters.auth_chats)
186+
@bot.on_message(filters.command("warns") & cus_filters.auth_chats)
186187
async def _check_warns_of_user(_, msg: Message):
187188
global WARN_LIMIT # pylint: disable=global-statement
188189
replied = msg.reply_to_message

assistant/utils/tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# All rights reserved.
88

9-
from pyrogram import Message
9+
from pyrogram.types import Message
1010

1111
from assistant import bot, Config
1212

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
git+https://github.com/pyrogram/pyrogram.git@asyncio-dev
21
aiofiles
32
aiohttp
3+
pyrogram
44
python-dotenv

0 commit comments

Comments
 (0)