fix-owner-my
This commit is contained in:
parent
bf4beaf59e
commit
467dbb6879
|
@ -1,6 +1,7 @@
|
|||
from storage import Profile, scan
|
||||
from api import get_member, send_message, get_chat_administrators
|
||||
from utils.mention import userdata_extract
|
||||
import json
|
||||
|
||||
|
||||
async def construct_unlink_buttons(actor):
|
||||
|
@ -53,19 +54,20 @@ async def handle_command_my(msg, state):
|
|||
|
||||
async def handle_command_owner_my(msg):
|
||||
chat_id = msg["chat"]["id"]
|
||||
r = await get_chat_administrators(chat_id)
|
||||
print(r)
|
||||
owner_id = ""
|
||||
for admin in r["result"]:
|
||||
if admin["status"] == "creator":
|
||||
owner_id = str(admin["user"]["id"])
|
||||
break
|
||||
if owner_id:
|
||||
owner = Profile.get(owner_id, msg)
|
||||
_uids, members = scan()
|
||||
for mdata in members:
|
||||
m = json.loads(mdata.decode("utf-8"))
|
||||
if owner_id in m["parents"]:
|
||||
if str(m["id"]) not in owner["children"]:
|
||||
owner["children"].append(str(m["id"]))
|
||||
Profile.save(owner)
|
||||
if chat_id < 0: # is not private
|
||||
r = await get_chat_administrators(chat_id)
|
||||
print(r)
|
||||
owner_id = ""
|
||||
for admin in r["result"]:
|
||||
if admin["status"] == "creator":
|
||||
owner_id = str(admin["user"]["id"])
|
||||
break
|
||||
if owner_id:
|
||||
owner = Profile.get(owner_id, msg)
|
||||
_uids, members = scan()
|
||||
for mdata in members:
|
||||
m = json.loads(mdata.decode("utf-8"))
|
||||
if owner_id in m["parents"]:
|
||||
if str(m["id"]) not in owner["children"]:
|
||||
owner["children"].append(str(m["id"]))
|
||||
Profile.save(owner)
|
||||
|
|
Loading…
Reference in New Issue
Block a user