def sendLookChange(this):
        try:
            p = ByteArray()
            look = this.client.playerLook.split(";")
            p.writeShort(int(look[0]))

            for item in look[1].split(","):
                if "_" in item:
                    itemSplited = item.split("_")
                    realItem = itemSplited[0]
                    custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                    realCustom = [] if custom == "" else custom.split("+")
                    p.writeInt(int(realItem)).writeByte(len(realCustom))
                    x = 0
                    while x < len(realCustom):
                        p.writeInt(int(realCustom[x], 16))
                        x += 1
                else:
                    p.writeInt(int(item)).writeByte(0)

            p.writeBytes('\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00').writeInt(
                int(this.client.MouseColor, 16))
            this.client.sendPacket(Identifiers.send.Look_Change,
                                   p.toByteArray())
        except:
            pass
Exemple #2
0
    def ForumsList(self):
        p = ByteArray("\x02\x02")
        p.writeUTF(self.langue)
        dbcur.execute("SELECT * FROM forum_forums where id < 1000")
        threads = dbcur.fetchall()
        for thread in threads:
            if str(thread[1]) in self.pf and self.priv < 4:

                pass
            else:
                p.writeInt(int(thread[1]))
                p.writeUTF(str(thread[0]))
                p.writeShort(int(thread[2]))
        if self.login:
            dbcur.execute("SELECT tribe FROM users where name = ?",
                          [self.username])
            td = dbcur.fetchone()
            if not td[0] == None:
                tdc = td[0].split("#")[1]
                dbcur.execute("SELECT * FROM tribu where Code = ?", [tdc])
                ntd = dbcur.fetchone()
                p.writeInt(int(tdc) + 2000)
                p.writeUTF("xx")
                p.writeShort(9)
                p.writeByte(False)
                p.writeUTF(ntd[1], True)

        self.transport.write(p.toPack())
    def sendShamanLook(this):
        items = ByteArray()

        count = 0
        for item in this.client.shamanLook.split(","):
            realItem = int(item.split("_")[0]) if "_" in item else int(item)
            if realItem != 0:
                items.writeShort(realItem)
                count += 1
        this.client.sendPacket(
            Identifiers.send.Shaman_Look,
            ByteArray().writeShort(count).writeBytes(
                items.toByteArray()).toByteArray())
    def sendShamanItems(this):
        p = ByteArray()

        shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split(
            ",")
        p.writeShort(len(shamanItems))

        for item in shamanItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")
                p.writeShort(int(realItem)).writeBool(
                    item in this.client.shamanLook.split(",")).writeByte(
                        len(realCustom) + 1)
                x = 0
                while x < len(realCustom):
                    p.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                p.writeShort(int(item)).writeBool(
                    item in this.client.shamanLook.split(",")).writeByte(0)

        this.client.sendPacket(Identifiers.send.Shaman_Items, p.toByteArray())
