|
2 | 2 | import re |
3 | 3 | from collections import defaultdict |
4 | 4 |
|
| 5 | +import sqlalchemy |
5 | 6 | from sqlalchemy import Table, String, Column, Integer, PrimaryKeyConstraint |
6 | 7 |
|
7 | 8 | from cloudbot import hook |
|
21 | 22 | ) |
22 | 23 |
|
23 | 24 |
|
| 25 | +@hook.on_start |
| 26 | +def remove_non_channel_points(db): |
| 27 | + """Temporary on_start hook to remove non-channel points""" |
| 28 | + db.execute(karma_table.delete().where(sqlalchemy.not_(karma_table.c.chan.startswith('#')))) |
| 29 | + db.commit() |
| 30 | + |
| 31 | + |
24 | 32 | @hook.command("pp", "addpoint") |
25 | 33 | def addpoint(text, nick, chan, db): |
26 | 34 | """<thing> - adds a point to the <thing>""" |
| 35 | + if nick.casefold() == chan.casefold(): |
| 36 | + # This is a PM, don't set points in a PM |
| 37 | + return |
| 38 | + |
27 | 39 | text = text.strip() |
28 | 40 | karma = db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", |
29 | 41 | {'name': nick, 'chan': chan, 'thing': text.lower()}).fetchone() |
@@ -55,6 +67,10 @@ def re_addpt(match, nick, chan, db, conn, notice): |
55 | 67 | @hook.command("mm", "rmpoint") |
56 | 68 | def rmpoint(text, nick, chan, db): |
57 | 69 | """<thing> - subtracts a point from the <thing>""" |
| 70 | + if nick.casefold() == chan.casefold(): |
| 71 | + # This is a PM, don't set points in a PM |
| 72 | + return |
| 73 | + |
58 | 74 | text = text.strip() |
59 | 75 | karma = db.execute("select score from karma where name = :name and chan = :chan and thing = :thing", |
60 | 76 | {'name': nick, 'chan': chan, 'thing': text.lower()}).fetchone() |
|
0 commit comments