You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/karma.py
+32-25Lines changed: 32 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
karmaminus_re=re.compile('^.*\-\-$')
9
9
db_ready= []
10
10
11
+
11
12
defdb_init(db, conn_name):
12
13
"""Check to see if the DB has the herald table. Connection name is for caching the result per connection.
13
14
:type db: sqlalchemy.orm.Session
@@ -21,10 +22,10 @@ def db_init(db, conn_name):
21
22
22
23
@hook.command("pp", "addpoint")
23
24
defaddpoint(text, nick, chan, db, conn):
24
-
""".addpoint or (.pp) <thing> adds a point to the <thing>"""
25
+
"""<thing> - adds a point to the <thing>"""
25
26
text=text.strip()
26
27
db_init(db, conn.name)
27
-
karma=db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", {'name':nick, 'chan': chan, 'thing': text.lower()}).fetchone()
28
+
karma=db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", {'name':nick, 'chan': chan, 'thing': text.lower()}).fetchone()
#return "{} is now worth 1 in {}'s eyes.".format(text, nick)
38
+
# return "{} is now worth 1 in {}'s eyes.".format(text, nick)
39
+
38
40
39
41
@hook.regex(karmaplus_re)
40
42
defre_addpt(match, nick, chan, db, conn, notice):
41
43
"""no useful help txt"""
42
44
thing=match.group().split('++')[0]
43
45
ifthing:
44
46
addpoint(thing, nick, chan, db, conn)
45
-
#return out
47
+
#return out
46
48
else:
47
49
notice(pluspts(nick, chan, db, conn))
48
50
51
+
49
52
@hook.command("mm", "rmpoint")
50
53
defrmpoint(text, nick, chan, db, conn):
51
-
""".rmpoint or (.mm) <thing> subtracts a point from the <thing>"""
54
+
"""<thing> - subtracts a point from the <thing>"""
52
55
text=text.strip()
53
56
db_init(db, conn.name)
54
-
karma=db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", {'name':nick, 'chan': chan, 'thing': text.lower()}).fetchone()
57
+
karma=db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", {'name':nick, 'chan': chan, 'thing': text.lower()}).fetchone()
#return "{} is now worth -1 in {}'s eyes.".format(text, nick)
67
+
#return "{} is now worth -1 in {}'s eyes.".format(text, nick)
65
68
66
69
67
70
@hook.command("pluspts", autohelp=False)
68
71
defpluspts(nick, chan, db, conn):
69
-
"""prints the things you have liked"""
72
+
"""- prints the things you have liked and their scores"""
70
73
db_init(db, conn.name)
71
74
output=""
72
-
likes=db.execute("select thing, score from karma where name = :name and chan = :chan and score >= 0 order by score desc", {'name': nick, 'chan': chan}).fetchall()
75
+
likes=db.execute("select thing, score from karma where name = :name and chan = :chan and score >= 0 order by score desc", {'name': nick, 'chan': chan}).fetchall()
73
76
forlikeinlikes:
74
-
output=output+str(like[0]) +" has "+str(like[1]) +" points "
77
+
output=output+str(like[0]) +" has "+str(like[1]) +" points "
75
78
returnoutput
76
79
80
+
77
81
@hook.command("minuspts", autohelp=False)
78
82
defminuspts(nick, chan, db, conn):
79
-
"""prints the things you have liked"""
83
+
"""- prints the things you have disliked and their scores"""
80
84
db_init(db, conn.name)
81
85
output=""
82
-
likes=db.execute("select thing, score from karma where name = :name and chan = :chan and score <= 0 order by score", {'name': nick, 'chan': chan}).fetchall()
86
+
likes=db.execute("select thing, score from karma where name = :name and chan = :chan and score <= 0 order by score", {'name': nick, 'chan': chan}).fetchall()
83
87
forlikeinlikes:
84
-
output=output+str(like[0]) +" has "+str(like[1]) +" points "
88
+
output=output+str(like[0]) +" has "+str(like[1]) +" points "
85
89
returnoutput
86
90
91
+
87
92
@hook.regex(karmaminus_re)
88
93
defre_rmpt(match, nick, chan, db, conn, notice):
89
94
"""no useful help txt"""
90
95
thing=match.group().split('--')[0]
91
96
ifthing:
92
97
rmpoint(thing, nick, chan, db, conn)
93
-
#return out
98
+
#return out
94
99
else:
95
100
notice(minuspts(nick, chan, db, conn))
96
101
97
102
98
103
@hook.command("points", autohelp=False)
99
104
defpoints(text, chan, db, conn):
100
-
""".points <thing> will print the total points for <thing> in the channel."""
105
+
"""<thing> - will print the total points for <thing> in the channel."""
""".topten or .pointstop prints the top 10 things with the highest points in the channel. To see the top 10 items in all of the channels the bot sits in use .topten global."""
134
+
"""- prints the top 10 things with the highest points in the channel. To see the top 10 items in all of the channels the bot sits in use .topten global."""
""".bottomten or .pointsbottom prints the top 10 things with the highest points in the channel. To see the top 10 items in all of the channels the bot sits in use .topten global."""
165
+
"""- prints the top 10 things with the lowest points in the channel. To see the bottom 10 items in all of the channels the bot sits in use .bottomten global."""
0 commit comments