N1/A5: ticket sales fund the community pot

`!lottery pot` has always claimed "pot is funded by ... ticket sales", and
the draw debits prizes from that pot -- but handleLotteryBuy only debited
the player, so ticket euros were burned and the lottery ran as a pure drain
on rake income from elsewhere.

Credit the pot after lotteryInsertTickets succeeds, so the refund path can't
strand money in it.

Watch pot-drain-vs-rake per project_lottery_economics: if weekly pot growth
jumps, tune the prize tiers rather than the ticket price.
This commit is contained in:
prosolis
2026-07-09 18:32:23 -07:00
parent e8f4863ae0
commit c9df282fde

View File

@@ -125,6 +125,13 @@ func (p *LotteryPlugin) handleLotteryBuy(ctx MessageContext, args string) error
return p.SendReply(ctx.RoomID, ctx.EventID, "Something went wrong buying tickets. You've been refunded.")
}
// Ticket euros fund the pot, which is what `!lottery pot` has always
// claimed and what the draw assumes — prizes debit the pot, so without
// this the lottery is a pure drain on rake income from elsewhere.
// Credited only after the tickets persist, so the refund path above
// can't strand money in the pot.
communityPotAdd(int(cost))
// Build confirmation.
var sb strings.Builder
sb.WriteString(fmt.Sprintf("🎟️ **%d ticket(s) purchased** — €%d\n\n", n, n))