xtao-some 新增获取频道/群组死号数

This commit is contained in:
xtaodada 2021-02-15 12:39:10 +08:00
parent d0c5afcfce
commit 45b7182701
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 25 additions and 5 deletions

View File

@ -62,13 +62,13 @@
},
{
"name": "xtao-some",
"version": "1.14",
"version": "1.154",
"section": "daily",
"maintainer": "xtaodada",
"size": "18.8 kb",
"supported": true,
"des-short": "一大堆便民功能。",
"des": "超多功能 例如 -ip -ipping -guess 等。"
"des": "超多功能 例如 -ip -ipping -guess -t -getdel 等。"
},
{
"name": "yb-dl",
@ -362,7 +362,7 @@
},
{
"name": "keyword",
"version": "2.55",
"version": "2.551",
"section": "chat",
"maintainer": "c3b2a,xtaodada",
"size": "36.7 kb",

View File

@ -1,11 +1,10 @@
""" Pagermaid plugin base. """
import json, requests, re
from translate import Translator as trans
from urllib.parse import urlparse
from pagermaid import bot, log
from pagermaid.listener import listener, config
from pagermaid.utils import clear_emojis, obtain_message, attach_log
from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors import ChatAdminRequiredError
from os import remove
@ -254,3 +253,24 @@ async def tx_t(context):
await attach_log(result, context.chat_id, "translation.txt", context.id)
return
await context.edit(result)
@listener(is_plugin=True, outgoing=True, command="getdel",
description="获取当前群组/频道的死号数。")
async def getdel(context):
""" PagerMaid getdel. """
cid = str(context.chat_id)
pri = cid.startswith('-100')
if pri:
member_count = 0
try:
await context.edit('遍历成员中。。。')
chat = await context.get_chat()
async for member in bot.iter_participants(chat):
if member.deleted:
member_count += 1
await context.edit(f'此频道/群组的死号数:`{member_count}`')
except ChatAdminRequiredError:
await context.edit('未加入此频道。')
else:
await context.edit("请在在群组/频道发送。")