Example #1
0
async def forward_msg_S2(c, m):

    chat_id = m.chat.id

    msg = m.text

    if r.getbit("forward:msg", 0) == 1 and msg and not msg.startswith("/"):
        try:
            if msg == "*" or int(msg):
                await c.send_chat_action(chat_id=chat_id, action="typing")
                await asyncio.sleep(0.15)

                resp = await c.send_message(chat_id=chat_id, 
                    text="""⚡️ **Forward Msg** ⚡️
                        \nپیام مورد نظر خود را برای فوروارد کردن ارسال نمایید
                        \n.
                    """
                )
                
                r.set("Msg:Number", msg)
                r.set("Previous:Msg:ID", resp.message_id)
                r.setbit("forward:msg", 0, 0)
                r.setbit("forward:msg", 1, 1)

        except ValueError:
            await c.send_chat_action(chat_id=chat_id, action='typing')
            await asyncio.sleep(0.10)

            await c.send_message(chat_id=chat_id, 
                text="""⚡️ **Forward Msg** ⚡️
                    \nورودی صحیح نمیباشد! ❌
                    \nلطفا فرمت مشخص شده را رعایت کنید.                    
                    \n.
                """
            )
Example #2
0
async def forward_msg_S3(c, m):

    chat_id = m.chat.id 
    
    if r.getbit("forward:msg", 1) == 1:

        previous_msg = int(r.get("Previous:Msg:ID"))

        if m.message_id == int(previous_msg)+1:                
            counter = 1
            current_user = await c.get_me()

            for user_id in r.smembers(f"users:{current_user.id}"):
                await c.send_chat_action(chat_id=chat_id, action='typing')
                await asyncio.sleep(0.10)

                await c.forward_messages(
                    chat_id = user_id,
                    from_chat_id = chat_id,
                    message_ids = m.message_id
                )

                if r.get("Msg:Number") != "*" and counter == int(r.get("Msg:Number")):
                    break

                else:
                    counter += 1

            await c.send_chat_action(chat_id=chat_id, action='typing')
            await asyncio.sleep(0.10)
            await c.send_message(chat_id=chat_id, text="پیام شما با موفقت ارسال شد ✅")

            r.setbit("forward:msg", 1, 0)
Example #3
0
async def get_message_id(c, m):

    msg = m.text

    if r.getbit("del:msg", 0) == 1 and msg and not msg.startswith("/"):
        chat_id = m.chat.id
        await c.send_chat_action(chat_id=chat_id, action="typing")

        if msg == "*":
            r.delete("Messages")
            r.setbit("del:msg", 0, 0)
            await c.send_message(chat_id=chat_id,
                                 text="""⚡️ **حذف همه پیام ها** ⚡️\n
                \nتمامی جملات شما با موفقیت حذف شد ✅""")

        else:
            msg_number = r.sscan("Messages", match=f"{msg}:*")[1]

            if msg_number:
                r.srem("Messages", msg_number[0])
                r.setbit("del:msg", 0, 0)
                await c.send_message(chat_id=chat_id,
                                     text="""⚡️ **حذف پیام** ⚡️\n
                    \n جمله شما با موفقیت حذف شد ✅""")

            else:
                messages = "⚡️ **حذف پیام** ⚡️\n\n❌جمله ای یافت نشد❌"

                await c.send_message(chat_id=chat_id, text=messages)
async def join_chat(c, m):

    msg = m.text

    if r.getbit("join:chat:status",
                0) == 1 and msg and not msg.startswith("/"):
        chat_id = m.chat.id

        await asyncio.create_task(chat_action(c, chat_id))

        try:
            if "joinchat" in msg:
                resp = await c.join_chat(chat_id=m.text)

            else:
                resp = await c.join_chat(chat_id=msg.split("/")[-1])

            await c.send_message(chat_id=chat_id,
                                 text="شما با موفقیت به گروه پیوستید ✅")

            if r.get("join:msg"):
                try:
                    await asyncio.create_task(chat_action(c, resp.id))
                    await c.send_message(chat_id=resp.id,
                                         text=r.get("join:msg"))

                except errors.ChatAdminRequired:
                    pass

        except errors.UserAlreadyParticipant:
            await c.send_message(chat_id=chat_id,
                                 text="❌ .شما قبلا در این گروه عضو شده اید ❌")

        except errors.UsernameInvalid:
            await c.send_message(chat_id=chat_id,
                                 text="❌ لطفا لینک صحیح را ارسال کنید. ❌")

        except errors.ChannelInvalid:
            await c.send_message(chat_id=chat_id,
                                 text="❌ لینک ارسال شده نام+عتبر است  ❌")

        except errors.InviteHashExpired:
            await c.send_message(chat_id=chat_id,
                                 text="❌ لینک شما منقضی شده است. ❌")

        except errors.UsernameNotOccupied:
            await c.send_message(chat_id=chat_id,
                                 text="❌ هیچ گروهی با این لینک وجود ندارد ❌")

        except errors.FloodWait as wait:
            await c.send_message(
                chat_id=chat_id,
                text=
                f"❌ شماره به مدت {wait.x} ثانیه محدوده شده اید لطفا بعد از زمان محدودیت دوباره تلاش کنید ❌"
            )

        finally:
            r.setbit("join:chat:status", 0, 0)
async def get_join_msg(c, m):

    chat_id = m.chat.id

    await asyncio.create_task(chat_action(c, chat_id))
    await c.send_message(chat_id=chat_id,
                         text="پیام مورد نظر خود را ارسال کنید")

    r.setbit("join:msg:status", 0, 1)
async def get_link_chat(c, m):

    chat_id = m.chat.id

    await asyncio.create_task(chat_action(c, chat_id))

    await c.send_message(chat_id=chat_id,
                         text="لینک گروه مدنظر خود را ارسال کنید")

    r.setbit("join:chat:status", 0, 1)
Example #7
0
async def add_msg(c, m):
    messages = """⚡️ **اضافه کردن پیام** ⚡️
        \nلطفا جمله یا جملات خود را ارسال کنید و در انتها کامند زیر را ارسال کنید:
        \n/save
    """

    chat_id = m.chat.id

    await c.send_chat_action(chat_id=chat_id, action="typing")

    await c.send_message(chat_id=chat_id, text=messages)

    r.setbit("add:msg", 0, 1)
async def set_join_msg(c, m):

    msg = m.text

    if r.getbit("join:msg:status", 0) == 1 and msg and not msg.startswith("/"):
        chat_id = m.chat.id

        await asyncio.create_task(chat_action(c, chat_id))

        r.set("join:msg", msg)

        await c.send_message(chat_id=chat_id,
                             text="پیام شما با موفقیت ذخیره شد ✅")

        r.setbit("join:msg:status", 0, 0)
Example #9
0
async def forward_msg_S1(c, m):

    message = """⚡️ **Forward Msg** ⚡️
        \n☔️ برای ارسال پیام به تعداد مشخصی از یوزر ها  یک `عدد` را ارسال کنید
        \n☔️ برای ارسال فوروارد به همه یوزر ها  علامت  `*` را ارسال کنید
        \n.    
    """
    
    chat_id = m.chat.id 

    await c.send_chat_action(chat_id=chat_id, action="typing")
    await asyncio.sleep(0.15)
  
    await c.send_message(chat_id=chat_id, text=message)
    
    # First Step
    r.setbit("forward:msg", 0, 1)

    # Second Step
    r.setbit("forward:msg", 1, 0)
Example #10
0
async def del_msg(c, m):

    chat_id = m.chat.id

    await c.send_chat_action(chat_id=chat_id, action="typing")

    if r.exists("Messages"):

        message = """⚡️ **حذف کردن جمه ها** ⚡️            
            \nلطفا شماره جمله مورد نظر خود ارسال کنید. 🗑            
            \nو یا برای حذف همه جمله ها  `*` را ارسال نمایید
            \n.
        """

        await c.send_message(chat_id=chat_id, text=message)

        r.setbit("del:msg", 0, 1)

    else:
        await c.send_message(chat_id=chat_id, text="❌جمله ای یافت نشد❌")
Example #11
0
async def get_input(c, m):

    msg = m.text

    if r.getbit("add:msg", 0) == 1 and msg and not msg.startswith("/"):

        msg_counter = r.incr("New:Msg")

        r.sadd("Messages", f"{msg_counter}:{msg}")

    elif msg == "/save":
        chat_id = m.chat.id

        await c.send_chat_action(chat_id=chat_id, action="typing")

        await c.send_message(chat_id=chat_id,
                             text="""⚡️ **اضافه کردن پیام** ⚡️
            \n✅ جمله های شما با موفقیت ذخیره شد
            \n.
        """)

        r.setbit("add:msg", 0, 0)