def func(self):
        "Initiate trade"

        if not self.args:
            if self.caller.ndb.tradehandler and self.caller.ndb.tradeevent.trade_started:
                self.caller.msg("You are already in a trade. Use 'end trade' to abort it.")
            else:
                self.caller.msg("Usage: trade <other party> [accept|decline] [:emote]")
            return
        self.args = self.args.strip()

        # handle the emote manually here
        selfemote = ""
        theiremote = ""
        if ':' in self.args:
            self.args, emote = [part.strip() for part in self.args.rsplit(":", 1)]
            selfemote = emote % 'You say, "%s"\n  '
            if self.caller.has_player:
                theiremote = '{c%s{n says, "%s"\n  ' % (self.caller.key, emote)
            else:
                theiremote = '%s says, "%s"\n  ' % (self.caller.key, emote)

        # for the sake of this command, the caller is always partA; this
        # might not match the actual name in tradehandler (in the case of
        # using this command to accept/decline a trade invitation).
        partA = self.caller
        accept = 'accept' in self.args
        decline = 'decline' in self.args
        if accept:
            partB = self.args.rstrip('accept').strip()
        elif decline:
            partB = self.args.rstrip('decline').strip()
        else:
            partB = self.args
        partB = self.caller.search(partB)
        if not partB:
            return
        if partA == partB:
            partA.msg("You play trader with yourself.")
            return

        # messages
        str_initA = "You ask to trade with %s. They need to accept within %s secs."
        str_initB = "%s wants to trade with you. Use {wtrade %s accept/decline [:emote]{n to answer (within %s secs)."
        str_noinitA = "%s declines the trade"
        str_noinitB = "You decline trade with %s."
        str_startA = "%s starts to trade with you. See {wtrade help{n for aid."
        str_startB = "You start to trade with %s. See {wtrade help{n for aid."

        if not (accept or decline):
            # initialization of trade
            if self.caller.ndb.tradehandler:
                # trying to start trade without stopping a previous one
                if self.caller.ndb.tradehandler.trade_started:
                    string = "You are already in trade with %s. You need to end trade first."
                else:
                    string = "You are already trying to initiate trade with %s. You need to decline that trade first."
                self.caller.msg(string % partB.key)
            elif partB.ndb.tradehandler and partB.ndb.tradehandler.partB == partA:
                # this is equivalent to partA accepting a trade from partB (so roles are reversed)
                partB.ndb.tradehandler.join(partA)
                partB.msg(theiremote + str_startA % partA.key)
                partA.msg(selfemote + str_startB % (partB.key))
            else:
                # initiate a new trade
                TradeHandler(partA, partB)
                partA.msg(selfemote + str_initA % (partB.key, TRADE_TIMEOUT))
                partB.msg(theiremote + str_initB % (partA.key, partA.key, TRADE_TIMEOUT))
                partA.scripts.add(TradeTimeout)
            return
        elif accept:
            # accept a trade proposal from partB (so roles are reversed)
            if partA.ndb.tradehandler:
                # already in a trade
                partA.msg("You are already in trade with %s. You need to end that first." % partB.key)
                return
            if partB.ndb.tradehandler.join(partA):
                partB.msg(theiremote + str_startA % partA.key)
                partA.msg(selfemote + str_startB % partB.key)
            else:
                partA.msg("No trade proposal to accept.")
            return
        else:
            # decline trade proposal from partB (so roles are reversed)
            if partA.ndb.tradehandler and partA.ndb.tradehandler.partB == partA:
                # stopping an invite
                partA.ndb.tradehandler.finish(force=True)
                partB.msg(theiremote + "%s aborted trade attempt with you." % partA)
                partA.msg(selfemote + "You aborted the trade attempt with %s." % partB)
            elif partB.ndb.tradehandler and partB.ndb.tradehandler.unjoin(partA):
                partB.msg(theiremote + str_noinitA % partA.key)
                partA.msg(selfemote + str_noinitB % partB.key)
            else:
                partA.msg("No trade proposal to decline.")
            return
dataset/ETHPy150Open evennia/evennia/evennia/contrib/barter.py/CmdTrade.func/swapped operands of `%`