summaryrefslogtreecommitdiffstats
path: root/Reaktor/titlebot/commands/up
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/up
parent9afc6e2d0237ae84c084cc05492bf0f285f98851 (diff)
add titlebot Reaktor configuration
Diffstat (limited to 'Reaktor/titlebot/commands/up')
-rwxr-xr-xReaktor/titlebot/commands/up27
1 files changed, 27 insertions, 0 deletions
diff --git a/Reaktor/titlebot/commands/up b/Reaktor/titlebot/commands/up
new file mode 100755
index 00000000..c9de1223
--- /dev/null
+++ b/Reaktor/titlebot/commands/up
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import json
+from os import environ
+import sys
+import os
+# krebs polling
+import poll
+
+f = 'suggestions.json'
+db = poll.load_db(f)
+votes = []
+try:
+ votes = sys.argv[1:]
+except:
+ print("""usage: up number (...)
+ upvotes one or more entries based on .list""")
+ sys.exit(1)
+
+voter = environ['_prefix']
+for vote in votes:
+ try:
+ vote = int(vote)
+ db[vote]['votes'][voter] = 1
+ except:
+ print("voting for #%s failed" %vote)
+print("Thanks for your votes %s"%environ['_from'])
+poll.save_db(f,db)