home · contact · privacy
Simplify quote line counting.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 22 Jan 2016 01:59:14 +0000 (02:59 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 22 Jan 2016 01:59:14 +0000 (02:59 +0100)
plomlombot.py

index 9da1166..4befc39 100755 (executable)
@@ -151,8 +151,9 @@ def lineparser_loop(io, nickname):
                 quotesfile = open(quotesfile_name, "r")
                 lines = quotesfile.readlines()
                 quotesfile.close()
                 quotesfile = open(quotesfile_name, "r")
                 lines = quotesfile.readlines()
                 quotesfile.close()
-                i = random.randrange(len(lines) - 1) + 1
-                notice("QUOTE #" + str(i) + ": " + lines[i])
+                lines = lines[1:]
+                i = random.randrange(len(lines))
+                notice("QUOTE #" + str(i + 1) + ": " + lines[i])
 
         sender = ""
         for rune in tokens[0]:
 
         sender = ""
         for rune in tokens[0]: