Untitled

mail@pastecode.io avatar
unknown
python
a year ago
2.0 kB
8
Indexable
Never
from pyrogram import Client,filters,idle
import asyncio
import json
from pyrogram.errors.exceptions.bad_request_400 import PeerFlood

async def whome(client):
  async with client:
    me = await client.get_me()
    print(me.id)

async def join_chat(client, chat):
  async with client:
    await client.join_chat(chat)

async def leave_chat(client, chat):
  async with client:
    await client.leave_chat(chat)
async def send_message(client, chat, message):
  async with client:
    try:
      await client.send_message(chat, message)
    except PeerFlood:
      return
async def make_client(num, session, opt, chat,message):
  client = Client(name=f"{num}", session_string=session)
  if opt == "whois":
    await whome(client)
  if opt == "join":
    await join_chat(client,chat)
  if opt == "leave":
    await leave_chat(client,chat)
  if opt == "send":
    await send_message(client,chat,message)


async def main(opt, chat = None, message = None):
  with open("accounts.json") as file:
    data = json.load(file)
    tasks = [asyncio.create_task(make_client(x,y,opt, chat, message)) for x,y in data["Accs"].items()]
  await asyncio.gather(*tasks)

app = Client("ixelizm", 1038911,"94d21cd31f1d54ff715ead95b1777bc1")

@app.on_message(filters.command("join",".") &filters.me)
async def joinf(_,m):
  message = await m.edit("`Working For Func...`")
  await main("join", m.chat.username)
  await message.reply("`Success!`")
@app.on_message(filters.command("leave",".") &filters.me)
async def leavef(_,m):
  message = await m.edit("`Working For Func...`")
  await main("leave", m.chat.username)
  await message.reply("`Success!`")

@app.on_message(filters.command("send",".") &filters.me)
async def leavef(_,m):
  text = m.text.split(".send ")[1]
  message = await m.edit("`Working For Func...`")
  if not m.reply_to_message:
    await main("send", chat = m.chat.username, message = text)
  else:
    await main("send", chat = m.reply_to_message.from_user.username, message = text)
  await message.reply("`Success!`")