mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 01:57:47 +00:00
silly_girl 新增两个API (Sourcery refactored) (#77)
Co-authored-by: cdle <50124752+cdle@users.noreply.github.com> Co-authored-by: Sourcery AI <>
This commit is contained in:
parent
2f0cf2a4f9
commit
88377ced67
@ -4,9 +4,12 @@ from pagermaid.listener import listener
|
||||
from pagermaid.enums import Message
|
||||
from pagermaid.single_utils import sqlite
|
||||
from pagermaid.utils import client, edit_delete
|
||||
from pagermaid import bot
|
||||
# from pagermaid import bot
|
||||
from pyrogram.enums.chat_type import ChatType
|
||||
from pagermaid.hook import Hook
|
||||
from datetime import datetime, timedelta
|
||||
from pagermaid.services import bot
|
||||
from pyrogram.types import ChatPermissions
|
||||
|
||||
import json
|
||||
|
||||
@ -57,6 +60,26 @@ class SillyGirl:
|
||||
replies = json.loads(req_data.text)
|
||||
results = []
|
||||
for reply in replies:
|
||||
if reply["command"]:
|
||||
try:
|
||||
id = reply["id"]
|
||||
cid = reply["chat_id"]
|
||||
uid = reply["sender_id"]
|
||||
if reply["command"] == "ban":
|
||||
if id != 0 :
|
||||
await bot.restrict_chat_member(cid, uid, ChatPermissions(),datetime.now() + timedelta(seconds=id))
|
||||
else:
|
||||
await bot.restrict_chat_member(cid, uid, ChatPermissions())
|
||||
elif reply["command"] == "unban":
|
||||
await bot.restrict_chat_member(cid, uid, ChatPermissions(),datetime.now() + timedelta(seconds=60))
|
||||
elif reply["command"] == "kick":
|
||||
if id != 0 :
|
||||
await bot.ban_chat_member(cid,uid,datetime.now() + timedelta(seconds=60))
|
||||
else:
|
||||
await bot.ban_chat_member(cid,uid)
|
||||
except Exception as e:
|
||||
print(e,"----")
|
||||
continue
|
||||
if reply["delete"]:
|
||||
try:
|
||||
await bot.edit_message(reply["chat_id"], reply["id"], "打错字了,呱呱~")
|
||||
@ -127,7 +150,12 @@ async def handle_receive(message: Message):
|
||||
reply_to_sender_id = 0
|
||||
chat_id = message.chat.id
|
||||
sender_id = 0
|
||||
user_name = ""
|
||||
chat_name = message.chat.title or ""
|
||||
if message.from_user:
|
||||
user_name = message.from_user.first_name
|
||||
if message.from_user.last_name:
|
||||
user_name += f" {message.from_user.last_name}"
|
||||
sender_id = message.from_user.id
|
||||
if reply := message.reply_to_message:
|
||||
reply_to = reply.id
|
||||
@ -141,6 +169,8 @@ async def handle_receive(message: Message):
|
||||
reply_to_sender_id = message.reply_to_message.from_user.id
|
||||
if sillyGirl.init != True:
|
||||
sillyGirl.init_connect_info("")
|
||||
# if reply_to_sender_id==0 or sillyGirl.self_user_id == reply_to_sender_id:
|
||||
# reply_to = 0
|
||||
await sillyGirl.poll(
|
||||
[
|
||||
{
|
||||
@ -153,6 +183,8 @@ async def handle_receive(message: Message):
|
||||
'bot_id': sillyGirl.self_user_id,
|
||||
'is_group': message.chat.type
|
||||
in [ChatType.SUPERGROUP, ChatType.CHANNEL],
|
||||
'user_name': user_name,
|
||||
'chat_name': chat_name,
|
||||
}
|
||||
]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user