Exemple #5
0
    def sendShamanItems(self):
        shamanItems = [] if self.client.shamanItems == "" else self.client.shamanItems.split(
            ",")

        packet = ByteArray().writeShort(len(shamanItems))
        for item in shamanItems:
            if "_" in item:
                custom = item.split("_")[1] if len(
                    item.split("_")) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")
                packet.writeShort(int(item.split("_")[0])).writeBoolean(
                    item in self.client.shamanLook.split(",")).writeByte(
                        len(realCustom) + 1)
                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeShort(int(item)).writeBoolean(
                    item in self.client.shamanLook.split(",")).writeByte(0)
        self.client.sendPacket(Identifiers.send.Shaman_Items,
                               packet.toByteArray())
    def sendShopList(this, sendItems=True):
        shopItems = [] if this.client.shopItems == "" else this.client.shopItems.split(
            ",")

        packet = ByteArray().writeInt(this.client.shopCheeses).writeInt(
            this.client.shopFraises).writeUTF(this.client.playerLook).writeInt(
                len(shopItems))
        for item in shopItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")
                packet.writeByte(len(realCustom) + 1).writeInt(int(realItem))
                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeByte(0).writeInt(int(item))

        shop = this.server.shopList if sendItems else []
        packet.writeInt(len(shop))
        for item in shop:
            value = item.split(",")
            packet.writeShort(value[0]).writeShort(value[1]).writeByte(
                value[2]).writeByte(value[3]).writeByte(value[4]).writeInt(
                    value[5]).writeInt(value[6]).writeShort(0)

        visuais = this.server.newVisuList
        packet.writeByte(len(visuais))
        i = len(visuais)
        visu = []
        for visual in visuais.items():
            visu.append(visual[1])
            if visual[1] in visu:
                visu.remove(visual[1])
            packet.writeShort(visual[0])
            a = visual[1]
            packet.writeUTF(''.join(a))
            packet.writeByte(2 if visual[0] in [52] else 1 if visual[0] in
                             [53] else 2)
            i -= 1

        packet.writeShort(len(this.client.clothes))

        for clothes in this.client.clothes:
            clotheSplited = clothes.split("/")
            packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" +
                            clotheSplited[3])

        shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split(
            ",")
        packet.writeShort(len(shamanItems))
        for item in shamanItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if (len(itemSplited) >= 2) else ""
                realCustom = [] if custom == "" else custom.split("+")
                packet.writeShort(int(realItem)).writeBoolean(
                    item in this.client.shamanLook.split(",")).writeByte(
                        len(realCustom) + 1)
                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeShort(int(item)).writeBoolean(
                    item in this.client.shamanLook.split(",")).writeByte(0)

        shamanShop = this.server.shamanShopList if sendItems else []
        packet.writeShort(len(shamanShop))
        for item in shamanShop:
            value = item.split(",")
            packet.writeInt(value[0]).writeByte(value[1]).writeByte(
                value[2]).writeByte(value[3]).writeInt(value[4]).writeShort(
                    value[5])
        this.client.sendPacket(Identifiers.send.Shop_List,
                               packet.toByteArray())
    def sendShopList(this, sendItems=True):
        shopItems = [] if this.client.shopItems == "" else this.client.shopItems.split(
            ",")

        packet = ByteArray().writeInt(this.client.shopCheeses).writeInt(
            this.client.shopFraises).writeUTF(this.client.playerLook).writeInt(
                len(shopItems))
        for item in shopItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeByte(len(realCustom) + 1).writeInt(int(realItem))

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeByte(0).writeInt(int(item))

        shop = this.server.shopList if sendItems else []
        packet.writeInt(len(shop))

        for item in shop:
            value = item.split(",")
            packet.writeShort(int(value[0])).writeShort(int(
                value[1])).writeByte(int(value[2])).writeByte(
                    int(value[3])).writeByte(int(value[4])).writeInt(
                        int(value[5])).writeInt(int(value[6])).writeShort(0)

        looks = []
        packet.writeByte(len(looks))
        for look in looks:
            packet.writeShort(look[0])
            packet.writeUTF(look[1])
            packet.writeByte(look[2])

        packet.writeShort(len(this.client.clothes))

        for clothe in this.client.clothes:
            clotheSplited = clothe.split("/")
            packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" +
                            clotheSplited[3])

        shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split(
            ",")
        packet.writeShort(len(shamanItems))

        for item in shamanItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeShort(int(realItem))

                packet.writeBoolean(item in this.client.shamanLook.split(
                    ",")).writeByte(len(realCustom) + 1)

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeShort(int(item)).writeBoolean(
                    item in this.client.shamanLook.split(",")).writeByte(0)

        shamanShop = this.server.shamanShopList if sendItems else []
        packet.writeShort(len(shamanShop))

        for item in shamanShop:
            value = item.split(",")
            packet.writeInt(int(value[0])).writeByte(int(value[1])).writeByte(
                int(value[2])).writeByte(int(value[3])).writeInt(int(
                    value[4])).writeShort(int(value[5]))

        this.client.sendPacket(Identifiers.send.Shop_List,
                               packet.toByteArray())
    def openModoPwet(self,
                     isOpen=False,
                     modopwetOnlyPlayerReports=False,
                     sortBy=False):
        if isOpen:
            if len(self.server.reports) <= 0:
                self.client.sendPacket(Identifiers.send.Modopwet_Open, 0)
            else:
                self.client.sendPacket(Identifiers.send.Modopwet_Open, 0)
                reports, bannedList, deletedList, disconnectList = self.sortReports(
                    self.server.reports, sortBy), {}, {}, []
                sayi = 0
                p = ByteArray()
                for i in reports:
                    isim = i[0]
                    v = self.server.reports[isim]
                    if self.client.modoPwetLangue == 'ALL' or v[
                            "dil"] == self.client.modoPwetLangue:
                        oyuncu = self.server.players.get(isim)
                        saat = math.floor(oyuncu.playerTime /
                                          3600) if oyuncu else 0
                        odaisim = oyuncu.roomName if oyuncu else "0"
                        sayi += 1
                        self.client.lastReportID += 1
                        if sayi >= 255:
                            break
                        p.writeByte(sayi)
                        p.writeShort(self.client.lastReportID)
                        p.writeUTF(v["dil"])
                        p.writeUTF(isim)
                        p.writeUTF(odaisim)
                        p.writeByte(1)  # alttaki modname uzunlugu ile alakali
                        p.writeUTF(self.getRoomMods(odaisim))
                        p.writeInt(saat)  #idk
                        p.writeByte(int(len(v["reporters"])))
                        for name in v["reporters"]:
                            r = v["reporters"][name]
                            p.writeUTF(name)
                            p.writeShort(self.getPlayerKarma(name))  #karma
                            p.writeUTF(r[1])
                            p.writeByte(r[0])
                            p.writeShort(int(Utils.getSecondsDiff(r[2]) /
                                             60))  #05m felan rep suresi

                        mute = v["isMuted"]
                        p.writeBoolean(mute)  #isMute
                        if mute:
                            p.writeUTF(v["mutedBy"])
                            p.writeShort(v["muteHours"])
                            p.writeUTF(v["muteReason"])

                        if v['durum'] == 'banned':
                            x = {}
                            x['banhours'] = v['banhours']
                            x['banreason'] = v['banreason']
                            x['bannedby'] = v['bannedby']
                            bannedList[isim] = x
                        if v['durum'] == 'deleted':
                            x = {}
                            x['deletedby'] = v['deletedby']
                            deletedList[isim] = x
                        if v['durum'] == 'disconnected':
                            disconnectList.append(isim)

                self.client.sendPacket(
                    Identifiers.send.Modopwet_Open,
                    ByteArray().writeByte(int(len(reports))).writeBytes(
                        p.toByteArray()).toByteArray())
                for user in disconnectList:
                    self.changeReportStatusDisconnect(user)

                for user in deletedList.keys():
                    self.changeReportStatusDeleted(
                        user, deletedList[user]['deletedby'])

                for user in bannedList.keys():
                    self.changeReportStatusBanned(
                        user, bannedList[user]['banhours'],
                        bannedList[user]['banreason'],
                        bannedList[user]['bannedby'])
