From d7bdbaaa1659289be2b07a532f98058ecba32916 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 25 Apr 2014 12:06:50 +0200 Subject: add titlebot Reaktor configuration --- titlebot/commands/undo | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 titlebot/commands/undo (limited to 'titlebot/commands/undo') diff --git a/titlebot/commands/undo b/titlebot/commands/undo new file mode 100755 index 0000000..bebd57a --- /dev/null +++ b/titlebot/commands/undo @@ -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: undo number (...) + undos vote of one or more entries based on .list""") + sys.exit(1) +voter = environ['_prefix'] +for vote in votes: + try: + vote = int(vote) + del(db[vote]['votes'][voter] ) + print("undid vote by %s for #%d" %(environ['_from'],vote)) + except: + print("undo voting for #%s failed" %vote) + +poll.save_db(f,db) -- cgit v1.2.3