def say_random(text): word = text.split()[0] if random.randint(0, 1) == 1: if random.randint(0, 1) == 1: word = word + " " else: word = " " + word msg = "" n = 0 r = Message.select().where(Message.message.contains(word)) count = r.count() if count > 0: while n < 3: msg = r[random.randrange(0, count)] if len(msg.message) < 100: break n += 1 if msg == "": n = 0 while n < 3: msg = Message.select()[random.randrange(0, Message.select().count())] n += 1 if len(msg.message) < 100: break return msg.message
def say_random(): msg = "" n = 0 while n < 3: msg = Message.select()[random.randrange(0, Message.select().count())] n += 1 if len(msg.message) < 100: break return msg.message
def stats(cmd): msg_q = Message.select() msgs = [msg for msg in msg_q] s = _("""Total number of messages: {msg_count}""").format( msg_count=len(msgs)) return s