Conversation
updating cause I forked this ages ago
1 similar comment
LordAro
left a comment
There was a problem hiding this comment.
An excellent start! No, really, there's little to no documentation for doing this, so it's not the easiest thing in the world
Some tests would be excellent, and mind the codestyle in a few places - when to put spaces around operators, particularly (A plugin for whatever editor you're using really helps with this!)
src/csbot/plugins/iou.py
Outdated
| @Plugin.command('iou', help = ('equivalent to IOU')) | ||
| def iou(self, e): | ||
| nick_ = nick(e['user']).strip('<') | ||
| nick_ = nick_.strip('>') |
There was a problem hiding this comment.
nick would never contain these characters
There was a problem hiding this comment.
Are you sure? I did this when trying to fix iamowed, where
!iou a b n
!iamowed b a
always returned 0 instead of n, and after a bit of poking it seemed that the reason was cause e['user'] gave the name in <>. I may be wrong, but in that case there's probably something else majorly wrong, so it would be good to know for sure. (By which I mean I'll check, but if you know it would be useful, and also won't fix immediately)
There was a problem hiding this comment.
Hmm, there is some weirdness with e['user'] - i notice csbot.util.nick is used in almost every place that e['user'] is, though that only splits on '!'. Should probably use that regardless, rather than the strips
src/csbot/plugins/iou.py
Outdated
|
|
||
| self.blankuser = {"_id": "example", "owee_nick": 0} | ||
|
|
||
| x = self.db_owage.insert(self.blankuser) |
There was a problem hiding this comment.
is this setup stuff necessary? I don't see it being done in the other mongodb plugins
src/csbot/plugins/iou.py
Outdated
| def update_owage(self, nick, owee_name, amount): | ||
| all_owed = self.db_owage.find_one(nick) | ||
| if all_owed: | ||
| self.db_owage.delete_one(all_owed) |
There was a problem hiding this comment.
perhaps using update_one would be better than finding, deleting, inserting, then finding again
iou and iamowed commands, using iou plugin