diff --git a/dr.botzo.py b/dr.botzo.py index 8dd0a98..099e943 100755 --- a/dr.botzo.py +++ b/dr.botzo.py @@ -545,14 +545,8 @@ class FactFile(Module): if os.path.isfile(filename): # http://www.regexprn.com/2008/11/read-random-line-in-large-file-in.html file = open(filename, 'r') - count = 0 - to_print = cur = file.readline() - while cur: - cur = file.readline() - count += 1 - if random.randint(0, count) == 0: - # 1/count chance to replace - to_print = cur + facts = file.readlines() + to_print = facts[random.randint(0, len(facts))] # return text if replypath is None: