def get_quote_by_nick_chan(db, chan, nick, num=False):
 count_query = select([qtable]).where((qtable.c.deleted != 1)).where((qtable.c.chan == chan)).where((qtable.c.nick == nick.lower())).count()
 count = db.execute(count_query).fetchall()[0][0]
 try:
  num = get_quote_num(num, count, nick)
 except Exception as error_message:
  return error_message
 query = select([qtable.c.time, qtable.c.nick, qtable.c.msg]).where((qtable.c.deleted != 1)).where((qtable.c.chan == chan)).where((qtable.c.nick == nick.lower())).order_by(qtable.c.time).limit(1).offset((num - 1))
 data = db.execute(query).fetchall()[0]
 return format_quote(data, num, count)

def get_quote_by_nick_chan ( db , chan , nick , num = False ) : count_query = select ( [ qtable ] ) . where ( ( qtable . c . deleted != 1 ) ) . where ( ( qtable . c . chan == chan ) ) . where ( ( qtable . c . nick == nick . lower ( ) ) ) . count ( ) count = db . execute ( count_query ) . fetchall ( ) [ 0 ] [ 0 ] try : num = get_quote_num ( num , count , nick ) except Exception as error_message : return error_message query = select ( [ qtable . c . time , qtable . c . nick , qtable . c . msg ] ) . where ( ( qtable . c . deleted != 1 ) ) . where ( ( qtable . c . chan == chan ) ) . where ( ( qtable . c . nick == nick . lower ( ) ) ) . order_by ( qtable . c . time ) . limit ( 1 ) . offset ( ( num - 1 ) ) data = db . execute ( query ) . fetchall ( ) [ 0 ] return format_quote ( data , num , count )
returns a formatted quote from a nick in a channel .