'Initiate trade'

def func(self):

    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()
    selfemote = ''
    theiremote = ''
    if (':' in self.args):
        (self.args, emote) = [part.strip() for part in self.args.rsplit(':', 1)]
        selfemote = ('You    say,    "%s"\n        ' % emote)
        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))
    part_a = self.caller
    accept = ('accept' in self.args)
    decline = ('decline' in self.args)
    if accept:
        part_b = self.args.rstrip('accept').strip()
    elif decline:
        part_b = self.args.rstrip('decline').strip()
    else:
        part_b = self.args
    part_b = self.caller.search(part_b)
    if (not part_b):
        return
    if (part_a == part_b):
        part_a.msg('You    play    trader    with    yourself.')
        return
    str_init_a = 'You    ask    to    trade    with    %s.    They    need    to    accept    within    %s    secs.'
    str_init_b = '%s    wants    to    trade    with    you.    Use    |wtrade    %s    accept/decline    [:emote]|n    to    answer    (within    %s    secs).'
    str_noinit_a = '%s    declines    the    trade'
    str_noinit_b = 'You    decline    trade    with    %s.'
    str_start_a = '%s    starts    to    trade    with    you.    See    |wtrade    help|n    for    aid.'
    str_start_b = 'You    start    to    trade    with    %s.    See    |wtrade    help|n    for    aid.'
    if (not (accept or decline)):
        if self.caller.ndb.tradehandler:
            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 % part_b.key))
        elif (part_b.ndb.tradehandler and (part_b.ndb.tradehandler.part_b == part_a)):
            part_b.ndb.tradehandler.join(part_a)
            part_b.msg((theiremote + (str_start_a % part_a.key)))
            part_a.msg((selfemote + (str_start_b % part_b.key)))
        else:
            TradeHandler(part_a, part_b)
            part_a.msg((selfemote + (str_init_a % (part_b.key, TRADE_TIMEOUT))))
            part_b.msg((theiremote + (str_init_b % (part_a.key, part_a.key, TRADE_TIMEOUT))))
            part_a.scripts.add(TradeTimeout)
        return
    elif accept:
        if part_a.ndb.tradehandler:
            part_a.msg(('You    are    already    in    trade    with    %s.    You    need    to    end    that    first.' % part_b.key))
            return
        if part_b.ndb.tradehandler.join(part_a):
            part_b.msg((theiremote + (str_start_a % part_a.key)))
            part_a.msg((selfemote + (str_start_b % part_b.key)))
        else:
            part_a.msg('No    trade    proposal    to    accept.')
        return
    else:
        if (part_a.ndb.tradehandler and (part_a.ndb.tradehandler.part_b == part_a)):
            part_a.ndb.tradehandler.finish(force=True)
            part_b.msg((theiremote + ('%s    aborted    trade    attempt    with    you.' % part_a)))
            part_a.msg((selfemote + ('You    aborted    the    trade    attempt    with    %s.' % part_b)))
        elif (part_b.ndb.tradehandler and part_b.ndb.tradehandler.unjoin(part_a)):
            part_b.msg((theiremote + (str_noinit_a % part_a.key)))
            part_a.msg((selfemote + (str_noinit_b % part_b.key)))
        else:
            part_a.msg('No    trade    proposal    to    decline.')
        return
