From 1b3d3b51e7a4e9ba0fabae29eaa4bd93aa588bb5 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Wed, 11 Sep 2013 17:41:59 +0800 Subject: [PATCH 1/2] Added better karma check. --- plugins/karma.py | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/plugins/karma.py b/plugins/karma.py index fd700a6..819fb4c 100644 --- a/plugins/karma.py +++ b/plugins/karma.py @@ -38,10 +38,10 @@ def down(db, nick_vote): def allowed(db, nick, nick_vote): time_restriction = 3600 db.execute("""DELETE FROM karma_voters WHERE ? - epoch >= 3600""", - (time.time(),)) + (time.time(),)) db.commit() check = db.execute("""SELECT epoch FROM karma_voters WHERE voter=? AND votee=?""", - (nick.lower(), nick_vote.lower())).fetchone() + (nick.lower(), nick_vote.lower())).fetchone() if check: check = check[0] @@ -53,7 +53,7 @@ def allowed(db, nick, nick_vote): db.commit() return True, 0 else: - return False, timesince.timeuntil(check, now=time.time()-time_restriction) + return False, timesince.timeuntil(check, now=time.time() - time_restriction) else: db.execute("""INSERT OR REPLACE INTO karma_voters( voter, @@ -68,9 +68,9 @@ def allowed(db, nick, nick_vote): # karma_re = ('((\S+)(\+\+|\-\-))+', re.I) karma_re = ('(.+)(\+\+|\-\-)$', re.I) + @hook.regex(*karma_re) def karma_add(match, nick='', chan='', db=None, notice=None): - if not db_ready: db_init(db) @@ -88,7 +88,7 @@ def karma_add(match, nick='', chan='', db=None, notice=None): nick_vote, up_karma, down_karma, - total_karma) values(?,?,?,?)""", (nick_vote.lower(),0,0,0)) + total_karma) values(?,?,?,?)""", (nick_vote.lower(), 0, 0, 0)) up(db, nick_vote) notice("Gave {} +1 karma!".format(nick_vote)) if match.group(2) == '--': @@ -96,7 +96,7 @@ def karma_add(match, nick='', chan='', db=None, notice=None): nick_vote, up_karma, down_karma, - total_karma) values(?,?,?,?)""", (nick_vote.lower(),0,0,0)) + total_karma) values(?,?,?,?)""", (nick_vote.lower(), 0, 0, 0)) down(db, nick_vote) notice("Took away 1 karma from {}.".format(nick_vote)) else: @@ -120,12 +120,32 @@ def karma(inp, nick='', chan='', db=None): nick_vote = inp out = db.execute("""SELECT * FROM karma WHERE nick_vote=?""", - (nick_vote.lower(),)).fetchall() + (nick_vote.lower(),)).fetchall() if not out: return "That user has no karma." else: out = out[0] - return "%s has \x02%s\x02 karma." % (nick_vote, out[1]-out[2]) + return "%s has \x02%s\x02 karma." % (nick_vote, out[1] - out[2]) - return + +@hook.command('dk') +@hook.command +def dkarma(inp, nick='', chan='', db=None): + """k/karma -- returns karma stats for in epeen.""" + + if not db_ready: + db_init(db) + + if not chan.startswith('#'): + return + + nick_vote = inp + out = db.execute("""SELECT * FROM karma WHERE nick_vote=?""", + (nick_vote.lower(),)).fetchall() + + if not out: + return "Vaginal karma detected." + else: + out = out[0] + return "{}'s epnis is \x02{}\x02cm long.".format(nick_vote, out[1] - out[2]) From 92e61a5348b5b0e948ec53d134a6aa12e9673953 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 27 Sep 2013 11:57:52 +0800 Subject: [PATCH 2/2] Remove broken double tuple --- plugins/quote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/quote.py b/plugins/quote.py index 25c614d..1af8874 100755 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -8,8 +8,8 @@ from util import hook def format_quote(q, num, n_quotes): """Returns a formatted string of a quote""" ctime, nick, msg = q - return "[{}/{}] <{}> {}".format((num, n_quotes, - nick, msg)) + return "[{}/{}] <{}> {}".format(num, n_quotes, + nick, msg) def create_table_if_not_exists(db):