summaryrefslogtreecommitdiffstats
path: root/Reaktor/titlebot/commands/list
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-04-25 12:06:50 +0200
committermakefu <github@syntax-fehler.de>2014-04-25 12:06:50 +0200
commit3907535dd48b94b3edd5facde0245719f04effb2 (patch)
treea25b7826c55cefe3be85f74b978bf0b9f2d19025 /Reaktor/titlebot/commands/list
parent9afc6e2d0237ae84c084cc05492bf0f285f98851 (diff)
add titlebot Reaktor configuration
Diffstat (limited to 'Reaktor/titlebot/commands/list')
-rwxr-xr-xReaktor/titlebot/commands/list27
1 files changed, 27 insertions, 0 deletions
diff --git a/Reaktor/titlebot/commands/list b/Reaktor/titlebot/commands/list
new file mode 100755
index 00000000..3a29919a
--- /dev/null
+++ b/Reaktor/titlebot/commands/list
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import json
+from os import environ
+import sys
+import os
+import poll
+
+f = 'suggestions.json'
+title=" ".join(sys.argv[1:])
+db = poll.load_db(f)
+if len(sys.argv) > 1 and ("-h" in sys.argv[1] or "usage" == sys.argv[1]):
+ print("""usage: list <(age|votes)>
+ sort by age or by votes (default: age)
+""")
+ sys.exit(0)
+
+if len(sys.argv) > 1 and ("votes" in sys.argv[1]):
+ use = poll.sort_by_votes(db)
+elif len(sys.argv) > 1 and ("age" in sys.argv[1]) or len(sys.argv) == 1:
+ pass
+else:
+ print("unknown sorting method")
+ sys.exit(1)
+
+for entry in poll.sort_by_votes(db):
+ print("#%d %s (votes: %d)" %
+ (db.index(entry),entry['title'],sum(entry['votes'].values())))