2022-06-23 15:41:03 +00:00
|
|
|
|
# -*- coding: UTF-8 -*-
|
2023-07-01 12:18:58 +00:00
|
|
|
|
"""
|
2022-06-23 15:41:03 +00:00
|
|
|
|
@File :main.py
|
|
|
|
|
@Author :汐洛 @guimc233
|
|
|
|
|
@Date :2022/6/23 2:49
|
2023-07-01 12:18:58 +00:00
|
|
|
|
"""
|
2022-06-23 15:41:03 +00:00
|
|
|
|
|
|
|
|
|
from pyrogram import Client
|
2024-09-28 14:35:08 +00:00
|
|
|
|
|
|
|
|
|
from pagermaid.enums import Message
|
2022-06-23 15:41:03 +00:00
|
|
|
|
from pagermaid.listener import listener
|
|
|
|
|
from pyrogram.enums import ParseMode
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
|
|
|
|
|
|
@listener(command="dc", description="查看本群dc分布, 查看你回复的人在哪个dc")
|
2022-06-23 15:41:03 +00:00
|
|
|
|
async def dc(bot: Client, context: Message):
|
|
|
|
|
context = await context.edit("Please wait...")
|
|
|
|
|
if context.reply_to_message:
|
|
|
|
|
user = (
|
2023-07-01 12:18:58 +00:00
|
|
|
|
context.reply_to_message.from_user or context.reply_to_message.sender_chat
|
2022-06-23 15:41:03 +00:00
|
|
|
|
)
|
|
|
|
|
if not user:
|
|
|
|
|
return await context.edit("出错啦!")
|
|
|
|
|
try:
|
|
|
|
|
return await context.edit(f"您所在的位置: DC{user.dc_id}")
|
|
|
|
|
except:
|
|
|
|
|
return await context.edit("无法查询! 您是否设置了头像呢?我是否可以看到你的头像呢?")
|
2022-07-12 07:57:08 +00:00
|
|
|
|
if context.chat.id > 0:
|
|
|
|
|
try:
|
|
|
|
|
user = await bot.get_users(context.chat.id)
|
|
|
|
|
return await context.edit(f"他所在的位置: DC{user.dc_id}")
|
|
|
|
|
except:
|
|
|
|
|
return await context.edit("无法查询! 您是否设置了头像呢?我是否可以看到你的头像呢?")
|
2022-06-23 15:41:03 +00:00
|
|
|
|
count = await bot.get_chat_members_count(context.chat.id)
|
|
|
|
|
if count >= 10000 and context.arguments != "force":
|
2023-07-01 12:18:58 +00:00
|
|
|
|
return await context.edit(
|
|
|
|
|
"太...太多人了... 我会...会...会坏掉的...\n\n如果您执意要运行的的话,您可以使用指令 ,dc force"
|
|
|
|
|
)
|
2022-06-23 16:24:57 +00:00
|
|
|
|
users = bots = deleted = 0
|
2022-06-23 15:41:03 +00:00
|
|
|
|
dc_ids = {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "failed": 0}
|
|
|
|
|
async for m in bot.get_chat_members(context.chat.id, limit=9999):
|
|
|
|
|
if not m.user.is_bot and not m.user.is_deleted:
|
|
|
|
|
users += 1
|
|
|
|
|
try:
|
|
|
|
|
dc_ids[str(m.user.dc_id)] += 1
|
|
|
|
|
except:
|
|
|
|
|
dc_ids["failed"] += 1
|
2022-06-23 16:24:57 +00:00
|
|
|
|
elif m.user.is_bot:
|
|
|
|
|
bots += 1
|
2022-06-23 15:41:03 +00:00
|
|
|
|
else:
|
2022-06-23 16:24:57 +00:00
|
|
|
|
deleted += 1
|
2023-07-01 12:18:58 +00:00
|
|
|
|
await context.edit(
|
|
|
|
|
f"""DC:
|
2022-06-23 15:41:03 +00:00
|
|
|
|
> DC1用户: **{dc_ids["1"]}** 分遗产占比: **{round((dc_ids["1"]/users)*100, 2)}%**
|
|
|
|
|
> DC2用户: **{dc_ids["2"]}** 分遗产占比: **{round((dc_ids["2"]/users)*100, 2)}%**
|
|
|
|
|
> DC3用户: **{dc_ids["3"]}** 分遗产占比: **{round((dc_ids["3"]/users)*100, 2)}%**
|
|
|
|
|
> DC4用户: **{dc_ids["4"]}** 分遗产占比: **{round((dc_ids["4"]/users)*100, 2)}%**
|
|
|
|
|
> DC5用户: **{dc_ids["5"]}** 分遗产占比: **{round((dc_ids["5"]/users)*100, 2)}%**
|
|
|
|
|
> 无法获取在哪个DC的用户: **{dc_ids["failed"]}**
|
2022-06-23 16:24:57 +00:00
|
|
|
|
> 已自动过滤掉 **{bots}** 个 Bot, **{deleted}** 个 死号
|
2022-06-23 15:41:03 +00:00
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
|
{'***请注意: 由于tg限制 我们只能遍历前10k人 此次获得到的数据并不完整***' if count >= 10000 else ''}""",
|
|
|
|
|
parse_mode=ParseMode.MARKDOWN,
|
|
|
|
|
)
|