-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iou plugin #160
base: main
Are you sure you want to change the base?
iou plugin #160
Conversation
updating cause I forked this ages ago
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nick would never contain these characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps using update_one would be better than finding, deleting, inserting, then finding again
iou and iamowed commands, using iou plugin