Exemple #9
0
    def openForums(self, forum_id, page):
        if page == -1: page = 0
        self.forum_id = forum_id
        if page != 0: limit1, limit2 = page * 20, page * 40
        else: limit1, limit2 = 0, 20

        p = ByteArray("\x02\x04")
        if forum_id == 1:
            openthread = self.user_type in [17, 18, 14, 20]
        else:
            openthread = True
        if self.username in om:
            openthread = False
        if not self.login:
            openthread = False
        p.writeBoolean(openthread)  # peutCreerSujet

        # [FORUM INFO] #

        ###Tribe Forums###
        if forum_id > 2000:
            dbcur.execute("SELECT * FROM forum_forums where id = ?",
                          [int(forum_id)])
            td = dbcur.fetchone()
            if not td == None:
                pass
            else:
                dbcur.execute("INSERT INTO forum_forums VALUES (?,?,?)",
                              ["xx", (forum_id), "9"])
            dbcur.execute("SELECT * FROM tribu where Code = ?",
                          [int(forum_id) - 2000])
            ntd = dbcur.fetchone()
            p.writeInt(forum_id)
            p.writeUTF("xx")
            p.writeShort(9)
            p.writeByte(False)
            p.writeUTF(ntd[1], True)
            dbcur.execute("SELECT * FROM forum_forums where id=?", [forum_id])
            forum = dbcur.fetchone()
        else:
            dbcur.execute("SELECT * FROM forum_forums where id=?", [forum_id])
            forum = dbcur.fetchone()
            p.writeInt(int(forum[1]))  # forumId
            p.writeUTF(str(forum[0]))  # forumCountry
            p.writeShort(int(forum[2]))  # forumIcon
        p.writeInt(page)  # pageCurrent
        p.writeInt(self.generateThreadsPage(forum_id) + 1)  # pageTotal
        #
        p.writeBoolean(
            False)  # masquerSujetCourrant # публичный форум : boolean

        dbcur.execute(
            "SELECT * FROM forum_threads where forum_id=? ORDER BY sticky DESC, date DESC LIMIT ?, ?",
            [forum_id, limit1, limit2])
        threads = dbcur.fetchall()
        threadNum = 0
        for row in threads:
            z = row[1]
            # [InfoServeurSujet] #
            dbcur.execute(
                "SELECT * FROM forum_comments where thread_id=? ORDER BY time DESC",
                [z])
            topicLastMessage = dbcur.fetchall()[0]
            p.writeInt(row[1])  # code
            p.writeUTF(row[2])  # titre
            p.writeInt(int(row[3]))  # date
            p.writeUTF(row[4].encode("cp1251"))  # auteur
            p.writeByte(self.getJoueurType(
                row[4].encode("cp1251")))  # typeAuteur
            p.writeUTF(topicLastMessage[3].encode("cp1251"))  # last_posteur
            p.writeInt(len(self.getcommentsbythread(row[1],
                                                    forum[1])))  # numMessage
            typeThread = 0
            if bool(row[7]): typeThread = 2
            p.writeByte(typeThread)  # type
            p.writeBoolean(bool(row[6]))  # postIt
            p.writeInt(threadNum)  # nombreSignalements
            threadNum += 1
        self.transport.write(p.toPack())