Пример #1
0
 def wear_cloth(self, clths, client):
     items = self.server.redis.smembers(f"uid:{client.uid}:items")
     for cloth in clths:
         if cloth["clid"]:
             tmp = f"{cloth['tpid']}_{cloth['clid']}"
         else:
             tmp = cloth["tpid"]
         if tmp not in items:
             return
     wearing = self.server.redis.smembers(f"uid:{client.uid}:wearing")
     for cloth in wearing:
         self.server.inv[client.uid].change_wearing(cloth, False)
     for cloth in clths:
         if cloth["clid"]:
             tmp = f"{cloth['tpid']}_{cloth['clid']}"
         else:
             tmp = cloth["tpid"]
         self.server.inv[client.uid].change_wearing(tmp, True)
     inv = self.server.inv[client.uid].get()
     clths = self.server.get_clothes(client.uid, type_=2)
     ccltn = self.server.get_clothes(client.uid, type_=3)
     client.send([
         "a.clths.wear", {
             "inv": inv,
             "clths": clths,
             "ccltn": ccltn,
             "cn": "",
             "ctp": "casual"
         }
     ])
     refresh_avatar(client, self.server)
Пример #2
0
 def reset_avatar_name(self, msg, client):
     privileges = self.server.modules["cp"].privileges
     user_data = self.server.get_user_data(client.uid)
     if user_data["role"] < privileges["RENAME_AVATAR"]:
         return
     uid = str(msg[2]["uid"])
     name = msg[2]["n"]
     if not self.server.redis.lindex(f"uid:{uid}:appearance", 0):
         return
     self.server.redis.lset(f"uid:{uid}:appearance", 0, name)
     for tmp in self.server.online.copy():
         if tmp.uid == uid:
             refresh_avatar(tmp, self.server)
             break
Пример #3
0
 async def join_clan(self, cid, uid):
     rid = int(uid)
     r = self.server.redis
     await r.set(f"uid:{uid}:clan", cid)
     await r.sadd(f"clans:{cid}:m", uid)
     await r.set(f"clans:{cid}:m:{uid}:role", 0)
     clan = await self.get_clan(cid)
     if uid in self.server.online:
         tmp = self.server.online[uid]
         await tmp.send(["ntf.cli", {"cli": {"tg": clan["tag"],
                                             "icn": clan["icon"], "acv": 0,
                                             "ctl": clan["name"], "clv": 1,
                                             "crl": 0, "crst": 0,
                                             "cid": int(cid)}}])
         await tmp.send(["crq.alr", {"rid": rid}])
         loop = asyncio.get_event_loop()
         loop.create_task(refresh_avatar(tmp, self.server))
     act = await self.server.redis.get(f"uid:{uid}:act")
     if act:
         act = int(act)
     else:
         act = 0
     message = ["clmb.adm", {"clmr": {"uid": uid, "jd": 1, "rl": 0,
                                      "cam": {"ah": [], "cid": 1,
                                              "ap": act},
                                      "cid": int(cid), "ccn": 0}}]
     inv = {"c": {"cfrn": {"id": "cfrn", "it": []},
                  "crc": {"id": "crc", "it": []}}}
     members = {}
     for member in clan["members"]:
         act = await self.server.redis.get(f"uid:{member}:act")
         if act:
             act = int(act)
         else:
             act = 0
         members[member] = {"uid": member, "jd": 1,
                            "rl": clan["members"][member]["role"],
                            "cam": {"ah": [], "cid": 1, "ap": act},
                            "ccn": 0}
     tmp = {"cinv": inv, "st": 0, "mmbs": members, "lvl": clan["lvl"],
            "crid": clan["owner"], "ttl": clan["name"], "ccn": 0,
            "pvt": False, "crdt": clan["create_date"], "tg": clan["tag"],
            "icn": clan["icon"], "clrtg": 0, "hpc": True, "id": int(cid)}
     act = await self.server.modules["ca"]._get_rating(cid)
     tmp["actvtmdl"] = {"cca": act, "ccpawdendtm": 0, "mcid": 1,
                        "ccedt": int(time.time())+(60*60*24*30),
                        "mced": int(time.time())+(60*60*24*30),
                        "ccid": 0, "ccpawd": 0}
     message2 = ["cln.upc", {"clm": tmp}]
     for member in clan["members"]:
         if member in self.server.online:
             tmp = self.server.online[member]
             loop = asyncio.get_event_loop()
             loop.create_task(tmp.send(message))
             loop.create_task(tmp.send(message2))
             if clan["members"][member]["role"] > 1:
                 loop.create_task(tmp.send(["crq.alr", {"rid": rid}]))
