Exemple #1
0
	async def cancel(self):
		"""|coro|
		Cancels the trade."""
		if self.state != TradeState.TRADING:
			raise TradeOnWrongState('cancel', self.state)

		await self.client.main.send(Packet.new(31, 6).writeString(self.trader).write8(2))
Exemple #2
0
    async def accept(self):
        """|coro|
		Accepts the trade."""
        if self.state != TradeState.ON_INVITE:
            raise TradeOnWrongState('accept', self.state)

        self.state = TradeState.ACCEPTING
        await self.client.main.send(Packet.new(31, 5).writeString(self.trader))
Exemple #3
0
	async def unlock(self):
		"""|coro|
		Unlocks (cancels the confirmation) the trade."""
		if self.state != TradeState.TRADING:
			raise TradeOnWrongState('lock', self.state)
		if not self.locked[1]:
			raise TypeError("Can not unlock a trade that is not locked by the client.")

		await self.client.main.send(Packet.new(31, 9).writeBool(False))
Exemple #4
0
	async def lock(self):
		"""|coro|
		Locks (confirms) the trade."""
		if self.state != TradeState.TRADING:
			raise TradeOnWrongState('lock', self.state)
		if self.locked[1]:
			raise TypeError("Can not lock a trade that is already locked by the client.")

		await self.client.main.send(Packet.new(31, 9).writeBool(True))
Exemple #5
0
    async def removeItem(self, item_id, quantity):
        """|coro|
		Removes an item from the trade.

		:param item_id: :class:`int` The item id.
		:param quantity: :class:`int` The quantity of item to remove."""
        if self.state != TradeState.TRADING:
            raise TradeOnWrongState('removeItem', self.state)

        quantity = min(max(quantity, 0), 200)
        packet = Packet.new(31, 8).write16(item_id).writeBool(False).buffer

        ten = packet + b'\x01'
        for i in range(quantity // 10):
            await self.client.main.send(Packet(ten))
            await asyncio.sleep(.05)

        unit = packet + b'\x00'
        for i in range(quantity % 10):
            await self.client.main.send(Packet(unit))
            await asyncio.sleep(.05)