Skip to content

Commit cb48d9c

Browse files
authored
Created get_messages seperately
1 parent eaa9d7e commit cb48d9c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

helper_func.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import base64
2+
import asyncio
23
from pyrogram import filters
3-
from config import FORCE_SUB_CHANNEL, ADMINS
4+
from config import FORCE_SUB_CHANNEL, ADMINS, CHANNEL_ID
45
from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant
6+
from pyrogram.errors import FloodWait
57

68
async def is_subscribed(filter, client, message):
79
if not FORCE_SUB_CHANNEL:
@@ -31,4 +33,26 @@ async def decode(base64_string):
3133
string = string_bytes.decode("ascii")
3234
return string
3335

36+
async def get_messages(client, message_ids):
37+
messages = []
38+
total_messages = 0
39+
while total_messages != len(message_ids):
40+
temb_ids = message_ids[total_messages:total_messages+200]
41+
try:
42+
msgs = await client.get_messages(
43+
chat_id=CHANNEL_ID,
44+
message_ids=temb_ids
45+
)
46+
except FloodWait as e:
47+
await asyncio.sleep(e.x)
48+
msgs = await client.get_messages(
49+
chat_id=CHANNEL_ID,
50+
message_ids=temb_ids
51+
)
52+
except:
53+
pass
54+
total_messages += len(temb_ids)
55+
messages.extend(msgs)
56+
return messages
57+
3458
subscribed = filters.create(is_subscribed)

0 commit comments

Comments
 (0)