premium dc 修复并且新增插件 (#19)

This commit is contained in:
汐洛呐 2022-06-23 23:41:03 +08:00 committed by GitHub
parent bd9a07826e
commit 12465bb9d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 16 deletions

51
dc/main.py Normal file
View File

@ -0,0 +1,51 @@
# -*- coding: UTF-8 -*-
'''
@File main.py
@Author 汐洛 @guimc233
@Date 2022/6/23 2:49
'''
from pyrogram import Client
from pagermaid.listener import listener
from pagermaid.utils import Message
from pyrogram.enums import ParseMode
@listener(command="dc",
description="查看本群dc分布, 查看你回复的人在哪个dc")
async def dc(bot: Client, context: Message):
context = await context.edit("Please wait...")
if context.reply_to_message:
user = (
context.reply_to_message.from_user
or context.reply_to_message.sender_chat
)
if not user:
return await context.edit("出错啦!")
try:
return await context.edit(f"您所在的位置: DC{user.dc_id}")
except:
return await context.edit("无法查询! 您是否设置了头像呢?我是否可以看到你的头像呢?")
count = await bot.get_chat_members_count(context.chat.id)
if count >= 10000 and context.arguments != "force":
return await context.edit("太...太多人了... 我会...会...会坏掉的...\n\n如果您执意要运行的的话,您可以使用指令 ,dc force")
users = bots_deleted = 0
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
else:
bots_deleted += 1
await context.edit(f"""DC:
> 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"]}**
> 已自动过滤掉 **{bots_deleted}** Bot / 死号
{'***请注意: 由于tg限制 我们只能遍历前10k人 此次获得到的数据并不完整***' if count >= 10000 else ''}""", parse_mode = ParseMode.MARKDOWN)

View File

@ -192,13 +192,13 @@
},
{
"name": "premium",
"version": "1.001",
"version": "1.002",
"section": "chat",
"maintainer": "xiluo",
"size": "3.2 kb",
"size": "2.0 kb",
"supported": true,
"des-short": "列出本群premium用户数量 列出本群dc分布",
"des": "列出本群premium用户数量(指令: ,premium) \n列出本群dc分布/查看某个人所在的dc服务器(指令: ,dc)"
"des-short": "列出本群premium用户数量",
"des": "列出本群premium用户数量(指令: ,premium)"
},
{
"name": "autochangename",
@ -209,6 +209,16 @@
"supported": true,
"des-short": "自动更新 last_name 为时间等。",
"des": "每 30 秒自动更新 last_name 为时间等小玩意。"
},
{
"name": "dc",
"version": "1.002",
"section": "chat",
"maintainer": "xiluo",
"size": "2.3 kb",
"supported": true,
"des-short": "列出本群dc分布/查看某个人所在的dc服务器",
"des": "列出本群dc分布/查看某个人所在的dc服务器(指令: ,dc)"
}
]
}

View File

@ -2,7 +2,7 @@
'''
@File main.py
@Author 汐洛 @guimc233
@Date 2022/6/23 2:49
@Date 2022/6/23 21:57
'''
from pyrogram import Client
@ -15,11 +15,11 @@ from pyrogram.enums import ChatMemberStatus, ParseMode
description="分遗产咯")
async def premium(bot: Client, context: Message):
context = await context.edit("Please wait...")
premium_users = 0
users = 0
premium_admins = 0
admins = 0
premium_users = users = admins = premium_admins = bots_deleted = 0
dc_ids = {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "failed": 0}
count = await bot.get_chat_members_count(context.chat.id)
if count >= 10000 and context.arguments != "force":
return await context.edit("太...太多人了... 我会...会...会坏掉的...\n\n如果您执意要运行的的话,您可以使用指令 ,premium force")
async for m in bot.get_chat_members(context.chat.id):
if not m.user.is_bot and not m.user.is_deleted:
users += 1
@ -33,15 +33,16 @@ async def premium(bot: Client, context: Message):
premium_admins += 1
if m.status in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
admins += 1
admin_part = 0
if admins == 0:
admin_part = "这个群没有管理吗???"
else:
admin_part = round((premium_admins/admins)*100, 2)
else:
bots_deleted += 1
await context.edit(f"""**分遗产咯**
管理员:
> 大会员: **{premium_admins}** / 总管理数: **{admins}** 分遗产占比: **{admin_part}%**
> 大会员: **{premium_admins}** / 总管理数: **{admins}** 分遗产占比: **{round((premium_admins/admins)*100, 2) if admins != 0 else '你群管理员全死号?',}%**
用户:
> 大会员: **{premium_users}** / 总用户数: **{users}** 分遗产占比: **{round((premium_users/users)*100, 2)}%**""", parse_mode = ParseMode.MARKDOWN)
> 大会员: **{premium_users}** / 总用户数: **{users}** 分遗产占比: **{round((premium_users/users)*100, 2)}%**
> 已自动过滤掉 **{bots_deleted}** Bot / 死号
{'***请注意: 由于tg限制 我们只能遍历前10k人 此次获得到的数据并不完整***' if count >= 10000 else ''}""", parse_mode = ParseMode.MARKDOWN)