mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 10:16:57 +00:00
autochangename premium 添加插件 (Sourcery refactored) (#18)
Co-authored-by: guimc233 <xiluo@guimc.ltd> Co-authored-by: Sourcery AI <> Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
This commit is contained in:
parent
726456f298
commit
bd9a07826e
42
autochangename/main.py
Normal file
42
autochangename/main.py
Normal file
@ -0,0 +1,42 @@
|
||||
""" Module to automate message deletion. """
|
||||
|
||||
import traceback
|
||||
from asyncio import sleep
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pagermaid.utils import pip_install
|
||||
|
||||
pip_install("emoji")
|
||||
|
||||
from emoji import emojize
|
||||
from pagermaid import logs, scheduler, bot
|
||||
from pagermaid.listener import listener
|
||||
|
||||
|
||||
|
||||
auto_change_name_init = False
|
||||
dizzy = emojize(":dizzy:", use_aliases=True)
|
||||
cake = emojize(":cake:", use_aliases=True)
|
||||
all_time_emoji_name = ["clock12", "clock1230", "clock1", "clock130", "clock2", "clock230", "clock3", "clock330",
|
||||
"clock4", "clock430", "clock5", "clock530", "clock6", "clock630", "clock7", "clock730", "clock8",
|
||||
"clock830", "clock9", "clock930", "clock10", "clock1030", "clock11", "clock1130"]
|
||||
time_emoji_symb = [
|
||||
emojize(f":{s}:", use_aliases=True) for s in all_time_emoji_name
|
||||
]
|
||||
|
||||
|
||||
@scheduler.scheduled_job("interval", seconds=30, id="autochangename")
|
||||
async def change_name_auto():
|
||||
try:
|
||||
time_cur = datetime.utcnow().replace(tzinfo=timezone.utc).astimezone(timezone(
|
||||
timedelta(hours=8))).strftime('%H:%M:%S:%p:%a')
|
||||
hour, minu, seco, p, abbwn = time_cur.split(':')
|
||||
shift = 1 if int(minu) > 30 else 0
|
||||
hsym = time_emoji_symb[(int(hour) % 12) * 2 + shift]
|
||||
_last_name = f"{hour}:{minu} {p} UTC+8 {hsym}"
|
||||
await bot.update_profile(last_name=_last_name)
|
||||
me = await bot.get_me()
|
||||
if me.last_name != _last_name:
|
||||
raise Exception("修改 last_name 失败")
|
||||
except Exception as e:
|
||||
trac = "\n".join(traceback.format_exception(e))
|
||||
await logs.info(f"更新失败! \n{trac}")
|
20
list.json
20
list.json
@ -189,6 +189,26 @@
|
||||
"supported": true,
|
||||
"des-short": "删除当前对话您发送的特定数量的消息。",
|
||||
"des": "删除当前对话您发送的特定数量的消息。\n指令:-dme"
|
||||
},
|
||||
{
|
||||
"name": "premium",
|
||||
"version": "1.001",
|
||||
"section": "chat",
|
||||
"maintainer": "xiluo",
|
||||
"size": "3.2 kb",
|
||||
"supported": true,
|
||||
"des-short": "列出本群premium用户数量 列出本群dc分布",
|
||||
"des": "列出本群premium用户数量(指令: ,premium) \n列出本群dc分布/查看某个人所在的dc服务器(指令: ,dc)"
|
||||
},
|
||||
{
|
||||
"name": "autochangename",
|
||||
"version": "1.111",
|
||||
"section": "profile",
|
||||
"maintainer": "xtaodada、xiluo",
|
||||
"size": "1.6 kb",
|
||||
"supported": true,
|
||||
"des-short": "自动更新 last_name 为时间等。",
|
||||
"des": "每 30 秒自动更新 last_name 为时间等小玩意。"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
47
premium/main.py
Normal file
47
premium/main.py
Normal file
@ -0,0 +1,47 @@
|
||||
# -*- 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, client
|
||||
from pyrogram.enums import ChatMemberStatus, ParseMode
|
||||
|
||||
|
||||
@listener(command="premium",
|
||||
description="分遗产咯")
|
||||
async def premium(bot: Client, context: Message):
|
||||
context = await context.edit("Please wait...")
|
||||
premium_users = 0
|
||||
users = 0
|
||||
premium_admins = 0
|
||||
admins = 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):
|
||||
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
|
||||
if m.user.is_premium:
|
||||
premium_users += 1
|
||||
if m.status in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
|
||||
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)
|
||||
await context.edit(f"""**分遗产咯**
|
||||
|
||||
管理员:
|
||||
> 大会员: **{premium_admins}** / 总管理数: **{admins}** 分遗产占比: **{admin_part}%**
|
||||
|
||||
用户:
|
||||
> 大会员: **{premium_users}** / 总用户数: **{users}** 分遗产占比: **{round((premium_users/users)*100, 2)}%**""", parse_mode = ParseMode.MARKDOWN)
|
Loading…
Reference in New Issue
Block a user