mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Coop lockout fix, holidays full list, !fx convert, lottery cleanup
- Co-op: when a run wipes or completes, clear the 99-sentinel combat lock for participants and pin combat_actions_used to maxCombatActions. Previously the lock only released on the next midnight reset, so members were stuck unable to combat for the rest of the day after their run ended. - Holidays: !holidays now prints the full list. Previously it called the same featured-only formatter as TwinBee's morning auto-post, so users saw the same truncated message twice with a misleading "Use !holidays for the full list" hint that pointed at itself. - Forex: add currency conversion. Auto-detects when the first arg is numeric (`!fx 1500 USD EUR`) and also accepts an explicit `convert` subcommand. Tolerant parsing: "to"/"into"/"in"/"=" filters, comma and k/m suffix support, and any of `1500 USD EUR`, `1500 USD/EUR`, `USD/EUR 1500` orderings. Includes parser + comma-formatter tests. - Lottery: drop 2-match prize tier. At 1/16 odds × €25 it was +EV per ticket on its own and bled the community pot (~€775/wk recently), preventing jackpot rollover from accumulating. Removed from scoring, payout loops, draw announcement, !lottery odds, and !lottery history. Match2Winners DB column kept (history rows preserved); always written as 0 going forward. - Lottery: shift week boundary so Sat/Sun return next Monday. Friday's 23:59 draw used to leave players locked at their 100-ticket cap until next Monday rolled in; now the cap resets immediately after the draw. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,7 @@ func (p *ForexPlugin) Name() string { return "forex" }
|
||||
|
||||
func (p *ForexPlugin) Commands() []CommandDef {
|
||||
return []CommandDef{
|
||||
{Name: "fx", Description: "Forex rates and analysis", Usage: "!fx rate [EUR|JPY] · !fx report [EUR|JPY] · !fx setalert <cur> <rate> · !fx alerts · !fx delalert <cur> <rate>", Category: "Entertainment"},
|
||||
{Name: "fx", Description: "Forex rates, conversion, and analysis", Usage: "!fx rate [EUR|JPY] · !fx 1500 USD to EUR · !fx report [EUR|JPY] · !fx setalert <cur> <rate> · !fx alerts · !fx delalert <cur> <rate>", Category: "Entertainment"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,23 @@ func (p *ForexPlugin) OnMessage(ctx MessageContext) error {
|
||||
args := strings.TrimSpace(p.GetArgs(ctx.Body, "fx"))
|
||||
if args == "" {
|
||||
return p.SendReply(ctx.RoomID, ctx.EventID,
|
||||
"Usage: `!fx rate [EUR|JPY]` · `!fx report [EUR|JPY]` · `!fx setalert <currency> <rate>` · `!fx alerts` · `!fx delalert <currency> <rate>`")
|
||||
"Usage: `!fx rate [EUR|JPY]` · `!fx 1500 USD to EUR` · `!fx report [EUR|JPY]` · `!fx setalert <currency> <rate>` · `!fx alerts` · `!fx delalert <currency> <rate>`")
|
||||
}
|
||||
|
||||
parts := strings.Fields(args)
|
||||
sub := strings.ToLower(parts[0])
|
||||
|
||||
// Auto-detect conversion: if the first token parses as a number,
|
||||
// treat the whole arg list as a convert request (e.g. `!fx 1500 USD EUR`).
|
||||
if _, err := fxParseAmount(parts[0]); err == nil {
|
||||
safeGo("forex-handler", func() {
|
||||
if err := p.cmdConvert(ctx, parts); err != nil {
|
||||
slog.Error("forex: handler error", "err", err)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// DB-only and instant subcommands
|
||||
switch sub {
|
||||
case "setalert":
|
||||
@@ -85,6 +96,13 @@ func (p *ForexPlugin) OnMessage(ctx MessageContext) error {
|
||||
}
|
||||
})
|
||||
return nil
|
||||
case "convert":
|
||||
safeGo("forex-handler", func() {
|
||||
if err := p.cmdConvert(ctx, parts[1:]); err != nil {
|
||||
slog.Error("forex: handler error", "err", err)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
default:
|
||||
return p.SendReply(ctx.RoomID, ctx.EventID, fmt.Sprintf("Unknown subcommand `%s`. Try `!fx help`.", parts[0]))
|
||||
}
|
||||
@@ -94,6 +112,7 @@ const fxHelpText = "**Forex Commands**\n\n" +
|
||||
"`!fx rate [EUR|JPY|CAD]` — current rate + quick signal\n" +
|
||||
"`!fx rate EUR/USD` — cross-pair rate from first currency's perspective\n" +
|
||||
"`!fx report [EUR|JPY|CAD]` — full analysis (averages, 52w range, buy score)\n" +
|
||||
"`!fx 1500 USD to EUR` — convert an amount (also: `!fx convert 1500 USD EUR`)\n" +
|
||||
"`!fx setalert <currency> <rate>` — alert when USD/currency reaches threshold\n" +
|
||||
"`!fx alerts` — list active alerts in this room\n" +
|
||||
"`!fx delalert <currency> <rate>` — remove an alert\n" +
|
||||
|
||||
Reference in New Issue
Block a user