Пример #4
0
 async def leave_clan(self, msg, client):
     r = self.server.redis
     cid = await r.get(f"uid:{client.uid}:clan")
     if not cid:
         return
     if client.uid == await r.get(f"clans:{cid}:owner"):
         return
     await self.clan.leave_clan(cid, client.uid)
     cn = self.server.modules["cn"]
     await cn.add_action(cid, f"{client.uid}_1")
     await client.send(["ntf.cli", {"cli": None}])
     loop = asyncio.get_event_loop()
     loop.create_task(refresh_avatar(client, self.server))
Пример #5
0
 async def dismiss(self, msg, client):
     r = self.server.redis
     cid = await r.get(f"uid:{client.uid}:clan")
     if not cid:
         return
     clan = await self.get_clan(cid)
     if clan["members"][client.uid]["role"] != 3:
         return
     if msg[2]["pc"] != clan["pin"]:
         return await client.send(["cln.dcl", {"scs": False}])
     pipe = r.pipeline()
     pipe.delete(f"clans:{cid}:icon")
     pipe.delete(f"clans:{cid}:name")
     pipe.delete(f"clans:{cid}:tag")
     pipe.delete(f"clans:{cid}:pin")
     pipe.delete(f"clans:{cid}:room")
     pipe.delete(f"clans:{cid}:create_date")
     pipe.delete(f"clans:{cid}:owner")
     pipe.delete(f"clans:{cid}:adv")
     for uid in clan["members"]:
         pipe.delete(f"clans:{cid}:m:{uid}:role")
         pipe.delete(f"uid:{uid}:clan")
     pipe.delete(f"clans:{cid}:m")
     req = []
     for uid in await r.smembers(f"clans:{cid}:req"):
         pipe.delete(f"uid:{uid}:req")
         req.append(uid)
     pipe.delete(f"clans:{cid}:req")
     for action in await r.lrange(f"clans:{cid}:actions", 0, -1):
         pipe.delete(f"clans:{cid}:actions:{action}")
     pipe.delete(f"clans:{cid}:action")
     pipe.srem("clans", cid)
     await pipe.execute()
     loop = asyncio.get_event_loop()
     for uid in req:
         if uid in self.server.online:
             tmp = self.server.online[uid]
             loop.create_task(tmp.send(["crq.dlr", {"rid": uid}]))
     for uid in clan["members"]:
         if uid in self.server.online:
             tmp = self.server.online[uid]
             loop.create_task(tmp.send(["ntf.cli", {"cli": None}]))
             loop.create_task(refresh_avatar(tmp, self.server))
     await client.send(["cln.dcl", {"scs": True}])
Пример #6
0
 async def remove_member(self, msg, client):
     r = self.server.redis
     uid = msg[2]["uid"]
     cid = await r.get(f"uid:{client.uid}:clan")
     if not cid:
         return
     role = int(await r.get(f"clans:{cid}:m:{client.uid}:role"))
     sec_role = int(await r.get(f"clans:{cid}:m:{uid}:role"))
     if sec_role >= role:
         if client.uid != await r.get(f"clans:{cid}:owner"):
             return
     await self.clan.leave_clan(cid, uid)
     cn = self.server.modules["cn"]
     await cn.add_action(cid, f"{uid}_1_{client.uid}")
     if uid in self.server.online:
         tmp = self.server.online[uid]
         await tmp.send(["ntf.cli", {"cli": None}])
         loop = asyncio.get_event_loop()
         loop.create_task(refresh_avatar(tmp, self.server))