Skip to content

Commit 2517fc5

Browse files
author
davux
committed
The 'paid' command takes its target into account
Now the 'paid' command changes its output depending on the command's target, by including only payments to them.
1 parent dca18cd commit 2517fc5

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

bitcoim/command.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,33 @@ def _executePaid(self, user):
126126
user. The command behaves the same whatever the target (for now)."""
127127
reply = ''
128128
for payment in user.pastPayments():
129-
if payment.category in [CATEGORY_SEND, CATEGORY_MOVE]:
130-
reply += "\nBTC %s" % abs(payment.amount)
131-
if payment.otheraccount is not None:
132-
recipient = UserAccount(JID(payment.otheraccount))
129+
if payment.category not in [CATEGORY_SEND, CATEGORY_MOVE]:
130+
continue
131+
if self.target is not None and (self.target.jid != payment.otheraccount):
132+
continue
133+
reply += "\nBTC %s" % abs(payment.amount)
134+
if payment.otheraccount is not None:
135+
recipient = UserAccount(JID(payment.otheraccount))
136+
if recipient != self.target:
133137
if user.isAdmin() or (0 != len(recipient.username)):
134138
reply += " to %s" % recipient.getLabel()
135139
else:
136140
reply += " to another user who became invisible since then"
137-
if payment.message is not None:
138-
reply += " (%s)" % payment.message
139-
confirmations = payment.confirmations
140-
if 0 <= confirmations:
141-
reply += " – %s confirmations" % payment.confirmations
141+
if payment.message is not None:
142+
reply += " (%s)" % payment.message
143+
confirmations = payment.confirmations
144+
if 0 <= confirmations:
145+
reply += " – %s confirmations" % payment.confirmations
142146
if 0 == len(reply):
143-
reply = "You didn't send any coins"
147+
if self.target is None:
148+
reply = "You didn't send any coins"
149+
else:
150+
reply = "You didn't send me any coins"
144151
else:
145-
reply = "You paid:%s" % reply
152+
if self.target is None:
153+
reply = "You paid:%s" % reply
154+
else:
155+
reply = "You paid me:%s" % reply
146156
return reply
147157

148158
def _executeCancel(self, user, code=None):

0 commit comments

Comments
 (0)