Exemplo n.º 1
0
def format_listing(listing, tell_more=False):
    t_count = Listing.count()
    s_count = len(listing)
    if t_count > s_count and tell_more:
        msg = '(Showing %s results out of %s)\n' % (s_count, len(t_count))
    else:
        msg = ''
    msg += ' | '.join(l_disp % i for i in listing)
    
    close_connection()
    return msg or 'There are no items listed!'
Exemplo n.º 2
0
def sub_add(client, nick, *args):
    if len(args) < 4 or not (args[0].isdigit() and args[-1].isdigit()):
        return ('Bad arguments! See the sub-command "help".')
    
    if Listing.count(seller=nick) >= client.mod_conf['listing']['max']:
        close_connection()
        return ('You have too many items listed! Use the "remove" sub-command '
                'alongside "show mine" to remove an item first.')
    
    p = int(args[-1])
    n = int(args[0])
    t = ' '.join(args[1:-2])
    w = args[-2]
    Listing(dict(seller=nick, quantity=n, price=p, item=t.lower(), word=w)
            ).add()
    close_connection()